summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-16 12:13:02 +0000
committerGerrit Code Review <review@openstack.org>2015-08-16 12:13:02 +0000
commit7253c18c729ca7285f13e24d017a96438ac11024 (patch)
treee89363226a1b12e8a2cdadf8e75fab6c211fb2ce
parent5c0bb9186fe2d65901744b00af24c8c50b3e1d29 (diff)
parentc3fc63c64f9db3b98d16fa77a8021b3f5d5b34a4 (diff)
downloadpbr-7253c18c729ca7285f13e24d017a96438ac11024.tar.gz
Merge "Fix retrieval of commit data and most recent tag."
-rw-r--r--pbr/git.py20
-rw-r--r--pbr/packaging.py2
-rw-r--r--pbr/tests/test_packaging.py12
3 files changed, 23 insertions, 11 deletions
diff --git a/pbr/git.py b/pbr/git.py
index 60acd3c..34cb1c1 100644
--- a/pbr/git.py
+++ b/pbr/git.py
@@ -169,7 +169,7 @@ def _iter_changelog(changelog):
first_line = False
-def _iter_log_oneline(git_dir=None, option_dict=None):
+def _iter_log_oneline(git_dir=None):
"""Iterate over --oneline log entries if possible.
This parses the output into a structured form but does not apply
@@ -179,16 +179,10 @@ def _iter_log_oneline(git_dir=None, option_dict=None):
:return: An iterator of (hash, tags_set, 1st_line) tuples, or None if
changelog generation is disabled / not available.
"""
- if not option_dict:
- option_dict = {}
- should_skip = options.get_boolean_option(option_dict, 'skip_changelog',
- 'SKIP_WRITE_GIT_CHANGELOG')
- if should_skip:
- return
if git_dir is None:
git_dir = _get_git_directory()
if not git_dir:
- return
+ return []
return _iter_log_inner(git_dir)
@@ -227,11 +221,17 @@ def _iter_log_inner(git_dir):
def write_git_changelog(git_dir=None, dest_dir=os.path.curdir,
- option_dict=dict(), changelog=None):
+ option_dict=None, changelog=None):
"""Write a changelog based on the git changelog."""
start = time.time()
+ if not option_dict:
+ option_dict = {}
+ should_skip = options.get_boolean_option(option_dict, 'skip_changelog',
+ 'SKIP_WRITE_GIT_CHANGELOG')
+ if should_skip:
+ return
if not changelog:
- changelog = _iter_log_oneline(git_dir=git_dir, option_dict=option_dict)
+ changelog = _iter_log_oneline(git_dir=git_dir)
if changelog:
changelog = _iter_changelog(changelog)
if not changelog:
diff --git a/pbr/packaging.py b/pbr/packaging.py
index e444165..c8bb61b 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -414,7 +414,7 @@ class LocalEggInfo(egg_info.egg_info):
def _from_git(distribution):
option_dict = distribution.get_option_dict('pbr')
- changelog = git._iter_log_oneline(option_dict=option_dict)
+ changelog = git._iter_log_oneline()
if changelog:
changelog = git._iter_changelog(changelog)
git.write_git_changelog(option_dict=option_dict, changelog=changelog)
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 24373ab..4a188d0 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -444,6 +444,18 @@ class TestVersions(base.BaseTestCase):
version = packaging._get_version_from_git()
self.assertEqual('1.3.0.0a1', version)
+ def test_skip_write_git_changelog(self):
+ # Fix for bug 1467440
+ self.repo.commit()
+ self.repo.tag('1.2.3')
+ os.environ['SKIP_WRITE_GIT_CHANGELOG'] = '1'
+ version = packaging._get_version_from_git('1.2.3')
+ self.assertEqual('1.2.3', version)
+
+ def tearDown(self):
+ super(TestVersions, self).tearDown()
+ os.environ.pop('SKIP_WRITE_GIT_CHANGELOG', None)
+
class TestRequirementParsing(base.BaseTestCase):