I have the following code where I want to push changes in my branch to gerrit using GitpYthon.
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")
It adds and commits the file(s), but when I want to push to refs/for/master I get an issue:
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
username@url: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''
Do note that I am standing in the cloned repo. Of course I can install the git hook change-id manually in git bash. But since this is supposed to be done automatically I want to know if there is a way to do that via gitpython.