diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-05-08 12:02:19 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-05-08 12:02:19 +0200 |
commit | 250f34806b1414b5346b4eaf268eb2537d8017de (patch) | |
tree | 5023ca9469ba55d8f38a22fd6e6967540d51ef1e /gitlab/objects.py | |
parent | 7a8f81b32e47dab6da495f5cefffe48566934744 (diff) | |
download | gitlab-250f34806b1414b5346b4eaf268eb2537d8017de.tar.gz |
Implement project compare
Fixes #112
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index a7f35bd..3a44f6e 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1475,7 +1475,7 @@ class Project(GitlabObject): return r.content def raw_blob(self, sha, **kwargs): - """Return the raw file contents for a blob by blob SHA. + """Returns the raw file contents for a blob by blob SHA. Args: sha(str): ID of the blob @@ -1492,6 +1492,26 @@ class Project(GitlabObject): raise_error_from_response(r, GitlabGetError) return r.content + def compare(self, from_, to, **kwargs): + """Returns a diff between two branches/commits. + + Args: + from_(str): orig branch/SHA + to(str): dest branch/SHA + + Returns: + str: The diff + + Raises: + GitlabConnectionError: If the server cannot be reached. + GitlabGetError: If the server fails to perform the request. + """ + url = "/projects/%s/repository/compare" % self.id + url = "%s?from=%s&to=%s" % (url, from_, to) + r = self.gitlab._raw_get(url, **kwargs) + raise_error_from_response(r, GitlabGetError) + return r.json() + def archive(self, sha=None, **kwargs): """Return a tarball of the repository. |