From 63894a5d00a0b001ce8379ec4bff2fcb8f8f1929 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 11 2018 14:32:08 +0000 Subject: [PATCH 1/3] Adjust the FIXES regex so they cover project having a dash in their name Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/link.py b/pagure/lib/link.py index d25a425..04ca77b 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -20,15 +20,15 @@ import pagure.exceptions FIXES = [ re.compile(r'(?:.*\s+)?fixe?[sd]?:?\s*?#(\d+)', re.I), re.compile( - r'(?:.*\s+)?fixe?[sd]?:?\s*?https?://.*/(\w+)' + r'(?:.*\s+)?fixe?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)' '/(?:issue|pull-request)/(\d+)', re.I), re.compile(r'(?:.*\s+)?merge?[sd]?:?\s*?#(\d+)', re.I), re.compile( - r'(?:.*\s+)?merge?[sd]?:?\s*?https?://.*/(\w+)' + r'(?:.*\s+)?merge?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)' '/(?:issue|pull-request)/(\d+)', re.I), re.compile(r'(?:.*\s+)?close?[sd]?:?\s*?#(\d+)', re.I), re.compile( - r'(?:.*\s+)?close?[sd]?:?\s*?https?://.*/(\w+)' + r'(?:.*\s+)?close?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)' '/(?:issue|pull-request)/(\d+)', re.I), ] diff --git a/tests/test_pagure_lib_link.py b/tests/test_pagure_lib_link.py index 14aa418..b6ec4fa 100644 --- a/tests/test_pagure_lib_link.py +++ b/tests/test_pagure_lib_link.py @@ -260,6 +260,8 @@ class PagureLibLinktests(tests.Modeltests): ('test', '123')) project_match('Merge: http://localhost/fork/pingou/test/issue/1234#foo', ('test', '1234')) + project_match('Merges: https://localhost/SSSD/ding-libs/pull-request/3188', + ('ding-libs', '3188')) # issue matches def issue_match(text, issue): From 3aa8fb69c25cb89816851ff30c9bcad357557a0a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 11 2018 14:32:08 +0000 Subject: [PATCH 2/3] Add a little more debugging if needed Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/files/pagure_hook.py b/pagure/hooks/files/pagure_hook.py index fe0dd4d..d6c8f99 100755 --- a/pagure/hooks/files/pagure_hook.py +++ b/pagure/hooks/files/pagure_hook.py @@ -51,6 +51,8 @@ def generate_revision_change_log(new_commits_list): line, 'fixes', include_prs=True): + if _config.get('HOOK_DEBUG', False): + print(commitid, relation) fixes_relation(commitid, relation, session, _config.get('APP_URL')) @@ -61,6 +63,8 @@ def generate_revision_change_log(new_commits_list): pagure.lib.git.get_repo_namespace(abspath), line, 'relates'): + if _config.get('HOOK_DEBUG', False): + print(commitid, issue) relates_commit(commitid, issue, session, _config.get('APP_URL')) session.close() From 4ecd3d6d53b5f09692f693d000d58cd8270cb7a3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 11 2018 14:32:08 +0000 Subject: [PATCH 3/3] Fix the RELATES regex as we fixed the FIXES ones Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/link.py b/pagure/lib/link.py index 04ca77b..a983f4e 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -37,7 +37,7 @@ RELATES = [ re.compile(r'(?:.*\s+)?relate[sd]?:?\s?#(\d+)', re.I), re.compile( r'(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?' - 'https?://.*/(\w+)/issue/(\d+)', re.I), + 'https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)/issue/(\d+)', re.I), ] diff --git a/tests/test_pagure_lib_link.py b/tests/test_pagure_lib_link.py index b6ec4fa..bb51d8e 100644 --- a/tests/test_pagure_lib_link.py +++ b/tests/test_pagure_lib_link.py @@ -223,6 +223,13 @@ class PagureLibLinktests(tests.Modeltests): else: self.assertEqual(regex.match(text), None) + text = 'relates https://localhost/SSSD/ding-libs/issue/31' + for index, regex in enumerate(pagure.lib.link.RELATES): + if index == 2: + self.assertNotEqual(regex.match(text), None) + else: + self.assertEqual(regex.match(text), None) + def test_fixes_regex(self): ''' Test the fixes regex present in pagure.lib.link. '''