summaryrefslogtreecommitdiffhomepage
path: root/tests/23_test_dch_extract_bts_cmds.py
diff options
context:
space:
mode:
authorJonathan Toppins <jtoppins@cumulusnetworks.com>2015-08-27 10:09:37 -0400
committerGuido Günther <agx@sigxcpu.org>2015-08-27 19:40:35 +0200
commitc89c29d3584d8e6e4a25eb434849f93b14897485 (patch)
tree8048290a7fcd15b5903c2edafcb49914265c5bdf /tests/23_test_dch_extract_bts_cmds.py
parent488ba325db7d467d813c4966354676e1f943988d (diff)
gbp-dch: allow bug number format to be overridden
Some derivatives and non Debian exclusive projects don't use just numbers for their bug numbers. gbp-dch should still be able to parse these bug numbers and generate useful changelog entries. This doesn't solve dpkg-parsechangelog but is a start. Examples of non-Debian bug numbers are: example change header Example: EX-12345 Should produce the following change log: * example change header (Example: EX-12345) This also helps in pulling CVE numbers simply by letting the user modify the regex to something like 'cve-\d+-\d+'. Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com> Signed-off-by: Guido Günther <agx@sigxcpu.org>
Diffstat (limited to 'tests/23_test_dch_extract_bts_cmds.py')
-rw-r--r--tests/23_test_dch_extract_bts_cmds.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/23_test_dch_extract_bts_cmds.py b/tests/23_test_dch_extract_bts_cmds.py
new file mode 100644
index 00000000..3acff5e6
--- /dev/null
+++ b/tests/23_test_dch_extract_bts_cmds.py
@@ -0,0 +1,54 @@
+# (C) 2015 Jonathan Toppins <jtoppins@cumulusnetworks.com>
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, please see
+# <http://www.gnu.org/licenses/>
+"""Test gbp.dch.extract_bts_cmds()"""
+
+import os
+import unittest
+
+from gbp.dch import extract_bts_cmds
+
+class OptionsStub:
+ def __init__(self):
+ self.meta_closes = "Closes|LP"
+ self.meta_closes_bugnum = r'(?:bug|issue)?\#?\s?\d+'
+
+class TestExtractBTSCmds(unittest.TestCase):
+ def test_debian_commands(self):
+ """Test default BTS command extraction that is applicable to Debian"""
+ options = OptionsStub()
+ lines = """This is a test commit
+
+Closes: bug#12345
+Closes: 456
+"""
+ bugs, dummy = extract_bts_cmds(lines.split('\n'), options)
+ self.assertEquals(bugs, {'Closes': ['bug#12345', '456']})
+
+ def test_nondebian_commands(self):
+ """Test non-default BTS commands. We use the example given in the
+ documentation manpages."""
+ options = OptionsStub()
+ options.meta_closes_bugnum = "(?:bug)?\s*ex-\d+"
+ lines = """This is a test commit
+some more lines...
+
+Closes: bug EX-12345
+Closes: ex-01273
+Closes: bug ex-1ab
+Closes: EX--12345
+"""
+ bugs, dummy = extract_bts_cmds(lines.split('\n'), options)
+ self.assertEquals(bugs, {'Closes': ['bug EX-12345', 'ex-01273',
+ 'bug ex-1']})