Gerrit error when Change-Id in commit messages are missing

前端 未结 12 1144
北荒
北荒 2020-11-28 03:58

I set up a branch in the remote repository and made some commits on that branch. Now I want to merge the remote branch to the remote master.

Basically follows are my

相关标签:
12条回答
  • 2020-11-28 04:22

    If you need to add Change-Id to multiple commits, you can download the hook from your Gerrit server and run these commands to add the Change-Ids to all commits that need them at once. The example below fixes all commits on your current branch that have not yet been pushed to the upstream branch.

    tmp=$(mktemp)
    hook=$(readlink -f $(git rev-parse --git-dir))/hooks/commit-msg
    git filter-branch -f --msg-filter "cat > $tmp; \"$hook\" $tmp; cat $tmp" @{u}..HEAD
    
    0 讨论(0)
  • 2020-11-28 04:25

    It is because Gerrit is configured to require Change-Id in the commit messages.

    http://gerrit.googlecode.com/svn-history/r6114/documentation/2.1.7/error-missing-changeid.html

    You have to change the messages of every commit that you are pushing to include the change id ( using git filter-branch ) and only then push.

    0 讨论(0)
  • 2020-11-28 04:26

    This can also happen if you have this restriction:

    Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit.

    and you do like me: write a commit message starting with "#" .....

    I had the same error, but I already had the commit-msg and did the rebase and everything. Very silly mistake though :D

    0 讨论(0)
  • 2020-11-28 04:28

    We solved this issue this morning by re-cloning repository and re-applying changes. This is the simplest way to re-sync your local copy with Gerrit. As always we created a backup first.

    Although there are a number of other wildly complicated solutions, its often advantageous to take a simple approach to avoid making things worse.

    0 讨论(0)
  • 2020-11-28 04:31

    You might be an admin doing a one-off push directly into refs/changes/<change_number>.

    For example, once a commit without Change-Id landed into Subversion, you pull it out of Subversion using git-svn, and you'd like to archive it as a Gerrit patchset into a Gerrit change.

    If so, you can go to project settings page (http://[installation-path]/#/admin/projects/[project-id]) and temporarily change "Require Change-Id in commit message" value to False.

    Don't forget to afterwards change it back to Inherit or True!

    0 讨论(0)
  • 2020-11-28 04:32

    Check your git repo before committing

    gitrepo/.git/hooks/commit-msg
    

    if this file is not present in that location then you will get this error "missing Change-Id in commit message" .

    To solve this just copy paste the commit hook in .git folder.

    0 讨论(0)
提交回复
热议问题