diff --git a/mepo.d/cmdline/parser.py b/mepo.d/cmdline/parser.py index cf36af6..6018f0b 100644 --- a/mepo.d/cmdline/parser.py +++ b/mepo.d/cmdline/parser.py @@ -126,6 +126,7 @@ def __checkout_if_exists(self): description = 'Switch to branch 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( diff --git a/mepo.d/command/checkout-if-exists/checkout-if-exists.py b/mepo.d/command/checkout-if-exists/checkout-if-exists.py index af80872..02b3cb5 100644 --- a/mepo.d/command/checkout-if-exists/checkout-if-exists.py +++ b/mepo.d/command/checkout-if-exists/checkout-if-exists.py @@ -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)