Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-python-gitlab for openSUSE:Factory checked in at 2022-10-31 12:15:17 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-python-gitlab (Old) and /work/SRC/openSUSE:Factory/.python-python-gitlab.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-gitlab" Mon Oct 31 12:15:17 2022 rev:13 rq:1032447 version:3.10.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-python-gitlab/python-python-gitlab.changes 2022-10-08 01:25:50.522314568 +0200 +++ /work/SRC/openSUSE:Factory/.python-python-gitlab.new.2275/python-python-gitlab.changes 2022-10-31 12:15:19.074389756 +0100 @@ -2 +2 @@ -Thu Oct 6 22:29:41 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> +Fri Oct 28 20:36:42 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> @@ -10,0 +11,3 @@ + +------------------------------------------------------------------- +Thu Oct 6 22:29:41 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> Old: ---- python-gitlab-3.9.0.tar.gz New: ---- python-gitlab-3.10.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-python-gitlab.spec ++++++ --- /var/tmp/diff_new_pack.2NqM6L/_old 2022-10-31 12:15:19.790393117 +0100 +++ /var/tmp/diff_new_pack.2NqM6L/_new 2022-10-31 12:15:19.794393136 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-python-gitlab -Version: 3.9.0 +Version: 3.10.0 Release: 0 Summary: Python module for interacting with the GitLab API License: LGPL-3.0-only ++++++ python-gitlab-3.9.0.tar.gz -> python-gitlab-3.10.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/CHANGELOG.md new/python-gitlab-3.10.0/CHANGELOG.md --- old/python-gitlab-3.9.0/CHANGELOG.md 2022-08-28 02:41:49.000000000 +0200 +++ new/python-gitlab-3.10.0/CHANGELOG.md 2022-09-28 02:51:49.000000000 +0200 @@ -2,6 +2,15 @@ <!--next-version-placeholder--> +## v3.10.0 (2022-09-28) +### Feature +* Add reset_approvals api ([`88693ff`](https://github.com/python-gitlab/python-gitlab/commit/88693ff2d6f4eecf3c79d017df52738886e2d636)) +* Add support for deployment approval endpoint ([`9c9eeb9`](https://github.com/python-gitlab/python-gitlab/commit/9c9eeb901b1f3acd3fb0c4f24014ae2ed7c975ec)) + +### Fix +* **cli:** Add missing attributes for creating MRs ([`1714d0a`](https://github.com/python-gitlab/python-gitlab/commit/1714d0a980afdb648d203751dedf95ee95ac326e)) +* **cli:** Add missing attribute for MR changes ([`20c46a0`](https://github.com/python-gitlab/python-gitlab/commit/20c46a0572d962f405041983e38274aeb79a12e4)) + ## v3.9.0 (2022-08-28) ### Feature * Add support for merge_base API ([`dd4fbd5`](https://github.com/python-gitlab/python-gitlab/commit/dd4fbd5e43adbbc502624a8de0d30925d798dec0)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/PKG-INFO new/python-gitlab-3.10.0/PKG-INFO --- old/python-gitlab-3.9.0/PKG-INFO 2022-08-28 02:41:51.505055000 +0200 +++ new/python-gitlab-3.10.0/PKG-INFO 2022-09-28 02:51:52.170605000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: python-gitlab -Version: 3.9.0 +Version: 3.10.0 Summary: Interact with GitLab API Home-page: https://github.com/python-gitlab/python-gitlab Author: Gauvain Pocentek diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/docs/gl_objects/deployments.rst new/python-gitlab-3.10.0/docs/gl_objects/deployments.rst --- old/python-gitlab-3.9.0/docs/gl_objects/deployments.rst 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/docs/gl_objects/deployments.rst 2022-09-28 02:51:48.000000000 +0200 @@ -40,6 +40,18 @@ deployment.status = "failed" deployment.save() +Approve a deployment:: + + deployment = project.deployments.get(42) + # `status` must be either "approved" or "rejected". + deployment.approval(status="approved") + +Reject a deployment:: + + deployment = project.deployments.get(42) + # Using the optional `comment` and `represented_as` arguments + deployment.approval(status="rejected", comment="Fails CI", represented_as="security") + Merge requests associated with a deployment =========================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/docs/gl_objects/merge_requests.rst new/python-gitlab-3.10.0/docs/gl_objects/merge_requests.rst --- old/python-gitlab-3.9.0/docs/gl_objects/merge_requests.rst 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/docs/gl_objects/merge_requests.rst 2022-09-28 02:51:48.000000000 +0200 @@ -189,6 +189,10 @@ mr.rebase() +Clear all approvals of a merge request (possible with project or group access tokens only):: + + mr.reset_approvals() + Get status of a rebase for an MR:: mr = project.mergerequests.get(mr_id, include_rebase_in_progress=True) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/gitlab/_version.py new/python-gitlab-3.10.0/gitlab/_version.py --- old/python-gitlab-3.9.0/gitlab/_version.py 2022-08-28 02:41:49.000000000 +0200 +++ new/python-gitlab-3.10.0/gitlab/_version.py 2022-09-28 02:51:49.000000000 +0200 @@ -3,4 +3,4 @@ __email__ = "gauvainpocen...@gmail.com" __license__ = "LGPL3" __title__ = "python-gitlab" -__version__ = "3.9.0" +__version__ = "3.10.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/gitlab/exceptions.py new/python-gitlab-3.10.0/gitlab/exceptions.py --- old/python-gitlab-3.9.0/gitlab/exceptions.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/gitlab/exceptions.py 2022-09-28 02:51:48.000000000 +0200 @@ -205,6 +205,10 @@ pass +class GitlabMRResetApprovalError(GitlabOperationError): + pass + + class GitlabMRClosedError(GitlabOperationError): pass @@ -301,6 +305,10 @@ pass +class GitlabDeploymentApprovalError(GitlabOperationError): + pass + + # For an explanation of how these type-hints work see: # https://mypy.readthedocs.io/en/stable/generics.html#declaring-decorators # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/gitlab/v4/objects/deployments.py new/python-gitlab-3.10.0/gitlab/v4/objects/deployments.py --- old/python-gitlab-3.9.0/gitlab/v4/objects/deployments.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/gitlab/v4/objects/deployments.py 2022-09-28 02:51:48.000000000 +0200 @@ -1,5 +1,11 @@ -from typing import Any, cast, Union +""" +GitLab API: +https://docs.gitlab.com/ee/api/deployments.html +""" +from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union +from gitlab import cli +from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin from gitlab.types import RequiredOptional @@ -15,6 +21,50 @@ class ProjectDeployment(SaveMixin, RESTObject): mergerequests: ProjectDeploymentMergeRequestManager + @cli.register_custom_action( + "ProjectDeployment", + mandatory=("status",), + optional=("comment", "represented_as"), + ) + @exc.on_http_error(exc.GitlabDeploymentApprovalError) + def approval( + self, + status: str, + comment: Optional[str] = None, + represented_as: Optional[str] = None, + **kwargs: Any, + ) -> Dict[str, Any]: + """Approve or reject a blocked deployment. + + Args: + status: Either "approved" or "rejected" + comment: A comment to go with the approval + represented_as: The name of the User/Group/Role to use for the + approval, when the user belongs to multiple + approval rules. + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabMRApprovalError: If the approval failed + + Returns: + A dict containing the result. + + https://docs.gitlab.com/ee/api/deployments.html#approve-or-reject-a-blocked-deployment + """ + path = f"{self.manager.path}/{self.encoded_id}/approval" + data = {"status": status} + if comment is not None: + data["comment"] = comment + if represented_as is not None: + data["represented_as"] = represented_as + + server_data = self.manager.gitlab.http_post(path, post_data=data, **kwargs) + if TYPE_CHECKING: + assert isinstance(server_data, dict) + return server_data + class ProjectDeploymentManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTManager): _path = "/projects/{project_id}/deployments" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/gitlab/v4/objects/merge_requests.py new/python-gitlab-3.10.0/gitlab/v4/objects/merge_requests.py --- old/python-gitlab-3.9.0/gitlab/v4/objects/merge_requests.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/gitlab/v4/objects/merge_requests.py 2022-09-28 02:51:48.000000000 +0200 @@ -242,7 +242,7 @@ manager = ProjectCommitManager(self.manager.gitlab, parent=self.manager._parent) return RESTObjectList(manager, ProjectCommit, data_list) - @cli.register_custom_action("ProjectMergeRequest") + @cli.register_custom_action("ProjectMergeRequest", optional=("access_raw_diffs",)) @exc.on_http_error(exc.GitlabListError) def changes(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """List the merge request changes. @@ -328,6 +328,24 @@ return self.manager.gitlab.http_put(path, post_data=data, **kwargs) @cli.register_custom_action("ProjectMergeRequest") + @exc.on_http_error(exc.GitlabMRResetApprovalError) + def reset_approvals( + self, **kwargs: Any + ) -> Union[Dict[str, Any], requests.Response]: + """Clear all approvals of the merge request. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabMRResetApprovalError: If reset approval failed + """ + path = f"{self.manager.path}/{self.encoded_id}/reset_approvals" + data: Dict[str, Any] = {} + return self.manager.gitlab.http_put(path, post_data=data, **kwargs) + + @cli.register_custom_action("ProjectMergeRequest") @exc.on_http_error(exc.GitlabGetError) def merge_ref(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """Attempt to merge changes between source and target branches into @@ -401,15 +419,18 @@ _create_attrs = RequiredOptional( required=("source_branch", "target_branch", "title"), optional=( + "allow_collaboration", + "allow_maintainer_to_push", + "approvals_before_merge", "assignee_id", + "assignee_ids", "description", - "target_project_id", "labels", "milestone_id", "remove_source_branch", - "allow_maintainer_to_push", - "squash", "reviewer_ids", + "squash", + "target_project_id", ), ) _update_attrs = RequiredOptional( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/python_gitlab.egg-info/PKG-INFO new/python-gitlab-3.10.0/python_gitlab.egg-info/PKG-INFO --- old/python-gitlab-3.9.0/python_gitlab.egg-info/PKG-INFO 2022-08-28 02:41:51.000000000 +0200 +++ new/python-gitlab-3.10.0/python_gitlab.egg-info/PKG-INFO 2022-09-28 02:51:52.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: python-gitlab -Version: 3.9.0 +Version: 3.10.0 Summary: Interact with GitLab API Home-page: https://github.com/python-gitlab/python-gitlab Author: Gauvain Pocentek diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/requirements-lint.txt new/python-gitlab-3.10.0/requirements-lint.txt --- old/python-gitlab-3.9.0/requirements-lint.txt 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/requirements-lint.txt 2022-09-28 02:51:48.000000000 +0200 @@ -1,11 +1,11 @@ argcomplete<=2.0.0 -black==22.6.0 -commitizen==2.32.1 +black==22.8.0 +commitizen==2.32.5 flake8==5.0.4 isort==5.10.1 mypy==0.971 pylint==2.14.5 -pytest==7.1.2 +pytest==7.1.3 types-PyYAML==6.0.11 -types-requests==2.28.9 +types-requests==2.28.10 types-setuptools==64.0.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/requirements-test.txt new/python-gitlab-3.10.0/requirements-test.txt --- old/python-gitlab-3.9.0/requirements-test.txt 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/requirements-test.txt 2022-09-28 02:51:48.000000000 +0200 @@ -1,5 +1,5 @@ coverage -pytest==7.1.2 +pytest==7.1.3 pytest-console-scripts==1.3.1 pytest-cov pytest-github-actions-annotate-failures==0.1.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/tests/functional/api/test_gitlab.py new/python-gitlab-3.10.0/tests/functional/api/test_gitlab.py --- old/python-gitlab-3.9.0/tests/functional/api/test_gitlab.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/tests/functional/api/test_gitlab.py 2022-09-28 02:51:48.000000000 +0200 @@ -59,7 +59,7 @@ def test_sidekiq_queue_metrics(gl): out = gl.sidekiq.queue_metrics() assert isinstance(out, dict) - assert "pages" in out["queues"] + assert "default" in out["queues"] def test_sidekiq_process_metrics(gl): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/tests/functional/api/test_merge_requests.py new/python-gitlab-3.10.0/tests/functional/api/test_merge_requests.py --- old/python-gitlab-3.9.0/tests/functional/api/test_merge_requests.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/tests/functional/api/test_merge_requests.py 2022-09-28 02:51:48.000000000 +0200 @@ -117,6 +117,15 @@ assert mr.rebase() +def test_merge_request_reset_approvals(gitlab_url, project): + bot = project.access_tokens.create({"name": "bot", "scopes": ["api"]}) + bot_gitlab = gitlab.Gitlab(gitlab_url, private_token=bot.token) + bot_project = bot_gitlab.projects.get(project.id, lazy=True) + + mr = bot_project.mergerequests.list()[0] + assert mr.reset_approvals() + + @pytest.mark.skip(reason="flaky test") def test_merge_request_merge(project): mr = project.mergerequests.list()[0] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/tests/functional/conftest.py new/python-gitlab-3.10.0/tests/functional/conftest.py --- old/python-gitlab-3.9.0/tests/functional/conftest.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/tests/functional/conftest.py 2022-09-28 02:51:48.000000000 +0200 @@ -68,11 +68,18 @@ if is_gitlab_ee(gl): logging.info("GitLab EE detected") # NOTE(jlvillal): By default in GitLab EE it will wait 7 days before - # deleting a group. Change it to 0 days. + # deleting a group. Disable delayed group/project deletion. settings = gl.settings.get() - if settings.deletion_adjourned_period != 0: - logging.info("Setting deletion_adjourned_period to 0") - settings.deletion_adjourned_period = 0 + modified_settings = False + if settings.delayed_group_deletion: + logging.info("Setting `delayed_group_deletion` to False") + settings.delayed_group_deletion = False + modified_settings = True + if settings.delayed_project_deletion: + logging.info("Setting `delayed_project_deletion` to False") + settings.delayed_project_deletion = False + modified_settings = True + if modified_settings: settings.save() for project in gl.projects.list(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/tests/functional/fixtures/.env new/python-gitlab-3.10.0/tests/functional/fixtures/.env --- old/python-gitlab-3.9.0/tests/functional/fixtures/.env 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/tests/functional/fixtures/.env 2022-09-28 02:51:48.000000000 +0200 @@ -1,2 +1,2 @@ GITLAB_IMAGE=gitlab/gitlab-ee -GITLAB_TAG=15.2.0-ee.0 +GITLAB_TAG=15.4.0-ee.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-gitlab-3.9.0/tests/unit/objects/test_deployments.py new/python-gitlab-3.10.0/tests/unit/objects/test_deployments.py --- old/python-gitlab-3.9.0/tests/unit/objects/test_deployments.py 2022-08-28 02:41:48.000000000 +0200 +++ new/python-gitlab-3.10.0/tests/unit/objects/test_deployments.py 2022-09-28 02:51:49.000000000 +0200 @@ -6,7 +6,25 @@ @pytest.fixture -def resp_deployment(): +def resp_deployment_get(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.GET, + url="http://localhost/api/v4/projects/1/deployments/42", + json=response_get_content, + content_type="application/json", + status=200, + ) + yield rsps + + +@pytest.fixture +def deployment(project): + return project.deployments.get(42, lazy=True) + + +@pytest.fixture +def resp_deployment_create(): content = {"id": 42, "status": "success", "ref": "main"} with responses.RequestsMock() as rsps: @@ -31,7 +49,42 @@ yield rsps -def test_deployment(project, resp_deployment): +@pytest.fixture +def resp_deployment_approval(): + content = { + "user": { + "id": 100, + "username": "security-user-1", + "name": "security user-1", + "state": "active", + "avatar_url": "https://www.gravatar.com/avatar/e130fcd3a1681f41a3de69d10841afa9?s=80&d=identicon", + "web_url": "http://localhost:3000/security-user-1", + }, + "status": "approved", + "created_at": "2022-02-24T20:22:30.097Z", + "comment": "Looks good to me", + } + + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/projects/1/deployments/42/approval", + json=content, + content_type="application/json", + status=200, + ) + yield rsps + + +def test_deployment_get(project, resp_deployment_get): + deployment = project.deployments.get(42) + assert deployment.id == 42 + assert deployment.iid == 2 + assert deployment.status == "success" + assert deployment.ref == "main" + + +def test_deployment_create(project, resp_deployment_create): deployment = project.deployments.create( { "environment": "Test", @@ -48,3 +101,80 @@ deployment.status = "failed" deployment.save() assert deployment.status == "failed" + + +def test_deployment_approval(deployment, resp_deployment_approval) -> None: + result = deployment.approval(status="approved") + assert result["status"] == "approved" + assert result["comment"] == "Looks good to me" + + +response_get_content = { + "id": 42, + "iid": 2, + "ref": "main", + "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", + "created_at": "2016-08-11T11:32:35.444Z", + "updated_at": "2016-08-11T11:34:01.123Z", + "status": "success", + "user": { + "name": "Administrator", + "username": "root", + "id": 1, + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://localhost:3000/root", + }, + "environment": { + "id": 9, + "name": "production", + "external_url": "https://about.gitlab.com", + }, + "deployable": { + "id": 664, + "status": "success", + "stage": "deploy", + "name": "deploy", + "ref": "main", + "tag": False, + "coverage": None, + "created_at": "2016-08-11T11:32:24.456Z", + "started_at": None, + "finished_at": "2016-08-11T11:32:35.145Z", + "user": { + "id": 1, + "name": "Administrator", + "username": "root", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://gitlab.dev/root", + "created_at": "2015-12-21T13:14:24.077Z", + "bio": None, + "location": None, + "skype": "", + "linkedin": "", + "twitter": "", + "website_url": "", + "organization": "", + }, + "commit": { + "id": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", + "short_id": "a91957a8", + "title": "Merge branch 'rename-readme' into 'main'\r", + "author_name": "Administrator", + "author_email": "ad...@example.com", + "created_at": "2016-08-11T13:28:26.000+02:00", + "message": "Merge branch 'rename-readme' into 'main'\r\n\r\nRename README\r\n\r\n\r\n\r\nSee merge request !2", + }, + "pipeline": { + "created_at": "2016-08-11T07:43:52.143Z", + "id": 42, + "ref": "main", + "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", + "status": "success", + "updated_at": "2016-08-11T07:43:52.143Z", + "web_url": "http://gitlab.dev/root/project/pipelines/5", + }, + "runner": None, + }, +}