Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to show refs of open Gerrit Patch Sets #49

Open
R-Zwi opened this issue Jan 27, 2022 · 1 comment
Open

Possibility to show refs of open Gerrit Patch Sets #49

R-Zwi opened this issue Jan 27, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@R-Zwi
Copy link

R-Zwi commented Jan 27, 2022

Feature description

Button to get all open Gerrit patch sets and show them as references.
An automatic fetch should be done before getting the patch sets to show the latest state of the branches.
It should be done recursively in case of submodules.

Could look like this:
image
... you can see all 3 patch sets of the open change

Use case

Sometimes it is useful to see all open Gerrit patch sets in the local repo.
So you can do local diffs between two selected patch sets with your favorite diff tool.
Getting all of them at once is useful in case other people did some work in this repo (or it's subrepos).

@R-Zwi R-Zwi added the enhancement New feature or request label Jan 27, 2022
@R-Zwi
Copy link
Author

R-Zwi commented Feb 1, 2022

As a proof of concept I wrote a litte bash script for this (single repo only, but should be possible to do it for submodules also).
It does several steps:

  1. cleanup (remove refs as they might be outdated):
    git show-ref --abbrev | grep changes | sed s%.*refs%refs% | xargs -P 5 -r -n 1 git update-ref -d
  2. get refs of open changes from Gerrit (one could easily add additional query filters like a topic):
    ssh -p 29418 $USERNAME@$SERVERNAME gerrit query --current-patch-set project:$GITPRJ_NAME AND is:open | grep ref: | sed -E 's%\ \ \ \ ref:\ (refs/changes/.*/).*%\1*%' | xargs -P 5 -r -n 1 sub_getchange.sh
    where sub_getchange.sh does git fetch -q --recurse-submodules=no origin $1:$1
  3. remove Gerrit's meta-refs as they are internal only (of course it would be better to not fetch them in the previous step but I couldn't get this done):
    git show-ref --abbrev | grep meta | sed s%.*refs%refs% | xargs -P 5 -r -n 1 git update-ref -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant