From 2d90a5dac9820fbc66d4cea5b303bc8f8c44c954 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 6 Nov 2014 13:41:28 +0100 Subject: [PATCH] Making commit message actions case insensitive --- taiga/github_hook/event_hooks.py | 4 ++-- tests/integration/test_github_hook.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/taiga/github_hook/event_hooks.py b/taiga/github_hook/event_hooks.py index 10e7c6e1..e91b17da 100644 --- a/taiga/github_hook/event_hooks.py +++ b/taiga/github_hook/event_hooks.py @@ -63,8 +63,8 @@ class PushEventHook(BaseEventHook): if message is None: return - p = re.compile("TG-(\d+) +#([-\w]+)") - m = p.search(message) + p = re.compile("tg-(\d+) +#([-\w]+)") + m = p.search(message.lower()) if m: ref = m.group(1) status_slug = m.group(2) diff --git a/tests/integration/test_github_hook.py b/tests/integration/test_github_hook.py index d218c6eb..a5d25122 100644 --- a/tests/integration/test_github_hook.py +++ b/tests/integration/test_github_hook.py @@ -128,6 +128,24 @@ def test_push_event_user_story_processing(client): assert len(mail.outbox) == 1 +def test_push_event_processing_case_insensitive(client): + creation_status = f.TaskStatusFactory() + new_status = f.TaskStatusFactory(project=creation_status.project) + task = f.TaskFactory.create(status=creation_status, project=creation_status.project) + payload = {"commits": [ + {"message": """test message + test tg-%s #%s ok + bye! + """%(task.ref, new_status.slug.upper())}, + ]} + mail.outbox = [] + ev_hook = event_hooks.PushEventHook(task.project, payload) + ev_hook.process_event() + task = Task.objects.get(id=task.id) + assert task.status.id == new_status.id + assert len(mail.outbox) == 1 + + def test_push_event_bad_processing_non_existing_ref(client): issue_status = f.IssueStatusFactory() payload = {"commits": [