Gerrit에서 주어진 패치 세트를 git-pull하는 방법은 무엇입니까?
Gerrit (Code Review)와 함께 작업 할 때 테스트 또는 유효성 검사를 위해 주어진 패치 세트의 사본이 필요한 경우가 많습니다. 분명하고 쉬운 방법은 Gerrit 웹 인터페이스를 통해 아카이브 또는 패치 파일을 다운로드하고 수동으로 내 로컬 소스에 적용하는 것입니다.
위의 단계는 매우 간단하고 내 요구를 충족하지만 최고의 세계에서는 패치 세트가 로컬 Git에 커밋으로 나타나기를 원합니다.
나는 주위를 둘러 보았지만 해결책을 찾지 못했습니다. 한 번 함께 컴파일되어 다음과 같은 해결책을 제공하는 희소 정보를 찾았습니다.
Gerrit 변경 1222의 패치 세트 2를 가져 오려고한다고 가정하십시오.
관심있는 원격 참조를 찾으십시오.
$ git ls-remote | grep 1220
From http://something.com:8081/MyProject
e2e0212a59240ac5cd7c11220c35542523f44b59 refs/changes/13/713/1
b8c4dceea5eaf1bad711b0ea6938c80ec932726a refs/changes/20/1220/1
6f20c182ec7f54a2aa9e8f6188a0eef1b0790df4 refs/changes/20/1220/2
ed94a98386d224ce3d86004ce99f61220905a077 refs/changes/22/1222/1
심판을 가져옵니다.
git pull origin refs/changes/20/1220/2
이렇게하면 결국 리베이스 할 수있는 Git 커밋 포인트가 생성됩니다.
git rebase
이 기능은 Gerrit UI의 표준입니다.
패치의 UI 오른쪽 상단에서 다운로드를 클릭하면 다음과 같은 내용이 표시됩니다.
패치를 탐색 할 때 다운로드 섹션으로 이동하여 패치 세트를 확인하기위한 명령 줄 명령을 복사합니다. 예를 들면 다음과 같습니다.
git fetch https://gerrit.googlesource.com/gerrit refs/changes/03/64403/2 && git checkout FETCH_HEAD
그런 다음 일반적으로 리뷰 번호와 패치 세트를 이름으로 사용하여 브랜치를 만듭니다.
git checkout -b b64403-2
여기에서는 정상적으로 작업하고 변경 사항을 커밋하거나이 변경 사항에 대한 변경 사항을 체리 픽 / 리베이스 할 수 있습니다.
r64403에 대한 검토가 완료되면 코드를 병합하거나 다른 패치 세트가 제출되면 동일한 작업을 다시 수행해야합니다.
옵션을 다운로드 할 수있는 옵션이 표시되지 Checkout
않거나 다음과 Cherry Pick
같이을 편집해야하는 gerrit.config
경우 :
[download]
scheme = ssh
command = checkout
command = cherry_pick
자세한 내용은 Gerrit 문서 에서 찾을 수 있습니다.
업데이트 : barryku가 올바르게 지적했듯이 이후 버전에서는 downloads-commands 플러그인을 다운로드해야합니다. 초기 설정 중에 또는 다음 명령을 사용하여 수행 할 수 있습니다.
java -jar gerrit-2.11.4.war init -d review_site --batch --install-plugin download-commands
또는 -d
옵션을 사용하여 git-review
. 예를 들어 nova-docker 저장소 로 작업 중이고 gerrit의이 변경에 관심이 있다고 가정합니다 .
다음과 같이 최신 패치 세트를 다운로드 할 수 있습니다.
git review -d 148486
또는 변경 ID를 사용할 수 있습니다.
git review -d I35729a86e211391f67cc959d19416c9125c6f9eb
쉼표와 패치 번호를 추가하여 패치의 특정 개정을 요청할 수도 있습니다. 예를 들어, 해당 패치의 두 번째 개정판을 얻으려면 :
git review -d 148486,2
귀하의 질문이 무엇인지 100 % 확신하지 못합니다. 워크 플로우 나 타이핑을 쉽게하고 싶은 것 같습니다. 이미 언급 된 유충 git review
은 주로 사용됩니다.
For your case, maybe it helps to download all ref's automatically so you can reference them directly. You can always all specified ref's like with
git fetch origin "+refs/changes/*:refs/remotes/origin/changes/*"
Then you can work locally with the commit id.
A simple git alias or scripting it for all refs can be easily done. An example of such a while loop can be found in the script on https://github.com/saper/gerrit-fetch-all With such a small shell snippet you can easily accomplish to skip one part of the ref id to easier reference them:
Server side: Client side:
refs/changes/13/713/1 refs/head/713/1
refs/changes/20/1220/1 refs/head/1220/1
refs/changes/20/1220/2 refs/head/1220/2
refs/changes/22/1222/1 refs/head/1222/1
As mentioned in the comments, you can just get the right git command from the gerrit GUI. If you really dislike GUIs, or you want to automate it (and for some reason can't use git-review
), you can use the gerrit API:
curl -s 'https://<your gerrit server>/r/changes/<change id>?o=CURRENT_REVISION&o=DOWNLOAD_COMMANDS' | tail -n+2 | jq -r '.revisions[.current_revision].fetch["anonymous http"].commands.Pull' | bash -
or
git pull origin `curl -s 'https://<your gerrit server>/r/changes/<change id>?o=CURRENT_REVISION' | tail -n+2 | jq -r '.revisions[.current_revision].ref'`
참고 URL : https://stackoverflow.com/questions/28370567/how-to-git-pull-a-given-patch-set-from-gerrit
'IT TIP' 카테고리의 다른 글
대안 (0) | 2020.12.07 |
---|---|
RecyclerView에서 항목 제거시 애니메이션이 없습니다. (0) | 2020.12.07 |
v2.4에서 / [post-id]가 더 이상 사용되지 않으므로 개별 게시물을 검색하려면 어떻게해야합니까? (0) | 2020.12.07 |
Angular 2 빠른 시작 : 예기치 않은 토큰 < (0) | 2020.12.07 |
ExecutorService의 활성 스레드 (0) | 2020.12.07 |