diff options
author | Adam Reid <areid@navtech.aero> | 2016-05-09 14:29:42 -0400 |
---|---|---|
committer | Adam Reid <areid@navtech.aero> | 2016-05-09 14:29:42 -0400 |
commit | 8edd7f79050559062ac119797329d0a8dba57a06 (patch) | |
tree | 0c2c07b7f86298929863e3fbf5946560252e5187 /gitlab/objects.py | |
parent | 111b7d9a4ee60176714b950d7ed9da86c6051feb (diff) | |
parent | 64af39818d02af1b40644d71fd047d6bc3f6e69e (diff) | |
download | gitlab-8edd7f79050559062ac119797329d0a8dba57a06.tar.gz |
Merge branch 'master' of https://github.com/gpocentek/python-gitlab
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 6924341..c537b42 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1473,6 +1473,59 @@ class Project(GitlabObject): raise_error_from_response(r, GitlabGetError) return r.content + def raw_blob(self, sha, **kwargs): + """Returns the raw file contents for a blob by blob SHA. + + Args: + sha(str): ID of the blob + + Returns: + str: The blob content + + Raises: + GitlabConnectionError: If the server cannot be reached. + GitlabGetError: If the server fails to perform the request. + """ + url = "/projects/%s/repository/raw_blobs/%s" % (self.id, sha) + r = self.gitlab._raw_get(url, **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 contributors(self): + """Returns a list of contributors for the project. + + Returns: + list: The contibutors + + Raises: + GitlabConnectionError: If the server cannot be reached. + GitlabGetError: If the server fails to perform the request. + """ + url = "/projects/%s/repository/contributors" % self.id + r = self.gitlab._raw_get(url) + raise_error_from_response(r, GitlabListError) + return r.json() + def archive(self, sha=None, **kwargs): """Return a tarball of the repository. |