summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-08-10 16:22:26 +1200
committerRobert Collins <rbtcollins@hp.com>2015-08-10 16:24:14 +1200
commit5c0bb9186fe2d65901744b00af24c8c50b3e1d29 (patch)
treeca62c38f117ec6caccee39e37748884601f5b9d8
parent925010e69f3e539a1d8403528f57d74ffaacedcb (diff)
downloadpbr-5c0bb9186fe2d65901744b00af24c8c50b3e1d29.tar.gz
Handle git being entirely absent1.5.0
When we try to find the git directory, if git is not present, treat that the same as an error from git itself. Sadly tests for this are nearly impossible to meaningfully write, since we always have git installed. I can do a mock based test if folk want one. Change-Id: If6160d1fb3def8133bdd0b66105e60ef93f80f82 Closes-Bug: #1481468
-rw-r--r--pbr/git.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pbr/git.py b/pbr/git.py
index b4ae300..60acd3c 100644
--- a/pbr/git.py
+++ b/pbr/git.py
@@ -18,6 +18,7 @@ from __future__ import unicode_literals
import distutils.errors
from distutils import log
+import errno
import io
import os
import re
@@ -64,7 +65,13 @@ def _run_git_command(cmd, git_dir, **kwargs):
def _get_git_directory():
- return _run_shell_command(['git', 'rev-parse', '--git-dir'])
+ try:
+ return _run_shell_command(['git', 'rev-parse', '--git-dir'])
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ # git not installed.
+ return ''
+ raise
def _git_is_installed():