From c9aedf21464b4c219aac4f46b53d591dc4f1ef16 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 14 Sep 2013 11:55:10 +0200 Subject: Implement Gitlab 6.1 new methods - Project: tree, blob - ProjectCommit: diff, blob --- gitlab.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gitlab.py') diff --git a/gitlab.py b/gitlab.py index 78af89d..9414fc2 100644 --- a/gitlab.py +++ b/gitlab.py @@ -651,6 +651,25 @@ class ProjectCommit(GitlabObject): requiredListAttrs = ['project_id'] shortPrintAttr = 'title' + def diff(self): + url = '/projects/%(project_id)s/repository/commits/%(commit_id)s/diff' % \ + {'project_id': self.project_id, 'commit_id': self.id} + r = self.gitlab.rawGet(url) + if r.status_code == 200: + return r.json() + + raise GitlabGetError() + + def blob(self, filepath): + url = '/projects/%(project_id)s/repository/blobs/%(commit_id)s' % \ + {'project_id': self.project_id, 'commit_id': self.id} + url += '?filepath=%s' % filepath + r = self.gitlab.rawGet(url) + if r.status_code == 200: + return r.content + + raise GitlabGetError() + class ProjectKey(GitlabObject): _url = '/projects/%(project_id)s/keys' @@ -865,6 +884,24 @@ class Project(GitlabObject): project_id=self.id, **kwargs) + def tree(self, path='', ref_name=''): + url = "%s/%s/repository/tree" % (self._url, self.id) + url += '?path=%s&ref_name=%s' % (path, ref_name) + r = self.gitlab.rawGet(url) + if r.status_code == 200: + return r.json() + + raise GitlabGetError() + + def blob(self, sha, filepath): + url = "%s/%s/repository/blobs/%s" % (self._url, self.id, sha) + url += '?filepath=%s' % (filepath) + r = self.gitlab.rawGet(url) + if r.status_code == 200: + return r.content + + raise GitlabGetError() + class TeamMember(GitlabObject): _url = '/user_teams/%(team_id)s/members' -- cgit v1.2.1