summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-24 18:27:46 +0100
committerGauvain Pocentek <gauvain.pocentek@objectif-libre.com>2016-01-24 18:27:46 +0100
commit7981987141825c198d5664d843e86472b9e44f3f (patch)
tree3e9d2036edd164b46d218e92173ddee8ef2e1b5a
parent0814d8664d58fadb136af3c4031ea6e7359eb8f5 (diff)
downloadgitlab-7981987141825c198d5664d843e86472b9e44f3f.tar.gz
Implement setting release info on a tag
Add the set_release_description() method to ProjectTag. Add python API test for this method.
-rw-r--r--gitlab/objects.py27
-rw-r--r--tools/python_test.py3
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()