diff options
author | Linn Crosetto <linn@hpe.com> | 2016-09-21 15:59:00 -0600 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-10-02 19:35:58 +0200 |
commit | c1b32fa62ee252e4cffb92a64b162ad8f98ca27a (patch) | |
tree | 5564638f5f942c00504f5abd0218390288670a96 | |
parent | f87c21c517a1353424c06d3b1ff7b405bcb9a0a6 (diff) |
dch: avoid adding section in snapshot mode if distribution is UNRELEASED
When using git-dch in snapshot mode, a section is added without checking
whether the distribution is set to UNRELEASED. If the distribution is
UNRELEASED, the version will be incremented but a new section will not be
added, resulting in a skipped version in the changelog.
Change this behavior to add a new section in snapshot mode only if the
distribution is not set to UNRELEASED.
Signed-off-by: Linn Crosetto <linn@hpe.com>
Closes: #838714
-rw-r--r-- | gbp/scripts/dch.py | 16 | ||||
-rw-r--r-- | tests/11_test_dch_main.py | 16 |
2 files changed, 24 insertions, 8 deletions
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 2ccbacbd..d716fbac 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -466,6 +466,7 @@ def main(argv): options=options.git_log.split(" ")) commits.reverse() + add_section = False # add a new changelog section if: if (options.new_version or options.bpo or options.nmu or options.qa or options.team or options.security): @@ -483,14 +484,13 @@ def main(argv): version_change['version'] = options.new_version # the user wants to force a new version add_section = True - elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner and commits: - # the last version was a release and we have pending commits - add_section = True - elif options.snapshot and not found_snapshot_banner: - # the user want to switch to snapshot mode - add_section = True - else: - add_section = False + elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_banner: + if commits: + # the last version was a release and we have pending commits + add_section = True + if options.snapshot: + # the user want to switch to snapshot mode + add_section = True if add_section and not version_change and not source.is_native(): # Get version from upstream if none provided diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py index a6c7876d..e9b64004 100644 --- a/tests/11_test_dch_main.py +++ b/tests/11_test_dch_main.py @@ -339,6 +339,22 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) + def test_dch_main_unreleased_debian_version_with_snapshot(self): + """Test dch.py like gbp dch script does: snapshot mode with unreleased debian version""" + new_version_1_0 = '1.0-1' + options = ["--commit"] + options.append("--commit-msg=UNRELEASED-version") + lines = self.run_dch() + header = re.search(r"\(%s\) UNRELEASED" % new_version_1_0, lines[0]) + self.assertIsNotNone(header) + options = ["--snapshot", "--auto"] + lines = self.run_dch(options) + header = re.search(snap_header_1, lines[0]) + self.assertIsNotNone(header) + self.assertEqual(header.lastindex, 1) + self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) + self.assertIn(""" * added debian/control\n""", lines) + def test_dch_main_closes_default(self): options = ["--meta"] self.add_file("closes", "test file", |