rpm-ch: implement '--all' option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 16 May 2014 11:26:49 +0000 (14:26 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:47 +0000 (10:07 +0200)
If defined, git-rpm-ch uses all commits in the Git history. Also,
'--since' option is omitted.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/rpm_ch.py
tests/component/rpm/test_rpm_ch.py

index 30426fb4097f572706b274db20c7219e17b79ae3..65cfef2cca8f3eea7860131570ffb34efe780206 100755 (executable)
@@ -237,7 +237,9 @@ def guess_commit(section, repo, options):
 
 def get_start_commit(changelog, repo, options):
     """Get the start commit from which to generate new entries"""
-    if options.since:
+    if options.all:
+        since = None
+    elif options.since:
         since = options.since
     else:
         if changelog.sections:
@@ -246,7 +248,7 @@ def get_start_commit(changelog, repo, options):
             since = None
         if not since:
             raise GbpError("Couldn't determine starting point from "
-                           "changelog, please use the '--since' option")
+                           "changelog, please use the '--since' or '--all'")
         gbp.log.info("Continuing from commit '%s'" % since)
     return since
 
@@ -436,6 +438,9 @@ def build_parser(name):
     # Range group options
     range_grp.add_option("-s", "--since", dest="since",
                     help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
+    range_grp.add_option("--all", action="store_true",
+                    help="use all commits from the Git history, overrides "
+                         "--since")
     # Formatting group options
     format_grp.add_option("--no-release", action="store_false", default=True,
                     dest="release",
index 810ea30ba529e410979f2191a5b4c2e567556222..e8f9b71170ed1b9f8421227b3e0b7511c1543073 100644 (file)
@@ -117,6 +117,16 @@ class TestRpmCh(RpmRepoTestBase):
         # Should contain 3 lines (header, 1 entry and an empty line)
         eq_(len(content), 3)
 
+    def test_option_all(self):
+        """Test the --all cmdline option"""
+        repo = self.init_test_repo('gbp-test2')
+
+        eq_(mock_ch(['--changelog-file=CHANGES', '--all']), 0)
+        content = self.read_file('packaging/gbp-test2.changes')
+        # Should contain N+2 lines (header, N commits and an empty line)
+        commit_cnt = len(repo.get_commits(since=None, until='master'))
+        eq_(len(content), commit_cnt + 2)
+
     def test_option_changelog_file(self):
         """Test the --changelog-file cmdline option"""
         repo = self.init_test_repo('gbp-test-native')