From f2cc715d680b1aa0e961d8e3992510bf2c5a1886 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Fri, 26 Sep 2014 14:28:26 -0400 Subject: [PATCH 1/2] Add "Needs Triage" label to new PRs --- openedx_webhooks/views/github.py | 10 ++++++++++ openedx_webhooks/views/jira.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openedx_webhooks/views/github.py b/openedx_webhooks/views/github.py index cbde4a5a..2003d44d 100644 --- a/openedx_webhooks/views/github.py +++ b/openedx_webhooks/views/github.py @@ -177,6 +177,16 @@ def pr_opened(pr, bugsnag_context=None): comment_resp = github.post(url, json=comment) if not comment_resp.ok: raise requests.exceptions.RequestException(comment_resp.text) + needs_triage_label = { + "url": "https://api.github.com/repos/edx/edx-platform/labels/needs+triage", + "name": "needs triage", + "color": "e11d21" + } + + label_resp = github.patch(issue_url, data=json.dumps({"labels": [needs_triage_label]})) + if not label_resp.ok: + raise requests.exceptions.RequestException(label_resp.text) + print( "@{user} opened PR #{num} against {repo}, created {issue} to track it".format( user=user, repo=repo, diff --git a/openedx_webhooks/views/jira.py b/openedx_webhooks/views/jira.py index 16889fbc..fa4b224d 100644 --- a/openedx_webhooks/views/jira.py +++ b/openedx_webhooks/views/jira.py @@ -33,6 +33,11 @@ def get_jira_custom_fields(): # TODO: should load this directly from labels.yaml so the color and name info is up to date. # Doesn't have the URL info but that is easily constructed. STATUS_LABEL_DICT = { + 'Needs Triage': { + "url": "https://api.github.com/repos/edx/edx-platform/labels/needs+triage", + "name": "needs triage", + "color": "e11d21" + }, 'Product Review': { "url": "https://api.github.com/repos/edx/edx-platform/labels/product+review", "name": "product review", @@ -49,9 +54,9 @@ def get_jira_custom_fields(): 'color': 'fad8c7' }, 'Engineering Review': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/community+manager+review", - "name": "community manager review", - "color": "207de5" + "url": "https://api.github.com/repos/edx/edx-platform/labels/engineering+review", + "name": "engineering review", + "color": "c7def8" }, 'Waiting on Author': { "url": "https://api.github.com/repos/edx/edx-platform/labels/waiting+on+author", From cf49c94a9c1dd407a2203a9756e39b03a2381c8f Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Tue, 7 Oct 2014 20:38:54 -0400 Subject: [PATCH 2/2] Fix issues with label api --- openedx_webhooks/views/github.py | 8 ++----- openedx_webhooks/views/jira.py | 40 ++++++-------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/openedx_webhooks/views/github.py b/openedx_webhooks/views/github.py index 2003d44d..e97c96f3 100644 --- a/openedx_webhooks/views/github.py +++ b/openedx_webhooks/views/github.py @@ -177,13 +177,9 @@ def pr_opened(pr, bugsnag_context=None): comment_resp = github.post(url, json=comment) if not comment_resp.ok: raise requests.exceptions.RequestException(comment_resp.text) - needs_triage_label = { - "url": "https://api.github.com/repos/edx/edx-platform/labels/needs+triage", - "name": "needs triage", - "color": "e11d21" - } - label_resp = github.patch(issue_url, data=json.dumps({"labels": [needs_triage_label]})) + issue_url = "/repos/{repo}/issues/{num}".format(repo=repo, num=pr["number"]) + label_resp = github.patch(issue_url, data=json.dumps({"labels": ["needs triage"]})) if not label_resp.ok: raise requests.exceptions.RequestException(label_resp.text) diff --git a/openedx_webhooks/views/jira.py b/openedx_webhooks/views/jira.py index fa4b224d..67967af2 100644 --- a/openedx_webhooks/views/jira.py +++ b/openedx_webhooks/views/jira.py @@ -29,40 +29,14 @@ def get_jira_custom_fields(): if value["custom"] } -# Maps JIRA status : Github label dictionary -# TODO: should load this directly from labels.yaml so the color and name info is up to date. -# Doesn't have the URL info but that is easily constructed. +# Maps JIRA status : Github label name STATUS_LABEL_DICT = { - 'Needs Triage': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/needs+triage", - "name": "needs triage", - "color": "e11d21" - }, - 'Product Review': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/product+review", - "name": "product review", - "color": "5319e7" - }, - 'Community Manager Review': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/community+manager+review", - "name": "community manager review", - "color": "207de5" - }, - 'Awaiting Prioritization': { - 'url': 'https://api.github.com/repos/edx/edx-platform/labels/awaiting+prioritization', - 'name': 'awaiting prioritization', - 'color': 'fad8c7' - }, - 'Engineering Review': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/engineering+review", - "name": "engineering review", - "color": "c7def8" - }, - 'Waiting on Author': { - "url": "https://api.github.com/repos/edx/edx-platform/labels/waiting+on+author", - "name": "waiting on author", - "color": "0052cc" - }, + 'Needs Triage': "needs triage", + 'Product Review': "product review", + 'Community Manager Review': "community manager review", + 'Awaiting Prioritization': "awaiting prioritization", + 'Engineering Review': "engineering review", + 'Waiting on Author': "waiting on author", }