Gerrit: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
No edit summary
Line 71: Line 71:
- git push origin HEAD:refs/for/<branch>
- git push origin HEAD:refs/for/<branch>
</pre>
</pre>
== Code review ==


== See also ==
== See also ==

Revision as of 08:12, 20 June 2016

Overview

git 연동 소스 리뷰 프로그램.

Basic

git 을 형상 관리 시스템이라고 한다면, gerrit 품질 관리 시스템이라고 할 수 있다. git 으로 소스를 업로드하고, gerrit 을 이용하여 소스 리뷰를 하여 소스의 품질을 향상시키는 방식이다.

$ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg

or

$ scp -p -P 29418 pchero@review.example.com:hooks/commit-msg .git/hooks/

Commit

$ git commit --amend

Change committed comment

Gerrit 을 이용하기 위해서는 각각의 커밋마다 Change-Id 를 입력해야 한다. PUSH 단위가 아닌 Commit 단위라는 것이 중요한데, 왜냐하면 이 Change-Id 는 push 를 할 때, gerrit 서버에서 임의로 생성해주는 것이기 때문이다. 그런데, 이미 많은 수의 commmit 들이 있는 상황에서 push를 하게 된다면 gerrit 에서는 어떻게 될까? 당연히 에러가 난다.

$ git push origin HEAD:refs/for/develop
...
 ! [remote rejected] HEAD -> refs/for/develop (missing Change-Id in commit message footer)

이럴 경우, 이미 commit 한 각각의 commit 메시지에 Chang-Id 를 입력하고 다시 PUSH 하는 수 밖에 없다.

$ git rebase -i HEAD~2
.. pick up the commit which is having no Change-Id
.. Add the Change-Id at the bottom
...

- Example

<source lang=bash> $ git rebase -i HEAD~2 [detached HEAD 9e9c71c] Added default config values

2 files changed, 22 insertions(+), 2 deletions(-)

Successfully rebased and updated refs/heads/sample_7361.

$ git push origin HEAD:refs/for/develop Counting objects: 22, done. Compressing objects: 100% (15/15), done. Writing objects: 100% (15/15), 2.63 KiB, done. Total 15 (delta 11), reused 0 (delta 0) remote: Resolving deltas: 100% (11/11) remote: Processing changes: new: 2, refs: 2, done remote: remote: New Changes: remote: http://gerrit.test.com:8080/1387 Added default config values remote: http://gerrit.test.com:8080/1388 Added message substitue remote: To ssh://pchero21@gerrit.test.com:29418/services/test

* [new branch]      HEAD -> refs/for/develop

</source>

Push

Gerrit 에서의 Push 일반적인 git push 와는 다르다. 보통은 다음의 문법대로 push 한다.

$ git push origin HEAD:refs/for/<branch>

Revert

Gerrit 에서는 이미 커밋된 소스 내용들에 대해 수정하기는 조금 까다롭다. 커밋된 내용으로 checkout 후에, 소스를 수정하고, 다시 Push 를 해야 한다.

- git checkout <committed ref>
- <Fix the code>
- git push origin HEAD:refs/for/<branch>

Code review

See also