Skip to content

Commit

Permalink
Merge pull request #134 from GEOS-ESM/hotfix/mathomp4/clone-config-bug
Browse files Browse the repository at this point in the history
Fix for clone-config bug
  • Loading branch information
mathomp4 authored Nov 20, 2020
2 parents 979fde2 + c51423f commit 13651a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mepo.d/cmdline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def __clone(self):
'--config',
metavar = 'config-file',
nargs = '?',
default = 'components.yaml',
help = 'Configuration file (ignored if init already called, default: %(default)s)')
default = None,
help = 'Configuration file (ignored if init already called)')

def __list(self):
listcomps = self.subparsers.add_parser(
Expand Down
15 changes: 12 additions & 3 deletions mepo.d/command/clone/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ def run(args):

# If you pass in a config, with clone, it could be outside the repo.
# So use the full path
passed_in_config = False
if args.config:
passed_in_config = True
args.config = os.path.abspath(args.config)
else:
# If we don't pass in a config, we need to "reset" the arg to the
# default name because we pass args to mepo_init
args.config = 'components.yaml'

if args.repo_url:
p = urlparse(args.repo_url)
Expand All @@ -35,9 +41,12 @@ def run(args):
local_clone(args.repo_url,args.branch)
os.chdir(git_url_directory)

# Copy the new file into the repo
if args.config:
shutil.copy(args.config,os.getcwd())
# Copy the new file into the repo only if we pass it in
if passed_in_config:
try:
shutil.copy(args.config,os.getcwd())
except shutil.SameFileError as e:
pass

# This tries to read the state and if not, calls init,
# loops back, and reads the state
Expand Down

0 comments on commit 13651a2

Please sign in to comment.