bin: add rebase mode
when we need to apply trailers to a whole MR at once, it's convenient to do something like `git rebase --exec "rb faith" origin/main`. This adds that operation into the script itself, so that can be done with simply `rb -r origin/main faith`. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34409>
This commit is contained in:
parent
19e4dda9a2
commit
3e82395306
1 changed files with 23 additions and 0 deletions
23
bin/rb.py
23
bin/rb.py
|
|
@ -9,6 +9,7 @@ import unittest
|
|||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import shlex
|
||||
from unidecode import unidecode
|
||||
|
||||
def normalize(x):
|
||||
|
|
@ -77,8 +78,30 @@ if __name__ == "__main__":
|
|||
parser.add_argument('-a', '--ack', action='store_true', help="Apply an acked-by tag")
|
||||
parser.add_argument('-d', '--dry-run', action='store_true',
|
||||
help="Print trailer without applying")
|
||||
parser.add_argument('-r', '--rebase', nargs='?',
|
||||
help="Rebase on the specified branch applying tags to all commits")
|
||||
args = parser.parse_args()
|
||||
|
||||
# If we are rebasing, let git reinvoke this script with the rebase related
|
||||
# arguments stripped.
|
||||
if args.rebase is not None:
|
||||
relevant_args = [sys.argv[0]]
|
||||
if args.ack:
|
||||
relevant_args.append("--ack")
|
||||
|
||||
relevant_args += args.person
|
||||
|
||||
cmd = f"python3 {' '.join(relevant_args)}"
|
||||
rebase = ['git', 'rebase', '--exec', cmd, args.rebase]
|
||||
|
||||
if args.dry_run:
|
||||
print(' '.join([shlex.quote(s) for s in rebase]))
|
||||
returncode = 0
|
||||
else:
|
||||
returncode = subprocess.run(rebase).returncode
|
||||
|
||||
sys.exit(returncode)
|
||||
|
||||
for p in args.person:
|
||||
person = find_person(p)
|
||||
if person is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue