diff options
| author | Aravind Vasudevan <aravindvasudev@google.com> | 2023-03-24 04:16:35 +0000 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-24 07:39:28 +0000 |
| commit | e74d9046eeec52d7ccd433a4dad2cee30838c620 (patch) | |
| tree | 58f47cfc65ffab5641e8d3f275919c33bde3ddc8 | |
| parent | 21cc3a9d53d3ab1f3de5b900ad7bb4969326994d (diff) | |
| download | git-repo-e74d9046eeec52d7ccd433a4dad2cee30838c620.tar.gz | |
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>
| -rw-r--r-- | subcmds/abandon.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/subcmds/abandon.py b/subcmds/abandon.py index 1f687f53..4036f306 100644 --- a/subcmds/abandon.py +++ b/subcmds/abandon.py | |||
| @@ -48,9 +48,15 @@ It is equivalent to "git branch -D <branchname>". | |||
| 48 | self.Usage() | 48 | self.Usage() |
| 49 | 49 | ||
| 50 | if not opt.all: | 50 | if not opt.all: |
| 51 | nb = args[0] | 51 | branches = args[0].split() |
| 52 | if not git.check_ref_format("heads/%s" % nb): | 52 | invalid_branches = [ |
| 53 | self.OptionParser.error("'%s' is not a valid branch name" % nb) | 53 | x for x in branches if not git.check_ref_format(f"heads/{x}") |
| 54 | ] | ||
| 55 | |||
| 56 | if invalid_branches: | ||
| 57 | self.OptionParser.error( | ||
| 58 | f"{invalid_branches} are not valid branch names" | ||
| 59 | ) | ||
| 54 | else: | 60 | else: |
| 55 | args.insert(0, "'All local branches'") | 61 | args.insert(0, "'All local branches'") |
| 56 | 62 | ||
| @@ -59,7 +65,7 @@ It is equivalent to "git branch -D <branchname>". | |||
| 59 | if all_branches: | 65 | if all_branches: |
| 60 | branches = project.GetBranches() | 66 | branches = project.GetBranches() |
| 61 | else: | 67 | else: |
| 62 | branches = [nb] | 68 | branches = nb |
| 63 | 69 | ||
| 64 | ret = {} | 70 | ret = {} |
| 65 | for name in branches: | 71 | for name in branches: |
| @@ -69,7 +75,7 @@ It is equivalent to "git branch -D <branchname>". | |||
| 69 | return (ret, project) | 75 | return (ret, project) |
| 70 | 76 | ||
| 71 | def Execute(self, opt, args): | 77 | def Execute(self, opt, args): |
| 72 | nb = args[0] | 78 | nb = args[0].split() |
| 73 | err = defaultdict(list) | 79 | err = defaultdict(list) |
| 74 | success = defaultdict(list) | 80 | success = defaultdict(list) |
| 75 | all_projects = self.GetProjects( | 81 | all_projects = self.GetProjects( |
