2017-04-12 26 views
1

我正在嘗試爲我現有的GIT項目設置gerrit代碼審查。Gerrit報告在早期提交中未找到change-Id

gerrit實例運行在我的本地端口。

以下是我跟着

  1. 在格里特創建空項目的過程(不初始提交)。該項目的名稱是SpringBootBasic

  2. 克隆遠程git倉庫在其他位置

    git clone https://github.com/hemantvsn/boot.git 
    
  3. 由於格里特需要更改-ID對每個提交,複製提交消息鉤子到我的克隆庫

    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. 添加一個指向gerrit項目的新遙控器

    hemant:-~/Projects/boot$ git remote add gerrit 
    http://127.0.0.1:9090/SpringBootBasic 
    
  5. 做了小改動並付諸實踐。 Change-Id已在此提交中填充。

    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. 最後,當林特林我的變化推到格里特報告,它仍然 示值誤差爲改變-ID不填充提交。

    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$ 
    

看來,它指的是我在回購初始提交的,這是格里特之前完成。

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. 

請建議需要做 也請建議配置中的任何改變什麼。

+1

'f905e04'在你的'git log'中不可見。這個沙從哪裏來?它指向哪裏? –

+0

它是我在遠程git倉庫中的初始提交(f905e04 2017-02-03 Basic Spring Boot Project。(hemantvsn)) – hemantvsn

回答

1

您需要在存儲庫的所有提交中擁有Change-Id,您只需將其添加到最後一個。

推新存儲庫格里特正確的方法是直推到分支(混帳推格里特HEAD:裁判/ /主),但你需要有權限去做。請求您的Gerrit管理員。