mirror of
https://github.com/ejwa/gitinspector.git
synced 2025-03-19 14:58:12 +01:00
Gracefully handle non-git-repo path (Fixes issue 44).
Error out gracefully when gitinspector is called with a path that does not point to a git repository, instead of printing a stack trace. Signed-off-by: Christian Kastner <debian@kvr.at> Signed-off-by: Adam Waldenberg <adam.waldenberg@ejwa.se>
This commit is contained in:
parent
68a6e90228
commit
e3b4857eb6
1 changed files with 6 additions and 3 deletions
|
@ -33,9 +33,12 @@ def get_basedir_git():
|
|||
global __git_basedir__
|
||||
|
||||
if not __git_basedir__:
|
||||
isbare = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
|
||||
stdout=subprocess.PIPE).stdout
|
||||
isbare = isbare.readlines()
|
||||
sp = subprocess.Popen("git rev-parse --is-bare-repository", shell=True, bufsize=1,
|
||||
stdout=subprocess.PIPE, stderr=open(os.devnull, "w"))
|
||||
isbare = sp.stdout.readlines()
|
||||
sp.wait()
|
||||
if sp.returncode != 0:
|
||||
sys.exit("Error processing git repository at \"%s\"" % os.getcwd())
|
||||
isbare = (isbare[0].decode("utf-8", "replace").strip() == "true")
|
||||
absolute_path = ""
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue