| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,3 +36,7 @@ Update an existing remote mirror's attributes:: | |||
| 36 | 36 | Delete an existing remote mirror:: | |
| 37 | 37 | ||
| 38 | 38 | mirror.delete() | |
| 39 | + | ||
| 40 | + Force push mirror update:: | ||
| 41 | + | ||
| 42 | + mirror.sync() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1233,7 +1233,20 @@ def create(self, data: dict[str, Any] | None = None, **kwargs: Any) -> ProjectFo | |||
| 1233 | 1233 | ||
| 1234 | 1234 | ||
| 1235 | 1235 | class ProjectRemoteMirror(ObjectDeleteMixin, SaveMixin, RESTObject): | |
| 1236 | - pass | ||
| 1236 | + @cli.register_custom_action(cls_names="ProjectRemoteMirror") | ||
| 1237 | + @exc.on_http_error(exc.GitlabCreateError) | ||
| 1238 | + def sync(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 | + return self.manager.gitlab.http_post(path, **kwargs) | ||
| 1237 | 1250 | ||
| 1238 | 1251 | ||
| 1239 | 1252 | class ProjectRemoteMirrorManager( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,12 @@ def resp_remote_mirrors(): | |||
| 54 | 54 | url="http://localhost/api/v4/projects/1/remote_mirrors/1", | |
| 55 | 55 | status=204, | |
| 56 | 56 | ) | |
| 57 | + | ||
| 58 | + rsps.add( | ||
| 59 | + method=responses.POST, | ||
| 60 | + url="http://localhost/api/v4/projects/1/remote_mirrors/1/sync", | ||
| 61 | + status=204, | ||
| 62 | + ) | ||
| 57 | 63 | yield rsps | |
| 58 | 64 | ||
| 59 | 65 | ||
@@ -81,3 +87,9 @@ def test_update_project_remote_mirror(project, resp_remote_mirrors): | |||
| 81 | 87 | def test_delete_project_remote_mirror(project, resp_remote_mirrors): | |
| 82 | 88 | mirror = project.remote_mirrors.create({"url": "https://example.com"}) | |
| 83 | 89 | mirror.delete() | |
| 90 | + | ||
| 91 | + | ||
| 92 | + def test_sync_project_remote_mirror(project, resp_remote_mirrors): | ||
| 93 | + mirror = project.remote_mirrors.create({"url": "https://example.com"}) | ||
| 94 | + response = mirror.sync() | ||
| 95 | + assert response.status_code == 204 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments