dch: Add support for the --local=suffix option
authorEmanuele Aina <emanuele.aina@collabora.com>
Mon, 8 Feb 2021 14:17:35 +0000 (15:17 +0100)
committerGuido Günther <agx@sigxcpu.org>
Sat, 13 Feb 2021 14:44:15 +0000 (15:44 +0100)
Closes: #857370
Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
debian/git-buildpackage.zsh-completion
docs/manpages/gbp-dch.xml
gbp/scripts/dch.py
tests/11_test_dch_main.py

index 61e9c6599b9507714edee5dde59b1783dc0f4db0..c8bb1731b972f23a8137d6a289e296d71fc96bc9 100644 (file)
@@ -154,6 +154,7 @@ _gbp-dch () {
                '--bpo[Increment the release number for a backports upload]' \
                '--nmu[Increment the release number for a NMU upload]' \
                '--qa[Increment the release number for a QA upload]' \
+               '(--local -l)'{-l,--local}'=-[Increment the release number for a local build]' \
                '--distribution=-[Set the distribution field]' \
                '--force-distribution[Force distribution]' \
                '--urgency=-[Set the upload urgency]' \
index 82a98334266d38260f05b2318b70aad9a7d7d0f8..bb9574cb6a8638dd1acf6d7ff9518061cbf99a3e 100644 (file)
@@ -49,6 +49,7 @@
         <arg><option>--qa</option></arg>
         <arg><option>--security</option></arg>
         <arg><option>--team</option></arg>
+        <arg><option>--local=</option><replaceable>suffix</replaceable></arg>
       </group>
       <arg><option>--distribution=</option><replaceable>name</replaceable></arg>
       <arg><option>--force-distribution</option></arg>
           </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><option>--local=</option><replaceable>suffix</replaceable>,
+              <option>-l</option> <replaceable>suffix</replaceable>
+        </term>
+        <listitem>
+          <para>
+            Increment the Debian release number for a local build
+            using the specified suffix.
+            This option can't be set via &gbp.conf;.
+          </para>
+        </listitem>
+      </varlistentry>
       <varlistentry>
         <term><option>--distribution=</option><replaceable>name</replaceable>
         </term>
index e48e87b5f7012f0374aa8908e547895a6787a630..635a4544ea396ac626ee899787beb67b16c53747 100644 (file)
@@ -393,6 +393,8 @@ def build_parser(name):
     version_group.add_option("--security", dest="security", action="store_true", default=False,
                              help="Increment the Debian release number for a security upload and "
                              "add a security upload changelog comment.")
+    version_group.add_option("-l", "--local", dest="local_suffix", metavar="SUFFIX",
+                             help="Add a suffix to the Debian version number for a local build.")
     version_group.add_boolean_config_file_option(option_name="git-author", dest="use_git_author")
     commit_group.add_boolean_config_file_option(option_name="meta", dest="meta")
     commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes")
@@ -498,7 +500,7 @@ def main(argv):
         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):
+                options.team or options.security or options.local_suffix):
             if options.bpo:
                 version_change['increment'] = '--bpo'
             elif options.nmu:
@@ -509,6 +511,8 @@ def main(argv):
                 version_change['increment'] = '--team'
             elif options.security:
                 version_change['increment'] = '--security'
+            elif options.local_suffix:
+                version_change['increment'] = '--local=%s' % options.local_suffix
             else:
                 version_change['version'] = options.new_version
             # the user wants to force a new version
index dbd82879141e7ba68345f442a72b3f5c015408e5..7dafb7f2271844707057924e133929171b569828 100644 (file)
@@ -304,6 +304,13 @@ class TestScriptDch(DebianGitTestRepo):
         self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0])
         self.assertIn("""  * added debian/control\n""", lines)
 
+    def test_dch_main_increment_debian_version_with_local(self):
+        """Test dch.py like gbp dch script does: increment debian version - local suffix"""
+        options = ["--local", "suffix"]
+        lines = self.run_dch(options)
+        self.assertEqual("test-package (0.9-1suffix1) UNRELEASED; urgency=%s\n" % (default_urgency,), lines[0])
+        self.assertIn("""  * added debian/control\n""", lines)
+
     def test_dch_main_increment_debian_version_with_auto(self):
         """Test dch.py like gbp dch script does: increment debian version - guess last commit"""
         self.repo.delete_tag("upstream/1.0")