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

feat: add sync method to force remote mirror updates#3232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
JohnVillalovos wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromjlvillal/3223
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletionsdocs/gl_objects/remote_mirrors.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,3 +36,7 @@ Update an existing remote mirror's attributes::
Delete an existing remote mirror::

mirror.delete()

Force push mirror update::

mirror.sync()
15 changes: 14 additions & 1 deletiongitlab/v4/objects/projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1233,7 +1233,20 @@ def create(self, data: dict[str, Any] | None = None, **kwargs: Any) -> ProjectFo


class ProjectRemoteMirror(ObjectDeleteMixin, SaveMixin, RESTObject):
pass
@cli.register_custom_action(cls_names="ProjectRemoteMirror")
@exc.on_http_error(exc.GitlabCreateError)
def sync(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
"""Force push mirror update.

Args:
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
path = f"{self.manager.path}/{self.encoded_id}/sync"
return self.manager.gitlab.http_post(path, **kwargs)


class ProjectRemoteMirrorManager(
Expand Down
12 changes: 12 additions & 0 deletionstests/unit/objects/test_remote_mirrors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,6 +54,12 @@ def resp_remote_mirrors():
url="http://localhost/api/v4/projects/1/remote_mirrors/1",
status=204,
)

rsps.add(
method=responses.POST,
url="http://localhost/api/v4/projects/1/remote_mirrors/1/sync",
status=204,
)
yield rsps


Expand DownExpand Up@@ -81,3 +87,9 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors):
def test_delete_project_remote_mirror(project, resp_remote_mirrors):
mirror = project.remote_mirrors.create({"url": "https://example.com"})
mirror.delete()


def test_sync_project_remote_mirror(project, resp_remote_mirrors):
mirror = project.remote_mirrors.create({"url": "https://example.com"})
response = mirror.sync()
assert response.status_code == 204
Loading

[8]ページ先頭

©2009-2025 Movatter.jp