Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch all changes with given topic from gerrit

Tags:

git

gerrit

We want to use topics for changes that are under development but we need to fetch them because we build from a server. We know we can fetch a commit, and a change, but we want to fetch with the topic name for simplicity reasons.

We haven't found a way. Does somebody know how we could do this?

We have discarded the use of branches for testing developments because it brings trash to the master repository and we would have to delete them after and replicate all those deletes worldwide.

like image 306
Olaia Avatar asked Dec 25 '22 10:12

Olaia


2 Answers

You should use a gerrit query to find all open changes by a known topic:

ssh -p 29418 review.example.com gerrit query --format=JSON topic:MY-TOPIC status:open project:xxx

Then you can iterate over each item in the returned JSON, fetch the changes and build them with your CI.

like image 52
fracz Avatar answered Feb 02 '23 04:02

fracz


Old question but maybe improving bit. For CI purpose you also need refs to know patchset you need. so adding --current-patch-set will give that information.

You can leave also project away as it will give project information anyway. Great for multirepo projects.

ssh -p 29418 review.example.com gerrit query --format=JSON --current-patch-set topic:<TOPIC> status:open

Then just parse json for your needed commits.

like image 25
Juge Avatar answered Feb 02 '23 03:02

Juge