Search code examples
gitgerrit

How to fetch all changes with given topic from 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.


Solution

  • 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.