diff options
author | Kenneth Hoste <kenneth.hoste@ugent.be> | 2017-04-01 12:29:06 +0200 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2017-04-01 03:29:06 -0700 |
commit | fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286 (patch) | |
tree | a35493b38fb69fbf0bebb60baba6ced970b829b3 /lib | |
parent | f982cd78ae79f77c2ca59440de20de37002d6658 (diff) | |
download | spack-fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286.tar.gz spack-fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286.tar.bz2 spack-fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286.tar.xz spack-fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286.zip |
fix annoying 'fatal: Not a git repository' error message (#3657)
fix annoying 'fatal: Not a git repository' error message produced by 'spack list' when Spack is not run from a Git repository (#3657)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/pkg.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/hooks/case_consistency.py | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py index 7b668586b5..12dcb81792 100644 --- a/lib/spack/spack/cmd/pkg.py +++ b/lib/spack/spack/cmd/pkg.py @@ -73,13 +73,16 @@ def setup_parser(subparser): help="revision to compare to rev1 (default is HEAD)") -def get_git(): +def get_git(fatal=True): # cd to spack prefix to do git operations os.chdir(spack.prefix) # If this is a non-git version of spack, give up. if not os.path.isdir('.git'): - tty.die("No git repo in %s. Can't use 'spack pkg'" % spack.prefix) + if fatal: + tty.die("No git repo in %s. Can't use 'spack pkg'" % spack.prefix) + else: + return None return which("git", required=True) diff --git a/lib/spack/spack/hooks/case_consistency.py b/lib/spack/spack/hooks/case_consistency.py index e9208ee9ff..2b88291666 100644 --- a/lib/spack/spack/hooks/case_consistency.py +++ b/lib/spack/spack/hooks/case_consistency.py @@ -31,6 +31,7 @@ import platform from llnl.util.filesystem import * import spack +from spack.cmd.pkg import get_git from spack.util.executable import * @@ -61,8 +62,8 @@ def git_case_consistency_check(path): """ with working_dir(path): # Don't bother fixing case if Spack isn't in a git repository - git = which('git') - if not git: + git = get_git(fatal=False) + if git is None: return try: |