Reputation:
let's assume that everything I know is gerrit link. Is it possible to checkout on such commit? so I've got https://gerrit.com/#/c/4840847/ The patchset is not specified so I want to checkout on the latest one.
Upvotes: 0
Views: 298
Reputation: 30858
By the legacy number 4840847
, you can get the ref of the current patchset with Gerrit's ssh command gerrit query
.
ssh -p 29418 <username>@<host> gerrit query change:4840847 --current-patch-set | awk '/^ ref:/{print $NF}'
If successful, it returns the ref of the latest patchset, refs/changes/47/4840847/5
for example. --format=json
can be used to return data in json. gerrit query
returns more than the ref. The project name is available too, with which you can compose the commands to fetch and checkout the revision.
git fetch ssh://<username>@<host>:29418/<projectname> refs/changes/47/4840847/5 && git checkout FETCH_HEAD
Upvotes: 1