Loading gitlab/v4/objects/commits.py +18 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,24 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def sequence(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """Get the sequence number of the commit. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the sequence number could not be retrieved Returns: The commit's sequence number """ path = f"{self.manager.path}/{self.encoded_id}/sequence" return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def signature(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Loading tests/unit/objects/test_commits.py +23 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,23 @@ def resp_get_commit_gpg_signature(): yield rsps @pytest.fixture def resp_get_commit_sequence(): content = { "count": 1, } with responses.RequestsMock() as rsps: rsps.add( method=responses.GET, url="http://localhost/api/v4/projects/1/repository/commits/6b2257ea/sequence", json=content, content_type="application/json", status=200, ) yield rsps def test_get_commit(project, resp_commit): commit = project.commits.get("6b2257ea") assert commit.short_id == "6b2257ea" Loading Loading @@ -113,3 +130,9 @@ def test_get_commit_gpg_signature(project, resp_get_commit_gpg_signature): signature = commit.signature() assert signature["gpg_key_primary_keyid"] == "8254AAB3FBD54AC9" assert signature["verification_status"] == "verified" def test_get_commit_sequence(project, resp_get_commit_sequence): commit = project.commits.get("6b2257ea", lazy=True) sequence = commit.sequence() assert sequence["count"] == 1 Loading
gitlab/v4/objects/commits.py +18 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,24 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def sequence(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """Get the sequence number of the commit. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the sequence number could not be retrieved Returns: The commit's sequence number """ path = f"{self.manager.path}/{self.encoded_id}/sequence" return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def signature(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Loading
tests/unit/objects/test_commits.py +23 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,23 @@ def resp_get_commit_gpg_signature(): yield rsps @pytest.fixture def resp_get_commit_sequence(): content = { "count": 1, } with responses.RequestsMock() as rsps: rsps.add( method=responses.GET, url="http://localhost/api/v4/projects/1/repository/commits/6b2257ea/sequence", json=content, content_type="application/json", status=200, ) yield rsps def test_get_commit(project, resp_commit): commit = project.commits.get("6b2257ea") assert commit.short_id == "6b2257ea" Loading Loading @@ -113,3 +130,9 @@ def test_get_commit_gpg_signature(project, resp_get_commit_gpg_signature): signature = commit.signature() assert signature["gpg_key_primary_keyid"] == "8254AAB3FBD54AC9" assert signature["verification_status"] == "verified" def test_get_commit_sequence(project, resp_get_commit_sequence): commit = project.commits.get("6b2257ea", lazy=True) sequence = commit.sequence() assert sequence["count"] == 1