8000 chore(api): turn changelog into its own manager · python-gitlab/python-gitlab@ea5d358 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea5d358

Browse files
committed
chore(api): turn changelog into its own manager
1 parent 51b6de1 commit ea5d358

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

gitlab/v4/objects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from .projects import *
5858
from .push_rules import *
5959
from .releases import *
60+
from .repositories import *
6061
from .runners import *
6162
from .services import *
6263
from .settings import *
8000

gitlab/v4/objects/projects.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747
)
4848
from .push_rules import ProjectPushRulesManager
4949
from .releases import ProjectReleaseManager
50-
from .repositories import RepositoryMixin
50+
from .repositories import (
51+
RepositoryMixin,
52+
ProjectRepositoryChangelog,
53+
ProjectRepositoryChangelogManager,
54+
)
5155
from .runners import ProjectRunnerManager
5256
from .services import ProjectServiceManager
5357
from .snippets import ProjectSnippetManager
@@ -112,6 +116,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
112116
("boards", "ProjectBoardManager"),
113117
("branches", "ProjectBranchManager"),
114118
("jobs", "ProjectJobManager"),
119+
("changelogs", "ProjectRepositoryChangelogManager"),
115120
("commits", "ProjectCommitManager"),
116121
("customattributes", "ProjectCustomAttributeManager"),
117122
("deployments", "ProjectDeploymentManager"),

gitlab/v4/objects/repositories.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
from gitlab import cli, types, utils
88
from gitlab import exceptions as exc
9+
from gitlab.base import RESTManager, RESTObject
10+
from gitlab.mixins import CreateMixin
11+
12+
__all__ = [
13+
"ProjectRepositoryChangelog",
14+
"ProjectRepositoryChangelogManager",
15+
]
916

1017

1118
class RepositoryMixin:
@@ -205,24 +212,16 @@ def delete_merged_branches(self, **kwargs):
205212
path = "/projects/%s/repository/merged_branches" % self.get_id()
206213
self.manager.gitlab.http_delete(path, **kwargs)
207214

208-
@cli.register_custom_action(
209-
"Project",
210-
("version_tag",),
211-
("from", "to", "date", "branch", "trailer", "file", "message"),
212-
)
213-
@exc.on_http_error(exc.GitlabCreateError)
214-
def changelog(self, data=None, **kwargs):
215-
"""Create a changelog entry in the repository.
216215

217-
Args:
218-
**kwargs: Extra options to send to the server (e.g. sudo)
216+
class ProjectRepositoryChangelog(RESTObject):
217+
pass
219218

220-
Raises:
221-
GitlabAuthenticationError: If authentication is not correct
222-
GitlabCreateError: If the server failed to perform the request
223-
"""
224-
path = "/projects/%s/repository/changelog" % self.get_id()
225219

226-
# This is here to avoid clashing with the CLI's `--version` flag
227-
228-
self.manager.gitlab.http_post(path, data=data, **kwargs)
220+
class ProjectRepositoryChangelogManager(CreateMixin, RESTManager):
221+
_obj_cls = ProjectRepositoryChangelog
222+
_path = "/projects/%(project_id)s/repository/changelog"
223+
_from_parent_attrs = {"project_id": "id"}
224+
_create_attrs = (
225+
("version",),
226+
("from_commit", "to_commit", "date", "branch", "trailer", "file", "message"),
227+
)

0 commit comments

Comments
 (0)
0