0
我有下面的代碼,我想使用GitpYthon將我的分支中的更改推送到gerrit。使用Gitpython推refs/for/master和change-id問題
repo_path_new = repo_path+repo_name
repo_obj = Repo(repo_path_new)
os.chdir(repo_path_new)
repo_obj.git.add(A=True)
if commit_command_line(commit_message, repo_obj, repo_name):
repo_obj.git.push("origin", "HEAD:refs/for/master")
它補充,並提交該文件(S),但是當我要推到裁判/爲/主,我碰到一個問題:
remote: Processing changes: refs: 1, done
remote: ERROR: [0f7c907] missing Change-Id in commit message footer
remote:
remote: Hint: To automatically insert Change-Id, install the hook:
remote: gitdir=$(git rev-parse --git-dir); scp -p -P port
[email protected]:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote: git commit --amend
remote:
To ssh://url:port/repo-name
! [remote rejected] HEAD -> refs/for/master ([0f7c907] missing Change-Id in commit message footer)
error: failed to push some refs to 'ssh://url:port/repo-name''
請注意,我站在克隆回購。當然,我可以在git bash中手動安裝git hook change-id。但由於這應該是自動完成的,我想知道是否有辦法通過gitpython來做到這一點。
我手動克隆存儲庫。當我按照你所說的方式安裝時,它會工作,但由於該腳本將在Go cd中運行(就像Jenkins一樣),因此無法確定是否存在commit-msg掛鉤。在我的代碼中,我打電話給你第一個選項,它在gitdir上失敗(無法找到它)。 – user535081
您可以在克隆存儲庫之後並在執行gitpython腳本之前設置go-cd執行bash腳本(使用命令安裝commit-msg掛鉤)? –