Update abandon to support multiple branches

This change updates `repo abandon` command to take multiple space-separated branchnames as parameters.

Bug: https://crbug.com/gerrit/13354
Change-Id: I00ad7a79872c0e4161f8183843835f25cd515605
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/365524
Tested-by: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
Aravind Vasudevan 2023-03-24 04:16:35 +00:00 committed by LUCI
parent 21cc3a9d53
commit e74d9046ee

View File

@ -48,9 +48,15 @@ It is equivalent to "git branch -D <branchname>".
self.Usage() self.Usage()
if not opt.all: if not opt.all:
nb = args[0] branches = args[0].split()
if not git.check_ref_format("heads/%s" % nb): invalid_branches = [
self.OptionParser.error("'%s' is not a valid branch name" % nb) x for x in branches if not git.check_ref_format(f"heads/{x}")
]
if invalid_branches:
self.OptionParser.error(
f"{invalid_branches} are not valid branch names"
)
else: else:
args.insert(0, "'All local branches'") args.insert(0, "'All local branches'")
@ -59,7 +65,7 @@ It is equivalent to "git branch -D <branchname>".
if all_branches: if all_branches:
branches = project.GetBranches() branches = project.GetBranches()
else: else:
branches = [nb] branches = nb
ret = {} ret = {}
for name in branches: for name in branches:
@ -69,7 +75,7 @@ It is equivalent to "git branch -D <branchname>".
return (ret, project) return (ret, project)
def Execute(self, opt, args): def Execute(self, opt, args):
nb = args[0] nb = args[0].split()
err = defaultdict(list) err = defaultdict(list)
success = defaultdict(list) success = defaultdict(list)
all_projects = self.GetProjects( all_projects = self.GetProjects(