diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 729a6453..ad6cdfc7 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -143,7 +143,7 @@ API `/repos/:user/:repo/commits/:sha/comments` API `/repos/:user/:repo/compare/:base...:head` ============================================== -* GET: (TODO) +* GET: `Repository.compare` API `/repos/:user/:repo/contributors` ===================================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 99d6b9a7..22a7fdb3 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -907,6 +907,7 @@ Pulls * `get_pulls( [state] )`: list of `PullRequest` * `get_pull( number )`: `PullRequest` * `create_pull( < title, body, base, head > or < issue, base, head > )`: `PullRequest` +* `compare( base, head )` Teams ----- diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 3024075e..253cb901 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -19,6 +19,9 @@ from PullRequest import * __modifyAttributesForObjectsReferingRepo = { "_repo": lambda repo: repo } +def __compare( repo, base, head ): + return repo._github._dataRequest( "GET", repo._baseUrl() + "/compare/" + base + "..." + head, None, None ) + Repository = GithubObject( "Repository", BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ), @@ -136,4 +139,5 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ElementGetable( Parameters( [ "number" ], [] ), __modifyAttributesForObjectsReferingRepo ), ElementCreatable( Alternative( Parameters( [ "title", "body", "base", "head" ], [] ), Parameters( [ "issue", "base", "head" ], [] ) ), __modifyAttributesForObjectsReferingRepo ), ), + MethodFromCallable( "compare", Parameters( [ "base", "head" ], [] ), __compare, SimpleTypePolicy( None ) ), ] ) )