Skip to content

Commit

Permalink
Implement project compare
Browse files Browse the repository at this point in the history
Fixes #112
  • Loading branch information
Gauvain Pocentek committed May 8, 2016
1 parent 7a8f81b commit 250f348
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion gitlab/objects.py
Expand Up @@ -1475,7 +1475,7 @@ def blob(self, sha, filepath, **kwargs):
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
Expand All @@ -1492,6 +1492,26 @@ def raw_blob(self, sha, **kwargs):
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.
Expand Down

0 comments on commit 250f348

Please sign in to comment.