问题
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:
Prepare environment
alias gerrit="ssh -p 29418 gerrit.yourdomain.com gerrit"
List all the commits with topic:
gerrit query topic:<topic>
Strip
Change-Id
'sAbandon 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