hemantvsn
hemantvsn

Reputation: 1446

Gerrit reports change-Id not found for earlier commits

I am trying to setup gerrit code review for my existing GIT project.

The gerrit instance was running on my local on port 9090.

Following is the process I followed

  1. Create empty project in Gerrit (without initial commit). The name for the project was SpringBootBasic.

  2. Cloned the remote git repo in some other location

    git clone https://github.com/hemantvsn/boot.git 
    
  3. Since gerrit needs Change-Id for each commit, copied the commit message hook into my cloned repository

    hemant:-~/Projects/boot$ scp -p -P 29418        
    [email protected]:hooks/commit-msg .git/hooks/commit-msg                                                                                  
                100% 4693     3.4MB/s   00:00    
    hemant:-~/Projects/hem$ 
    
  4. Added the a new remote to point to gerrit project

    hemant:-~/Projects/boot$ git remote add gerrit 
    http://127.0.0.1:9090/SpringBootBasic
    
  5. Made a minor change and committed it. Change-Id was populated in this commit.

    hemant:-~/Projects/boot$ git log
    --------------------------------
    commit 98f1c6534492984364bdbc714407dbb8b39c06da
    Author: hemant <[email protected]>
    Date:   Wed Apr 12 14:43:42 2017 +0530
    
    Minor text changes.
    
    Change-Id: I48e625c728add8be45b4dee0809c1d0d9804b7c8
    
    --------------------------------
    
    commit 5d485988e6d67394622bbd5d2d3146fc379b7ec3
    Author: hemant <[email protected]>
    Date:   Wed Apr 5 13:22:09 2017 +0530
    
    Added sysouts
    --------------------------------
    
    commit 330c5c6ca2fed898146efe81f99b4ee91faa614f
    Author: hemant <[email protected]>
    Date:   Wed Apr 5 13:03:40 2017 +0530
    
    changed index file
    --------------------------------
    
  6. Finally when Im tring to push my changes to the gerrit report, its still showing error as change-Id not populated in commit.

     hemant:-~/Projects/boot$ git push gerrit HEAD:refs/for/master
     Counting objects: 43, done.
     Delta compression using up to 4 threads.
     Compressing objects: 100% (29/29), done.
     Writing objects: 100% (43/43), 4.29 KiB | 0 bytes/s, done.
     Total 43 (delta 6), reused 0 (delta 0)
     remote: Resolving deltas: 100% (6/6)
     remote: Processing changes: refs: 1, done    
     remote: ERROR: [f905e04] 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 29418 
     [email protected]:hooks/commit-msg ${gitdir}/hooks/
     remote: And then amend the commit:
     remote:   git commit --amend
     remote: 
     To http://127.0.0.1:9090/SpringBootBasic
     ! [remote rejected] HEAD -> refs/for/master ([f905e04] missing 
     Change-Id in commit message footer)
     error: failed to push some refs to 
     'http://127.0.0.1:9090/SpringBootBasic'
    
    
     hemant:-~/Projects/boot$
    

It seems that its referring to my initial commits in repo, which were done before gerrit.

 hemant:-~/Projects/boot$ git log --pretty=format:'%h %ad %s (%an)' --date=short 
98f1c65 2017-04-12 Minor text changes. (hemantvsn)
5d48598 2017-04-05 Added sysouts (hemant)
330c5c6 2017-04-05 changed index file (hemant)
90bb7be 2017-04-05 sonar file (hemant)
eca2fc2 2017-03-30 test (hemant)
f905e04 2017-02-03 Basic Spring Boot Project. (hemantvsn) **** This commit is referred in error report.

Please suggest what needs to be done Also Please suggest any changes in config.

Upvotes: 1

Views: 298

Answers (1)

You need to have the Change-Id in ALL commits of your repository, you just added it in the last one.

The correct way to push a new repository to Gerrit is to push straight to the branch (git push gerrit HEAD:refs/heads/master) but you need to have permission to do that. Ask for your Gerrit administrator.

Upvotes: 1

Related Questions