Add urgency management.
authorDaniel Dehennin <daniel.dehennin@baby-gnu.org>
Mon, 21 Nov 2011 18:57:18 +0000 (19:57 +0100)
committerGuido Günther <agx@sigxcpu.org>
Sat, 6 Apr 2013 16:30:00 +0000 (18:30 +0200)
* tests/11_test_dch_main.py: test the new --urgency option to
  dch.main(). Add only meaningful tests, i.e. options alone and combined
  with --release and --snapshot.

* git-dch (fixup_section): Manage "urgency" option.
  (main): Add version_group option "-U" and "--urgency" to set the
  urgency level of the entry.

* docs/manpages/git-dch.sgml: Update documentation for new option.

docs/manpages/git-dch.sgml
gbp/scripts/dch.py
tests/11_test_dch_main.py

index 0cccf09..8f4bae1 100644 (file)
@@ -43,6 +43,7 @@
       </group>
       <arg><option>--distribution=</option><replaceable>name</replaceable></arg>
       <arg><option>--force-distribution</option></arg>
+      <arg><option>--urgency=</option><replaceable>level</replaceable></arg>
       <arg><option>--[no-]full</option></arg>
       <arg><option>--[no-]meta</option></arg>
       <arg><option>--meta-closes=bug-close-tags</option></arg>
        </listitem>
       </varlistentry>
       <varlistentry>
+       <term><option>--urgency=</option><replaceable>level</replaceable>
+       </term>
+       <listitem>
+         <para>Set the urgency field
+         to <replaceable>level</replaceable>.</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><option>--git-log=</option><replaceable>git-log-options</replaceable>
         </term>
         <listitem>
index c06fb50..66da519 100644 (file)
@@ -72,7 +72,7 @@ def fixup_section(repo, git_author, options, dch_options):
     This apply --distribution and --urgency options passed to git-dch
     """
     author, email = get_author_email(repo, git_author)
-    used_options = ['distribution']
+    used_options = ['distribution', 'urgency']
     header_opts = []
 
     # This must not be done for snapshots or snapshots changelog entries
@@ -318,6 +318,7 @@ def main(argv):
                       help="Force the provided distribution to be used, even if it doesn't match the list of known distributions")
     version_group.add_option("-N", "--new-version", dest="new_version",
                       help="use this as base for the new version number")
+    version_group.add_option("-U", "--urgency", dest="urgency", help="Set urgency level")
     version_group.add_option("--bpo", dest="bpo", action="store_true", default=False,
                       help="Increment the Debian release number for an upload to backports, and add a backport upload changelog comment.")
     version_group.add_option("--nmu", dest="nmu", action="store_true", default=False,
index 36431ef..e43709c 100644 (file)
@@ -267,6 +267,35 @@ class TestScriptDch(DebianGitTestRepo):
         self.assertIn("""  * TEST-COMMITTED-SNAPSHOT\n""", lines)
 
 
+    def test_dch_main_new_upstream_version_with_urgency(self):
+        """Test dch.py like git-dch script does: new upstream version - set urgency"""
+        options = ["--urgency=emergency"]
+        lines = self.run_dch(options)
+        self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=emergency\n", lines[0])
+        self.assertIn("""  * added debian/control\n""", lines)
+
+
+    def test_dch_main_new_upstream_version_with_release_urgency(self):
+        """Test dch.py like git-dch script does: new upstream version - release - set urgency"""
+        options = ["--release"]
+        options.append("--urgency=emergency")
+        lines = self.run_dch(options)
+        self.assertEqual("test-package (1.0-1) unstable; urgency=emergency\n", lines[0])
+        self.assertIn("""  * added debian/control\n""", lines)
+
+
+    def test_dch_main_new_upstream_version_with_snapshot_urgency(self):
+        """Test dch.py like git-dch script does: new upstream version - snapshot mode - set urgency"""
+        options = ["--snapshot"]
+        options.append("--urgency=emergency")
+        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_increment_debian_version(self):
         """Test dch.py like git-dch script does: increment debian version"""
         self.repo.delete_tag("debian/0.9-1")