Skip to content

Commit

Permalink
Merge pull request #1655 from StingRayZA/add-milestone-promote
Browse files Browse the repository at this point in the history
feat(api): add project milestone promotion
  • Loading branch information
nejch committed Oct 31, 2021
2 parents 0b53c0a + f068520 commit 5ce3b17
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/milestones.rst
Expand Up @@ -66,6 +66,10 @@ Change the state of a milestone (activate / close)::
milestone.state_event = 'activate'
milestone.save()

Promote a project milestone::

milestone.promote()

List the issues related to a milestone::

issues = milestone.issues()
Expand Down
5 changes: 3 additions & 2 deletions gitlab/v4/objects/milestones.py
Expand Up @@ -2,7 +2,7 @@
from gitlab import exceptions as exc
from gitlab import types
from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, PromoteMixin, SaveMixin

from .issues import GroupIssue, GroupIssueManager, ProjectIssue, ProjectIssueManager
from .merge_requests import (
Expand Down Expand Up @@ -90,8 +90,9 @@ class GroupMilestoneManager(CRUDMixin, RESTManager):
_types = {"iids": types.ListAttribute}


class ProjectMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
_short_print_attr = "title"
_update_uses_post = True

@cli.register_custom_action("ProjectMilestone")
@exc.on_http_error(exc.GitlabListError)
Expand Down
21 changes: 21 additions & 0 deletions tests/functional/api/test_projects.py
Expand Up @@ -199,6 +199,27 @@ def test_project_milestones(project):
assert len(milestone.merge_requests()) == 0


def test_project_milestone_promotion(gl, group):
"""
Milestone promotion requires the project to be a child of a group (not in a user namespace)
"""
_id = uuid.uuid4().hex
data = {
"name": f"test-project-{_id}",
"namespace_id": group.id,
}
project = gl.projects.create(data)

milestone_title = "promoteme"
promoted_milestone = project.milestones.create({"title": milestone_title})
promoted_milestone.promote()

assert any(
milestone.title == milestone_title for milestone in group.milestones.list()
)


def test_project_pages_domains(gl, project):
domain = project.pagesdomains.create({"domain": "foo.domain.com"})
assert len(project.pagesdomains.list()) == 1
Expand Down

0 comments on commit 5ce3b17

Please sign in to comment.