diff options
-rw-r--r-- | gitlab/objects.py | 27 | ||||
-rw-r--r-- | tools/python_test.py | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index f23d12c..66a46f3 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -638,7 +638,6 @@ class ProjectBranch(GitlabObject): canUpdate = False requiredUrlAttrs = ['project_id'] requiredCreateAttrs = ['branch_name', 'ref'] - _constructorTypes = {'commit': 'ProjectCommit'} def protect(self, protect=True, **kwargs): url = self._url % {'project_id': self.project_id} @@ -832,8 +831,23 @@ class ProjectNoteManager(BaseManager): obj_cls = ProjectNote +class ProjectTagRelease(GitlabObject): + _url = '/projects/%(project_id)s/repository/tags/%(tag_name)/release' + canDelete = False + canList = False + requiredUrlAttrs = ['project_id', 'tag_name'] + requiredCreateAttrs = ['description'] + shortPrintAttr = 'description' + + +class ProjectTagReleaseManager(BaseManager): + obj_cls = ProjectTagRelease + + class ProjectTag(GitlabObject): _url = '/projects/%(project_id)s/repository/tags' + _constructorTypes = {'release': 'ProjectTagRelease', + 'commit': 'ProjectCommit'} idAttr = 'name' canGet = 'from_list' canUpdate = False @@ -842,6 +856,17 @@ class ProjectTag(GitlabObject): optionalCreateAttrs = ['message'] shortPrintAttr = 'name' + def set_release_description(self, description): + url = '/projects/%s/repository/tags/%s/release' % (self.project_id, + self.name) + if self.release is None: + r = self.gitlab._raw_post(url, data={'description': description}) + raise_error_from_response(r, GitlabCreateError, 201) + else: + r = self.gitlab._raw_put(url, data={'description': description}) + raise_error_from_response(r, GitlabUpdateError, 200) + self.release = ProjectTagRelease(self, r.json()) + class ProjectTagManager(BaseManager): obj_cls = ProjectTag diff --git a/tools/python_test.py b/tools/python_test.py index d4786d5..2dc7a10 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -148,4 +148,7 @@ assert(m1.issues()[0].title == 'my issue 1') # tags tag1 = admin_project.tags.create({'tag_name': 'v1.0', 'ref': 'master'}) assert(len(admin_project.tags.list()) == 1) +tag1.set_release_description('Description 1') +tag1.set_release_description('Description 2') +assert(tag1.release.description == 'Description 2') tag1.delete() |