Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1f97be2

Browse files
jyggennejch
authored andcommitted
feat(api): add support for commit sequence
1 parentcf87226 commit1f97be2

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

‎gitlab/v4/objects/commits.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ def revert(
127127
post_data= {"branch":branch}
128128
returnself.manager.gitlab.http_post(path,post_data=post_data,**kwargs)
129129

130+
@cli.register_custom_action(cls_names="ProjectCommit")
131+
@exc.on_http_error(exc.GitlabGetError)
132+
defsequence(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+
returnself.manager.gitlab.http_get(path,**kwargs)
147+
130148
@cli.register_custom_action(cls_names="ProjectCommit")
131149
@exc.on_http_error(exc.GitlabGetError)
132150
defsignature(self,**kwargs:Any)->Union[Dict[str,Any],requests.Response]:

‎tests/unit/objects/test_commits.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ def resp_get_commit_gpg_signature():
7878
yieldrsps
7979

8080

81+
@pytest.fixture
82+
defresp_get_commit_sequence():
83+
content= {
84+
"count":1,
85+
}
86+
87+
withresponses.RequestsMock()asrsps:
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+
yieldrsps
96+
97+
8198
deftest_get_commit(project,resp_commit):
8299
commit=project.commits.get("6b2257ea")
83100
assertcommit.short_id=="6b2257ea"
@@ -113,3 +130,9 @@ def test_get_commit_gpg_signature(project, resp_get_commit_gpg_signature):
113130
signature=commit.signature()
114131
assertsignature["gpg_key_primary_keyid"]=="8254AAB3FBD54AC9"
115132
assertsignature["verification_status"]=="verified"
133+
134+
135+
deftest_get_commit_sequence(project,resp_get_commit_sequence):
136+
commit=project.commits.get("6b2257ea",lazy=True)
137+
sequence=commit.sequence()
138+
assertsequence["count"]==1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp