diff --git a/ReadMe.md b/ReadMe.md index db758ce1..42cfa159 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -13,6 +13,11 @@ What's new? [![Build Status](https://secure.travis-ci.org/jacquev6/PyGithub.png)](http://travis-ci.org/jacquev6/PyGithub) +Next version +------------ + +* Add a shortcut function `Github.get_repo` to get a repo directly from its full name. thank you [lwc](https://github.com/lwc) for the contribution + [Version 1.9.1](https://github.com/jacquev6/PyGithub/issues?milestone=17&state=closed) (November 20th, 2012) ------------------------------------------------------------------------------------------------------------ diff --git a/doc/ReferenceOfApis.md b/doc/ReferenceOfApis.md index 73586918..9566a5f4 100644 --- a/doc/ReferenceOfApis.md +++ b/doc/ReferenceOfApis.md @@ -133,7 +133,7 @@ API `/rate_limit` API `/repos/:user/:repo` ======================== -* GET: `AuthenticatedUser.get_repo`, `NamedUser.get_repo` or `Organization.get_repo` +* GET: `AuthenticatedUser.get_repo`, `NamedUser.get_repo`, `Organization.get_repo` or `Github.get_repo` * PATCH: `Repository.edit` * DELETE: `Repository.delete` diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index e34a3882..d0d87b31 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -26,6 +26,7 @@ Methods * `get_user()`: `AuthenticatedUser` * `get_user( login )`: `NamedUser` * `get_organization( login )`: `Organization` +* `get_repo( full_name )`: `Repository` * `get_gist( id )`: `Gist` * `id`: string * `get_gists()`: `PaginatedList` of `Gist` diff --git a/github/Github.py b/github/Github.py index 711699c2..782d8f6f 100644 --- a/github/Github.py +++ b/github/Github.py @@ -70,11 +70,11 @@ class Github(object): ) return Organization.Organization(self.__requester, data, completed=True) - def get_repo(self, path): - assert isinstance(path, (str, unicode)), name + def get_repo(self, full_name): + assert isinstance(full_name, (str, unicode)), full_name headers, data = self.__requester.requestAndCheck( "GET", - "/repos/" + path, + "/repos/" + full_name, None, None ) diff --git a/github/tests/Github_.py b/github/tests/Github_.py index 95a51b5d..24d504c9 100644 --- a/github/tests/Github_.py +++ b/github/tests/Github_.py @@ -92,3 +92,6 @@ class Github(Framework.TestCase): self.assertEqual(hook.supported_events, ["push"]) self.assertEqual(hook.events, ["push"]) self.assertEqual(hook.schema, [["string", "url"], ["string", "token"], ["string", "project_id"], ["string", "milestone_id"], ["string", "category_id"]]) + + def testGetRepoFromFullName(self): + self.assertEqual(self.g.get_repo("jacquev6/PyGithub").description, "Python library implementing the full Github API v3") diff --git a/github/tests/ReplayData/Github.testGetRepoFromFullName.txt b/github/tests/ReplayData/Github.testGetRepoFromFullName.txt new file mode 100644 index 00000000..df44e1e0 --- /dev/null +++ b/github/tests/ReplayData/Github.testGetRepoFromFullName.txt @@ -0,0 +1,5 @@ +https GET api.github.com None /repos/jacquev6/PyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4939'), ('content-length', '1097'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"922c0519f2733063a899619ae95ce892"'), ('date', 'Sun, 20 May 2012 12:33:27 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"svn_url":"https://github.com/jacquev6/PyGithub","has_wiki":false,"has_issues":true,"updated_at":"2012-05-19T10:50:39Z","forks":2,"homepage":"http://vincent-jacques.net/PyGithub","git_url":"git://github.com/jacquev6/PyGithub.git","url":"https://api.github.com/repos/jacquev6/PyGithub","clone_url":"https://github.com/jacquev6/PyGithub.git","open_issues":18,"fork":false,"ssh_url":"git@github.com:jacquev6/PyGithub.git","pushed_at":"2012-05-19T10:50:39Z","size":304,"private":false,"has_downloads":true,"watchers":13,"html_url":"https://github.com/jacquev6/PyGithub","owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","login":"jacquev6","id":327146},"name":"PyGithub","permissions":{"pull":true,"admin":true,"push":true},"language":"Python","description":"Python library implementing the full Github API v3","created_at":"2012-02-25T12:53:47Z","id":3544490,"mirror_url":null} +