| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cf87226 commit 1f97be2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,24 @@ def revert( | |||
| 127 | 127 | post_data = {"branch": branch} | |
| 128 | 128 | return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) | |
| 129 | 129 | ||
| 130 | + @cli.register_custom_action(cls_names="ProjectCommit") | ||
| 131 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 132 | + def sequence(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: | ||
| 133 | + """Get the sequence number of the commit. | ||
| 134 | + | ||
| 135 | + Args: | ||
| 136 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 137 | + | ||
| 138 | + Raises: | ||
| 139 | + GitlabAuthenticationError: If authentication is not correct | ||
| 140 | + GitlabGetError: If the sequence number could not be retrieved | ||
| 141 | + | ||
| 142 | + Returns: | ||
| 143 | + The commit's sequence number | ||
| 144 | + """ | ||
| 145 | + path = f"{self.manager.path}/{self.encoded_id}/sequence" | ||
| 146 | + return self.manager.gitlab.http_get(path, **kwargs) | ||
| 147 | + | ||
| 130 | 148 | @cli.register_custom_action(cls_names="ProjectCommit") | |
| 131 | 149 | @exc.on_http_error(exc.GitlabGetError) | |
| 132 | 150 | def signature(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,6 +78,23 @@ def resp_get_commit_gpg_signature(): | |||
| 78 | 78 | yield rsps | |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | + @pytest.fixture | ||
| 82 | + def resp_get_commit_sequence(): | ||
| 83 | + content = { | ||
| 84 | + "count": 1, | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + with responses.RequestsMock() as rsps: | ||
| 88 | + rsps.add( | ||
| 89 | + method=responses.GET, | ||
| 90 | + url="http://localhost/api/v4/projects/1/repository/commits/6b2257ea/sequence", | ||
| 91 | + json=content, | ||
| 92 | + content_type="application/json", | ||
| 93 | + status=200, | ||
| 94 | + ) | ||
| 95 | + yield rsps | ||
| 96 | + | ||
| 97 | + | ||
| 81 | 98 | def test_get_commit(project, resp_commit): | |
| 82 | 99 | commit = project.commits.get("6b2257ea") | |
| 83 | 100 | assert commit.short_id == "6b2257ea" | |
@@ -113,3 +130,9 @@ def test_get_commit_gpg_signature(project, resp_get_commit_gpg_signature): | |||
| 113 | 130 | signature = commit.signature() | |
| 114 | 131 | assert signature["gpg_key_primary_keyid"] == "8254AAB3FBD54AC9" | |
| 115 | 132 | assert signature["verification_status"] == "verified" | |
| 133 | + | ||
| 134 | + | ||
| 135 | + def test_get_commit_sequence(project, resp_get_commit_sequence): | ||
| 136 | + commit = project.commits.get("6b2257ea", lazy=True) | ||
| 137 | + sequence = commit.sequence() | ||
| 138 | + assert sequence["count"] == 1 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments