Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch latest patch set from git using gerrit link

Tags:

git

gerrit

I have gerrit link of an unmerged change, would like to fetch the latest Patch set from that change, is it possible ?

for instance, below is my cherry pick command, I don't know the patch set, can I provide LATEST or something in place of <dontKnowPsNo.> ? or any other way?

git fetch ssh://<URL>:#####/path/to/project refs/changes/20/12345/<dontKnowPsNo.> && git cherry-pick FETCH_HEAD
like image 807
rodee Avatar asked Jul 08 '26 13:07

rodee


2 Answers

I'd love to find a nice way to do this. So far, best workaround I've found is to do a git ls-remote, grep for the change number, and then sort on the rightmost value after the slash:

From ssh://gerrit:29418/repo
892b11be21fe58b40a6193a8903eee69319aa46c    refs/changes/01/42/1
87e35bb74575ff922d55924520a8eb1440e410ba    refs/changes/01/42/2
673467f3ad08c6501808fd33d5b27d640bc6f04e    refs/changes/01/42/3
like image 180
bolind Avatar answered Jul 11 '26 03:07

bolind


curl -s 'https://<your gerrit server>/r/changes/<change id>?o=CURRENT_REVISION' | tail -n+2 | jq -r '.revisions[.current_revision].ref'

will return the correct reference. You'll probably have an easier time using git-review though, in which case you can just do git review -x 12345.

like image 43
Tgr Avatar answered Jul 11 '26 02:07

Tgr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!