user5634387
user5634387

Reputation:

Checkout on gerrit patchset with LINK

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

Answers (1)

ElpieKay
ElpieKay

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

Related Questions