Skip to content

Commit

Permalink
Add support for commit comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Jun 19, 2016
1 parent 547f385 commit 412e2bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
3 changes: 3 additions & 0 deletions gitlab/__init__.py
Expand Up @@ -77,6 +77,8 @@ class Gitlab(object):
branches
project_commits (ProjectCommitManager): Manager for GitLab projects
commits
project_commitcomments (ProjectCommitCommentManager): Manager for
GitLab projects commits comments
project_keys (ProjectKeyManager): Manager for GitLab projects keys
project_events (ProjectEventManager): Manager for GitLab projects
events
Expand Down Expand Up @@ -143,6 +145,7 @@ def __init__(self, url, private_token=None, email=None, password=None,
self.licenses = LicenseManager(self)
self.project_branches = ProjectBranchManager(self)
self.project_commits = ProjectCommitManager(self)
self.project_commit_comments = ProjectCommitCommentManager(self)
self.project_keys = ProjectKeyManager(self)
self.project_events = ProjectEventManager(self)
self.project_forks = ProjectForkManager(self)
Expand Down
46 changes: 31 additions & 15 deletions gitlab/objects.py
Expand Up @@ -838,13 +838,44 @@ class ProjectBuildManager(BaseManager):
obj_cls = ProjectBuild


class ProjectCommitStatus(GitlabObject):
_url = '/projects/%(project_id)s/statuses/%(commit_id)s'
canUpdate = False
canDelete = False
requiredUrlAttrs = ['project_id', 'commit_id']
optionalGetAttrs = ['ref_name', 'stage', 'name', 'all']
requiredCreateAttrs = ['state']
optionalCreateAttrs = ['description', 'name', 'context', 'ref',
'target_url']


class ProjectCommitStatusManager(BaseManager):
obj_cls = ProjectCommitStatus


class ProjectCommitComment(GitlabObject):
_url = '/projects/%(project_id)s/repository/commits/%(commit_id)s/comments'
canUpdate = False
cantGet = False
canDelete = False
requiredUrlAttrs = ['project_id', 'commit_id']
requiredCreateAttrs = ['note']
optionalCreateAttrs = ['path', 'line', 'line_type']


class ProjectCommitCommentManager(BaseManager):
obj_cls = ProjectCommitComment


class ProjectCommit(GitlabObject):
_url = '/projects/%(project_id)s/repository/commits'
canDelete = False
canUpdate = False
canCreate = False
requiredUrlAttrs = ['project_id']
shortPrintAttr = 'title'
managers = [('comments', ProjectCommitCommentManager,
[('project_id', 'project_id'), ('commit_id', 'id')])]

def diff(self, **kwargs):
"""Generate the commit diff."""
Expand Down Expand Up @@ -904,21 +935,6 @@ class ProjectCommitManager(BaseManager):
obj_cls = ProjectCommit


class ProjectCommitStatus(GitlabObject):
_url = '/projects/%(project_id)s/statuses/%(commit_id)s'
canUpdate = False
canDelete = False
requiredUrlAttrs = ['project_id', 'commit_id']
optionalGetAttrs = ['ref_name', 'stage', 'name', 'all']
requiredCreateAttrs = ['state']
optionalCreateAttrs = ['description', 'name', 'context', 'ref',
'target_url']


class ProjectCommitStatusManager(BaseManager):
obj_cls = ProjectCommitStatus


class ProjectKey(GitlabObject):
_url = '/projects/%(project_id)s/keys'
canUpdate = False
Expand Down

0 comments on commit 412e2bc

Please sign in to comment.