From 87e4a22aa965ad625ba063e81f03f3db87119e1a Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Jan 11 2021 11:25:58 +0000 Subject: Fedpkg update didn't read bug numbers from changelog Fixes the regular expression by accepting whitespaces at the beginning of the pattern which finds bug numbers. JIRA: RHELCMP-3685 Resolves: rhbz#1912555 Signed-off-by: Ondrej Nosek --- diff --git a/fedpkg/cli.py b/fedpkg/cli.py index 18a683f..c6ccd95 100644 --- a/fedpkg/cli.py +++ b/fedpkg/cli.py @@ -703,7 +703,7 @@ class fedpkgClient(cliClient): id_pattern_raw = r'(?:fedora|epel|rh(?:bz)?)#(\d{5,})' bz_pattern = re.compile( # says: there is at least one complete (including prefix) Bugzilla bug occurrence - r'(?:fix(?:es)?|close(?:s)?|resolve(?:s)?)(?::|:\s+|\s+)' + id_pattern_raw, + r'\s*(?:fix(?:es)?|close(?:s)?|resolve(?:s)?)(?::|:\s+|\s+)' + id_pattern_raw, re.IGNORECASE, ) id_pattern = re.compile(id_pattern_raw, re.IGNORECASE) diff --git a/test/test_cli.py b/test/test_cli.py index 08bd7eb..b816558 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -123,8 +123,9 @@ class TestUpdate(CliTestCase): 'New command update - #1000', # invalid bug id format 'Fix tests - #2000, #notabug', # both invalid bug id format '处理一些Unicode字符číář', - 'fix: rh#10001' - 'Fixes: rhbz#20001' + 'fix: rh#10001', + 'Fixes: rhbz#20001', + ' close: fedora#30001', # test whitespace at the beginning ])) clog_file = os.path.join(self.cloned_repo_path, 'clog') with io.open(clog_file, 'w', encoding='utf-8') as f: @@ -190,7 +191,7 @@ class TestUpdate(CliTestCase): expected_data = { 'autokarma': 'True', - 'bugs': '10001,20001', + 'bugs': '10001,20001,30001', 'display_name': six.u(''), 'builds': ' {0} '.format(self.mock_nvr.return_value), 'close_bugs': True, @@ -228,7 +229,7 @@ class TestUpdate(CliTestCase): with io.open('bodhi.template', encoding='utf-8') as f: bodhi_template = f.read() self.assertTrue(self.mock_nvr.return_value in bodhi_template) - self.assertTrue('10001,20001' in bodhi_template) + self.assertTrue('10001,20001,30001' in bodhi_template) if notes: self.assertTrue(notes.replace('\n', '\n ') in bodhi_template) else: