Skip to content

refactor(objects): remove deprecated tag release API #1596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions gitlab/v4/objects/tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gitlab import cli
from gitlab import exceptions as exc
from gitlab.base import RequiredOptional, RESTManager, RESTObject
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin

Expand All @@ -15,41 +13,6 @@ class ProjectTag(ObjectDeleteMixin, RESTObject):
_id_attr = "name"
_short_print_attr = "name"

@cli.register_custom_action("ProjectTag", ("description",))
def set_release_description(self, description, **kwargs):
"""Set the release notes on the tag.

If the release doesn't exist yet, it will be created. If it already
exists, its description will be updated.

Args:
description (str): Description of the release.
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server fails to create the release
GitlabUpdateError: If the server fails to update the release
"""
id = self.get_id().replace("/", "%2F")
path = "%s/%s/release" % (self.manager.path, id)
data = {"description": description}
if self.release is None:
try:
server_data = self.manager.gitlab.http_post(
path, post_data=data, **kwargs
)
except exc.GitlabHttpError as e:
raise exc.GitlabCreateError(e.response_code, e.error_message) from e
else:
try:
server_data = self.manager.gitlab.http_put(
path, post_data=data, **kwargs
)
except exc.GitlabHttpError as e:
raise exc.GitlabUpdateError(e.response_code, e.error_message) from e
self.release = server_data


class ProjectTagManager(NoUpdateMixin, RESTManager):
_path = "/projects/%(project_id)s/repository/tags"
Expand Down
4 changes: 0 additions & 4 deletions tests/functional/api/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ def test_project_tags(project, project_file):
tag = project.tags.create({"tag_name": "v1.0", "ref": "master"})
assert len(project.tags.list()) == 1

tag.set_release_description("Description 1")
tag.set_release_description("Description 2")
assert tag.release["description"] == "Description 2"

tag.delete()
assert len(project.tags.list()) == 0

Expand Down