Skip to content

Commit

Permalink
Merge pull request #179 from GEOS-ESM/develop
Browse files Browse the repository at this point in the history
Pull Develop into main for release
  • Loading branch information
mathomp4 committed Jun 10, 2021
2 parents b2d24f1 + a2de3b2 commit 1cebc4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions mepo.d/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ def __diff(self):
def __checkout(self):
checkout = self.subparsers.add_parser(
'checkout',
description = 'Switch to branch `branch-name` in component `comp-name`. '
'Specifying `-b` causes the branch `branch-name` to be created in '
'the specified component(s).',
description = "Switch to branch/tag `branch-name` in component `comp-name`. "
"If no components listed, checkout from all. "
"Specifying `-b` causes the branch `branch-name` to be created in "
"the specified component(s). NOTE: the -b option *requires* components to be specified.",
aliases=mepoconfig.get_command_alias('checkout'))
checkout.add_argument(
'branch_name',
Expand All @@ -154,7 +155,7 @@ def __checkout(self):
checkout.add_argument(
'comp_name',
metavar = 'comp-name',
nargs = '+',
nargs = '*',
help = 'Components to checkout branch in')
checkout.add_argument(
'-b',
Expand Down
13 changes: 11 additions & 2 deletions mepo.d/command/checkout/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

def run(args):
allcomps = MepoState.read_state()
verify.valid_components(args.comp_name, allcomps)
comps2checkout = [x for x in allcomps if x.name in args.comp_name]
comps2checkout = _get_comps_to_list(args.comp_name, allcomps)
if args.b and comps2checkout == allcomps:
raise Exception("We do not allow creating branches without specifying specific repos")
for comp in comps2checkout:
git = GitRepository(comp.remote, comp.local)
branch = args.branch_name
Expand All @@ -23,3 +24,11 @@ def run(args):
(colors.YELLOW + branch + colors.RESET,
colors.RESET + comp.name + colors.RESET))
git.checkout(branch)

def _get_comps_to_list(specified_comps, allcomps):
comps_to_list = allcomps
if specified_comps:
verify.valid_components(specified_comps, allcomps)
comps_to_list = [x for x in allcomps if x.name in specified_comps]
return comps_to_list

0 comments on commit 1cebc4f

Please sign in to comment.