Dirk Mueller
b3e679149a
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pbr?expand=0&rev=39
47 lines
1.3 KiB
Diff
47 lines
1.3 KiB
Diff
From 5c0bb9186fe2d65901744b00af24c8c50b3e1d29 Mon Sep 17 00:00:00 2001
|
|
From: Robert Collins <rbtcollins@hp.com>
|
|
Date: Mon, 10 Aug 2015 16:22:26 +1200
|
|
Subject: [PATCH] Handle git being entirely absent
|
|
|
|
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
|
|
---
|
|
pbr/git.py | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
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():
|
|
--
|
|
2.4.6
|
|
|