8000 Merge pull request #138 from paulswartz/137-issue-html_url · jeffcross/github3.py@d8348a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8348a2

Browse files
committed
Merge pull request sigmavirus24#138 from paulswartz/137-issue-html_url
Issue sigmavirus24#137: Issues can sometimes have `pull` in the `html_url`
2 parents 6b28752 + bfa66db commit d8348a2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

github3/issues/issue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, issue, session=None):
7474
self.number = issue.get('number')
7575
#: Dictionary URLs for the pull request (if they exist)
7676
self.pull_request = issue.get('pull_request')
77-
m = match('https://[\w\d\-\.\:]+/(\S+)/(\S+)/issues/\d+',
77+
m = match('https://[\w\d\-\.\:]+/(\S+)/(\S+)/(?:issues|pull)/\d+',
7878
self.html_url)
7979
#: Returns ('owner', 'repository') this issue was filed on.
8080
self.repository = m.groups()

tests/json/issue_137

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"body": "We use the `_api` attribute to make constructing urls for objects. After a discussion today with GitHub support, it seems as if they'll be using the `url` parameter in the json objects for the same url with parameters in the future. This change was recently made (possibly accidentally) breaking what functionality I had relied on (although they fixed it once I reported it).\n\nFrom now on, to keep with that functionality, I'll have to construct these urls myself (the form I was intending on relying upon).\n\nAnother option I have is to just strip off the parameters and save those elsewhere in case the API starts to require that.", "labels": [{"url": "https://api.github.com/repos/sigmavirus24/github3.py/labels/bug", "color": "fc2929", "name": "bug"}, {"url": "https://api.github.com/repos/sigmavirus24/github3.py/labels/enhancement", "color": "84b6eb", "name": "enhancement"}], "body_text": "We use the _api attribute to make constructing urls for objects. After a discussion today with GitHub support, it seems as if they'll be using the url parameter in the json objects for the same url with parameters in the future. This change was recently made (possibly accidentally) breaking what functionality I had relied on (although they fixed it once I reported it).\n\nFrom now on, to keep with that functionality, I'll have to construct these urls myself (the form I was intending on relying upon).\n\nAnother option I have is to just strip off the parameters and save those elsewhere in case the API starts to require that.", "title": "Construct _api attribute on our own", "url": "https://api.github.com/repos/sigmavirus24/github3.py/issues/1", "created_at": "2012-06-15T17:54:49Z", "milestone": {"description": null, "title": "0.1", "url": "https://api.github.com/repos/sigmavirus24/github3.py/milestones/1", "created_at": "2012-06-15T17:54:49Z", "creator": {"url": "https://api.github.com/users/sigmavirus24", "avatar_url": "https://secure.gravatar.com/avatar/c148356d89f925e692178bee1d93acf7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", "_links": {"self": {"href": "https://api.github.com/users/sigmavirus24"}}, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "id": 240830}, "number": 1, "open_issues": 3, "state": "open", "closed_issues": 3, "due_on": null, "id": 132462}, "body_html": "<p>We use the <code>_api</code> attribute to make constructing urls for objects. After a discussion today with GitHub support, it seems as if they'll be using the <code>url</code> parameter in the json objects for the same url with parameters in the future. This change was recently made (possibly accidentally) breaking what functionality I had relied on (although they fixed it once I reported it).</p>\n\n<p>From now on, to keep with that functionality, I'll have to construct these urls myself (the form I was intending on relying upon).</p>\n\n<p>Another option I have is to just strip off the parameters and save those elsewhere in case the API starts to require that.</p>", "comments": 2, "number": 1, "updated_at": "2012-09-17T23:32:48Z", "assignee": {"url": "https://api.github.com/users/sigmavirus24", "avatar_url": "https://secure.gravatar.com/avatar/c148356d89f925e692178bee1d93acf7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", "_links": {"self": {"href": "https://api.github.com/users/sigmavirus24"}}, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "id": 240830}, "html_url": "https://github.com/sigmavirus24/github3.py/pull/1", "state": "closed", "user": {"url": "https://api.github.com/users/sigmavirus24", "avatar_url": "https://secure.gravatar.com/avatar/c148356d89f925e692178bee1d93acf7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", "_links": {"self": {"href": "https://api.github.com/users/sigmavirus24"}}, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "id": 240830}, "pull_request": {"diff_url": null, "html_url": null, "patch_url": null}, "id": 5097345, "closed_at": "2012-09-17T23:32:48Z", "closed_by": {"url": "https://api.github.com/users/sigmavirus24", "avatar_url": "https://secure.gravatar.com/avatar/c148356d89f925e692178bee1d93acf7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png", "_links": {"self": {"href": "https://api.github.com/users/sigmavirus24"}}, "gravatar_id": "c148356d89f925e692178bee1d93acf7", "login": "sigmavirus24", "id": 240830}}

tests/test_issues.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ def test_reopen(self):
309309
def test_enterprise(self):
310310
Issue(load('issue_enterprise'))
311311

312+
def test_issue_137(self):
313+
"""
314+
GitHub sometimes returns `pull` as part of of the `html_url` for Issue
315+
requests.
316+
"""
317+
i = Issue(load('issue_137'))
318+
self.assertEqual(
319+
i.html_url,
320+
"https://github.com/sigmavirus24/github3.py/pull/1")
321+
self.assertEqual(i.repository, ("sigmavirus24", "github3.py"))
322+
323+
312324

313325
class TestIssueEvent(BaseCase):
314326
def setUp(self):

0 commit comments

Comments
 (0)
0