Skip to content

Commit bf97f4d

Browse files
committed
Added warning for listing commits in repos containing '.'.
1 parent 997187d commit bf97f4d

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

github2/commits.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class Commits(GithubCommand):
2929
def list(self, project, branch="master", file=None):
3030
"""List commits on a project
3131
32+
.. warning::
33+
Unfortunately, listing the commits from repositories containing
34+
certain characters such as '.' will fail. This is an issue with the
35+
GitHub API, and can't currently be worked around in this library.
36+
3237
:param str project: project name
3338
:param str branch: branch name
3439
:param str file: optional file filter
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
status: 404
2+
content-location: https://github.com/api/v2/json/commits/list/kennethreitz/osxpython.org/master
3+
x-runtime: 24ms
4+
content-length: 21
5+
server: nginx/0.7.67
6+
connection: keep-alive
7+
x-ratelimit-limit: 60
8+
cache-control: no-cache
9+
date: Sun, 22 May 2011 20:40:50 GMT
10+
content-type: application/json; charset=utf-8
11+
12+
{"error":"Not Found"}

tests/test_commits.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sys
44

5-
from nose.tools import assert_equals
5+
from nose.tools import (assert_equals, assert_false)
66

77
import utils
88

@@ -34,3 +34,21 @@ def test_list_with_branch_and_file(self):
3434
assert_equals(len(commits), 35)
3535
assert_equals(commits[0].id,
3636
'482f657443df4b701137a3025ae08476cddd2b7d')
37+
38+
def test_list_repo_with_dot(self):
39+
"""GitHub returns error listing commits in repos containing '.'
40+
41+
The purpose of this test is to tell us when this issue is fixed
42+
upstream.
43+
"""
44+
try:
45+
commits = self.client.commits.list('kennethreitz/osxpython.org')
46+
except RuntimeError:
47+
# The hoop jumping here is for Python 2 & 3 compatibility, it is
48+
# also good a sign it may be time to use 2to3 on the tests.
49+
e = sys.exc_info()[1]
50+
if """'{"error":"Not Found"}'""" not in e.args[0]:
51+
raise
52+
commits = None
53+
assert_false(commits,
54+
"Listing commits with '.' in name is fixed upstream!")

0 commit comments

Comments
 (0)