Skip to content

Commit

Permalink
Issue webcompat#3140 - Adds a method to extract the public issue number
Browse files Browse the repository at this point in the history
We need the number to patch the issue at the right place.
  • Loading branch information
karlcow committed Feb 3, 2020
1 parent f5ad195 commit d946cd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/unit/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ def test_private_issue_moderated_ok(self, mock_proxy):
self.assertEqual(rv.status_code, 200)
self.assertEqual(rv.content_type, 'text/plain')

def test_get_public_issue_number(self):
"""Test the extraction of the issue number from the public_url."""
public_url = 'https://github.com/webcompat/webcompat-tests/issues/1'
self.assertEqual(helpers.get_public_issue_number(public_url), '1')


if __name__ == '__main__':
unittest.main()
6 changes: 6 additions & 0 deletions webcompat/webhooks/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ def get_issue_info(payload):
return issue_info


def get_public_issue_number(public_url):
"""Extract the issue number from the public url."""
public_number = public_url.strip().rsplit('/', 1)[1]
return public_number


def get_issue_labels(issue_body):
"""Extract the list of labels from an issue body to be sent to GitHub."""
labelslist = []
Expand Down

0 comments on commit d946cd0

Please sign in to comment.