diff options
author | Clark Boylan <clark.boylan@gmail.com> | 2014-12-17 14:21:35 -0800 |
---|---|---|
committer | Jeremy Stanley <fungi@yuggoth.org> | 2014-12-21 22:21:32 +0000 |
commit | 50a43a18d14f4c2acebbd3fb221400224eb56781 (patch) | |
tree | eba30072d718c483b15328cd5a695a193ac36f65 | |
parent | c01b8dae1e5ad91d30756140d9b591818444db2d (diff) | |
download | pbr-50a43a18d14f4c2acebbd3fb221400224eb56781.tar.gz |
Properly check for git before getting git dir
We cannot get the git dir if git is not installed. Check that git is
installed before querying for the git dir. Return None if the git dir
cannot be found or if git is not installed.
Change-Id: Ic8e0c74a779b23842369a8cf01fcbf37885202ef
Fixes-bug: 1326682
(cherry picked from commit e7d2825d39fce2111d0d413e63e553603a0e56fb)
-rw-r--r-- | pbr/git.py | 12 | ||||
-rw-r--r-- | pbr/packaging.py | 4 |
2 files changed, 8 insertions, 8 deletions
@@ -91,8 +91,8 @@ def _find_git_files(dirname='', git_dir=None): at absurd times. We only want to do this when we are building an sdist. """ file_list = [] - if git_dir is None and _git_is_installed(): - git_dir = _get_git_directory() + if git_dir is None: + git_dir = _run_git_functions() if git_dir: log.info("[pbr] In git context, generating filelist from git") file_list = _run_git_command(['ls-files', '-z'], git_dir) @@ -114,10 +114,10 @@ def get_is_release(git_dir): def _run_git_functions(): - git_dir = _get_git_directory() - if git_dir and _git_is_installed(): - return git_dir - return None + git_dir = None + if _git_is_installed(): + git_dir = _get_git_directory() + return git_dir or None def get_git_short_sha(git_dir=None): diff --git a/pbr/packaging.py b/pbr/packaging.py index 0783f2a..8d41104 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -586,8 +586,8 @@ def _get_version_from_git(pre_version=None): :param pre_version: If supplied use this as the target version rather than inferring one from the last tag + commit messages. """ - git_dir = git._get_git_directory() - if git_dir and git._git_is_installed(): + git_dir = git._run_git_functions() + if git_dir: try: tagged = git._run_git_command( ['describe', '--exact-match'], git_dir, |