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

Commitf3c6678

Browse files
JohnVillalovosnejch
authored andcommitted
feat: add sync method to force remote mirror updates
Add ProjectRemoteMirror.sync() method to trigger immediate push mirrorupdates.Closes:#3223
1 parentbf7a60a commitf3c6678

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

‎docs/gl_objects/remote_mirrors.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ Update an existing remote mirror's attributes::
3636
Delete an existing remote mirror::
3737

3838
mirror.delete()
39+
40+
Force push mirror update::
41+
42+
mirror.sync()

‎gitlab/v4/objects/projects.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,20 @@ def create(self, data: dict[str, Any] | None = None, **kwargs: Any) -> ProjectFo
12331233

12341234

12351235
classProjectRemoteMirror(ObjectDeleteMixin,SaveMixin,RESTObject):
1236-
pass
1236+
@cli.register_custom_action(cls_names="ProjectRemoteMirror")
1237+
@exc.on_http_error(exc.GitlabCreateError)
1238+
defsync(self,**kwargs:Any)->dict[str,Any]|requests.Response:
1239+
"""Force push mirror update.
1240+
1241+
Args:
1242+
**kwargs: Extra options to send to the server (e.g. sudo)
1243+
1244+
Raises:
1245+
GitlabAuthenticationError: If authentication is not correct
1246+
GitlabCreateError: If the server cannot perform the request
1247+
"""
1248+
path=f"{self.manager.path}/{self.encoded_id}/sync"
1249+
returnself.manager.gitlab.http_post(path,**kwargs)
12371250

12381251

12391252
classProjectRemoteMirrorManager(

‎tests/unit/objects/test_remote_mirrors.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ def resp_remote_mirrors():
5454
url="http://localhost/api/v4/projects/1/remote_mirrors/1",
5555
status=204,
5656
)
57+
58+
rsps.add(
59+
method=responses.POST,
60+
url="http://localhost/api/v4/projects/1/remote_mirrors/1/sync",
61+
status=204,
62+
)
5763
yieldrsps
5864

5965

@@ -81,3 +87,9 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors):
8187
deftest_delete_project_remote_mirror(project,resp_remote_mirrors):
8288
mirror=project.remote_mirrors.create({"url":"https://example.com"})
8389
mirror.delete()
90+
91+
92+
deftest_sync_project_remote_mirror(project,resp_remote_mirrors):
93+
mirror=project.remote_mirrors.create({"url":"https://example.com"})
94+
response=mirror.sync()
95+
assertresponse.status_code==204

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp