diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2013-09-14 11:55:10 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2013-09-14 11:55:10 +0200 |
commit | c9aedf21464b4c219aac4f46b53d591dc4f1ef16 (patch) | |
tree | 2c80d553b9bd688252ad22588ec4b83072ab4e51 /gitlab.py | |
parent | 4006ab26ce73d03a8d74cfd978d93117ce8d68d6 (diff) | |
download | gitlab-c9aedf21464b4c219aac4f46b53d591dc4f1ef16.tar.gz |
Implement Gitlab 6.1 new methods
- Project: tree, blob
- ProjectCommit: diff, blob
Diffstat (limited to 'gitlab.py')
-rw-r--r-- | gitlab.py | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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' |