From 9810572411d38bd03d559de0b0e540282d35a1e9 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 19 Feb 2021 00:48:35 -0800 Subject: [PATCH] run git from proper directory --- lib/spack/spack/cmd/checkout.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/spack/spack/cmd/checkout.py b/lib/spack/spack/cmd/checkout.py index c4c3a5037b0..244621fcf45 100644 --- a/lib/spack/spack/cmd/checkout.py +++ b/lib/spack/spack/cmd/checkout.py @@ -55,10 +55,6 @@ def known_commit_or_tag(ref): def checkout(parser, args): - deployment_required_args = {'remote': 'origin'} - deployment.setup_deployment_args('checkout', args, - deployment_required_args) - remote = args.remote or 'origin' url = args.url ref = args.ref @@ -66,12 +62,13 @@ def checkout(parser, args): global git # make git available to called methods git = which('git', required=True) - # Always fetch branches - branches = map(lambda b: b.strip('* '), - git('branch', output=str, error=str).split('\n')) - if ref in branches or not known_commit_or_tag(ref): - fetch_remote(remote, url) + with working_dir(spack.paths.prefix): + # Always fetch branches + branches = map(lambda b: b.strip('* '), + git('branch', output=str, error=str).split('\n')) + if ref in branches or not known_commit_or_tag(ref): + fetch_remote(remote, url) - # For branches, ensure we're getting the version from the correct remote - full_ref = '%s/%s' % (remote, ref) if ref in branches else ref - git('checkout', full_ref) + # For branches, ensure we're getting the version from the correct remote + full_ref = '%s/%s' % (remote, ref) if ref in branches else ref + git('checkout', full_ref)