Skip to content

Commit

Permalink
Merge pull request #101 from GEOS-ESM/feature/mathomp4/add-if-exists-…
Browse files Browse the repository at this point in the history
…dry-run

Adds a dry-run option for checkout-if-exists
  • Loading branch information
tclune committed Sep 1, 2020
2 parents 3369caf + 6f106de commit 1fcca03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions mepo.d/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __checkout_if_exists(self):
description = 'Switch to branch <branch-name> in any component where it is present. ')
checkout_if_exists.add_argument('branch_name', metavar = 'branch-name')
checkout_if_exists.add_argument('--quiet', action = 'store_true', help = 'Suppress found messages')
checkout_if_exists.add_argument('--dry-run','-n', action = 'store_true', help = 'Dry-run only (lists repos where branch exists)')

def __fetch(self):
fetch = self.subparsers.add_parser(
Expand Down
13 changes: 9 additions & 4 deletions mepo.d/command/checkout-if-exists/checkout-if-exists.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ def run(args):
status = git.verify_branch(branch)

if status == 0:
if not args.quiet:
print("Checking out branch %s in %s" %
(colors.YELLOW + branch + colors.RESET,
if args.dry_run:
print("Branch %s exists in %s" %
(colors.YELLOW + branch + colors.RESET,
colors.RESET + comp.name + colors.RESET))
git.checkout(branch)
else:
if not args.quiet:
print("Checking out branch %s in %s" %
(colors.YELLOW + branch + colors.RESET,
colors.RESET + comp.name + colors.RESET))
git.checkout(branch)

0 comments on commit 1fcca03

Please sign in to comment.