2017-07-06 127 views
1
git log --oneline 

上面的命令給了我,隨後的結果:有沒有什麼辦法可以用git log來顯示遠程引用?

5485b34 Modify: something 
ccaf2c4 Modify: another thing 
85a87e8 Bug Fix: the other thing 

但因爲我使用的是格里特通常格里特有它的變化號碼作爲裁判/修改/ ...格式,我想收集名單成幀如下:

refs/changes/85/104085/9 Modify: something 
refs/changes/33/104033/9 Modify: another thing 
refs/changes/83/104183/2 Bug Fix: the other thing 

我知道有一種方法,通過使用「GIT中LS-遠程」,取得提交ID和遠程引用之間的映射。通過使用「git ls-remote」,我可以創建一個腳本來獲得上述結果。但是有沒有更好更簡單的方法來獲得上述結果?

回答

0

您可以使用--decorate選項在日誌中顯示引用。
但它只會顯示本地和牽強引用,這樣的refs/changes/x/yyyy/zz不會被顯示出來,你必須首先獲取它們:

git config --add remote.origin.fetch refs/changes/*:refs/remotes/gerrit/changes/* 

然後你會得到這樣的輸出:

# You can add '--all' to see other references not in the current history 
$ git log --oneline --decorate 
5485b34 (HEAD -> master, origin/master, origin/HEAD, gerrit/changes/85/104085/9) Modify: something 
ccaf2c4 (gerrit/changes/33/104033/9) Modify: another thing 
85a87e8 (gerrit/changes/83/104183/2) Bug Fix: the other thing 
+0

非常感謝。這是我真正想要的。 –

0

我認爲這是不可能得到的信息,你想要的方式,但你可以得到很多的格里特審覈信息執行以下操作:

1)配置你的資料庫,以獲得審覈信息

$ git config --add remote.origin.fetch refs/notes/review:refs/notes/review 

2)在此之後,每一次更新將帶來的審查信息也

$ git fetch 

remote: Counting objects: 66, done 
remote: Finding sources: 100% (66/66) 
remote: Total 66 (delta 18), reused 66 (delta 18) 
Unpacking objects: 100% (66/66), done. 
From https://GERRIT-SERVER/REPO-FULLNAME 
* [new ref] refs/notes/review -> refs/notes/review 

3)要查看審覈信息,添加「--notes =審覈」你的「混帳日誌」命令

$ git log --notes=review 

commit a5bc87cb44e5e68154fb8bd3559f9753e1540fd7 
Author: AUTHOR 
Date: Thu May 8 16:02:16 2017 -0300 
COMMIT-MESSAGE 
Change-Id: CHANGE-ID 
Notes (review): 
Verification+1: REVIEWER1 
Code-Review+1: REVIEWER2 
Code-Review+1: REVIEWER3 
Code-Review+2: REVIEWER4 
Submitted-by: SUBMITTER 
Submitted-at: Fri, 09 May 2017 08:23:28 -0300 
Reviewed-on: https://GERRIT-SERVER/CHANGE-NUMBER 
Project: REPO-FULLNAME 
Branch: refs/heads/BRANCH 
相關問題