summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-02-28 14:45:09 +0100
committerNejc Habjan <hab.nejc@gmail.com>2021-02-28 14:45:29 +0100
commitea5d358a6b0262055b10d82d7c0e998b26bf4aaa (patch)
tree450bd2a701a00c586c1809150826c98c94936f68
parent51b6de1c26f28778d05d5a21be6e93f0a7c97b80 (diff)
downloadgitlab-feat/generate-changelog-api.tar.gz
chore(api): turn changelog into its own managerfeat/generate-changelog-api
-rw-r--r--gitlab/v4/objects/__init__.py1
-rw-r--r--gitlab/v4/objects/projects.py7
-rw-r--r--gitlab/v4/objects/repositories.py35
3 files changed, 24 insertions, 19 deletions
diff --git a/gitlab/v4/objects/__init__.py b/gitlab/v4/objects/__init__.py
index 8a2ed7c..9ca0f92 100644
--- a/gitlab/v4/objects/__init__.py
+++ b/gitlab/v4/objects/__init__.py
@@ -57,6 +57,7 @@ from .pipelines import *
from .projects import *
from .push_rules import *
from .releases import *
+from .repositories import *
from .runners import *
from .services import *
from .settings import *
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
index c187ba9..9f601dd 100644
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -47,7 +47,11 @@ from .pipelines import (
)
from .push_rules import ProjectPushRulesManager
from .releases import ProjectReleaseManager
-from .repositories import RepositoryMixin
+from .repositories import (
+ RepositoryMixin,
+ ProjectRepositoryChangelog,
+ ProjectRepositoryChangelogManager,
+)
from .runners import ProjectRunnerManager
from .services import ProjectServiceManager
from .snippets import ProjectSnippetManager
@@ -112,6 +116,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
("boards", "ProjectBoardManager"),
("branches", "ProjectBranchManager"),
("jobs", "ProjectJobManager"),
+ ("changelogs", "ProjectRepositoryChangelogManager"),
("commits", "ProjectCommitManager"),
("customattributes", "ProjectCustomAttributeManager"),
("deployments", "ProjectDeploymentManager"),
diff --git a/gitlab/v4/objects/repositories.py b/gitlab/v4/objects/repositories.py
index 0fd99a0..1b844f9 100644
--- a/gitlab/v4/objects/repositories.py
+++ b/gitlab/v4/objects/repositories.py
@@ -6,6 +6,13 @@ Currently this module only contains repository-related methods for projects.
from gitlab import cli, types, utils
from gitlab import exceptions as exc
+from gitlab.base import RESTManager, RESTObject
+from gitlab.mixins import CreateMixin
+
+__all__ = [
+ "ProjectRepositoryChangelog",
+ "ProjectRepositoryChangelogManager",
+]
class RepositoryMixin:
@@ -205,24 +212,16 @@ class RepositoryMixin:
path = "/projects/%s/repository/merged_branches" % self.get_id()
self.manager.gitlab.http_delete(path, **kwargs)
- @cli.register_custom_action(
- "Project",
- ("version_tag",),
- ("from", "to", "date", "branch", "trailer", "file", "message"),
- )
- @exc.on_http_error(exc.GitlabCreateError)
- def changelog(self, data=None, **kwargs):
- """Create a changelog entry in the repository.
- Args:
- **kwargs: Extra options to send to the server (e.g. sudo)
+class ProjectRepositoryChangelog(RESTObject):
+ pass
- Raises:
- GitlabAuthenticationError: If authentication is not correct
- GitlabCreateError: If the server failed to perform the request
- """
- path = "/projects/%s/repository/changelog" % self.get_id()
- # This is here to avoid clashing with the CLI's `--version` flag
-
- self.manager.gitlab.http_post(path, data=data, **kwargs)
+class ProjectRepositoryChangelogManager(CreateMixin, RESTManager):
+ _obj_cls = ProjectRepositoryChangelog
+ _path = "/projects/%(project_id)s/repository/changelog"
+ _from_parent_attrs = {"project_id": "id"}
+ _create_attrs = (
+ ("version",),
+ ("from_commit", "to_commit", "date", "branch", "trailer", "file", "message"),
+ )