From fb98f9ee19a1ddcbde3a1447f8f847e5c1c62286 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Sat, 1 Apr 2017 12:29:06 +0200 Subject: 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) --- lib/spack/spack/cmd/pkg.py | 7 +++++-- lib/spack/spack/hooks/case_consistency.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') 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: -- cgit v1.2.3-70-g09d2