How to abandon a whole topic on Gerrit?

元气小坏坏 提交于 2019-12-11 03:07:20

问题


So the long and short of the issue is that, in a fit of fanatical adherence to code review principles and user attribution....

I pushed around 834 commits from an upstream branch to a project's gerrit server.

I was since then informed me that I ought to have (reasonably) first pushed a squashed commit for testing on gerrit and then pointed them to my repo for a merge...

Luckily I had tagged the commits with a topic while uploading them (for ease of testing.... -_-)

How can I now mass abandon the whole damn topic there? (to be replaced with a squashed commit)

There ought to maybe be some sort of terminal command? My gerrit-fu is weak and I haven't any privileged access to the server though..


回答1:


AFAIK, there is no ready method to achieve this. However, gerrit is awesome tool and you can solve this problem by writing a custom script.

Sorry, I'm too lazy to make you a ready to use solution, but here's what my script would do:

  1. Prepare environment

    alias gerrit="ssh -p 29418 gerrit.yourdomain.com gerrit"
    
  2. List all the commits with topic:

    gerrit query topic:<topic>
    
  3. Strip Change-Id's

  4. Abandon commits one by one:

    gerrit review <id> --abandon
    

Update

Thanks to Marcelo Avila de Oliveira, you have now the script you can use:

#!/bin/bash

alias gerrit="ssh -p 29418 gerrit.yourdomain.com gerrit"

for c in $(gerrit query topic:trololo | grep "сhange" | cut -d ' ' -f 2);
    do gerrit review $c --abandon;
done

Replace trololo with whatever you need, or adapt the script to take the argument.



来源:https://stackoverflow.com/questions/45595704/how-to-abandon-a-whole-topic-on-gerrit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!