| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9833632 commit 4794ecc
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -115,6 +115,10 @@ Delete a project:: | |||
| 115 | 115 | # or | |
| 116 | 116 | project.delete() | |
| 117 | 117 | ||
| 118 | + Restore a project marked for deletion (Premium only):: | ||
| 119 | + | ||
| 120 | + project.restore() | ||
| 121 | + | ||
| 118 | 122 | Fork a project:: | |
| 119 | 123 | ||
| 120 | 124 | fork = project.forks.create({}) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -286,6 +286,10 @@ class GitlabRepairError(GitlabOperationError): | |||
| 286 | 286 | pass | |
| 287 | 287 | ||
| 288 | 288 | ||
| 289 | + class GitlabRestoreError(GitlabOperationError): | ||
| 290 | + pass | ||
| 291 | + | ||
| 292 | + | ||
| 289 | 293 | class GitlabRevertError(GitlabOperationError): | |
| 290 | 294 | pass | |
| 291 | 295 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -477,6 +477,21 @@ def upload( | |||
| 477 | 477 | assert isinstance(data, dict) | |
| 478 | 478 | return {"alt": data["alt"], "url": data["url"], "markdown": data["markdown"]} | |
| 479 | 479 | ||
| 480 | + @cli.register_custom_action("Project") | ||
| 481 | + @exc.on_http_error(exc.GitlabRestoreError) | ||
| 482 | + def restore(self, **kwargs: Any) -> None: | ||
| 483 | + """Restore a project marked for deletion. | ||
| 484 | + | ||
| 485 | + Args: | ||
| 486 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 487 | + | ||
| 488 | + Raises: | ||
| 489 | + GitlabAuthenticationError: If authentication is not correct | ||
| 490 | + GitlabRestoreError: If the server failed to perform the request | ||
| 491 | + """ | ||
| 492 | + path = f"/projects/{self.encoded_id}/restore" | ||
| 493 | + self.manager.gitlab.http_post(path, **kwargs) | ||
| 494 | + | ||
| 480 | 495 | @cli.register_custom_action("Project", optional=("wiki",)) | |
| 481 | 496 | @exc.on_http_error(exc.GitlabGetError) | |
| 482 | 497 | def snapshot( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,6 +504,19 @@ def resp_delete_push_rules_project(no_content): | |||
| 504 | 504 | yield rsps | |
| 505 | 505 | ||
| 506 | 506 | ||
| 507 | + @pytest.fixture | ||
| 508 | + def resp_restore_project(created_content): | ||
| 509 | + with responses.RequestsMock() as rsps: | ||
| 510 | + rsps.add( | ||
| 511 | + method=responses.POST, | ||
| 512 | + url="http://localhost/api/v4/projects/1/restore", | ||
| 513 | + json=created_content, | ||
| 514 | + content_type="application/json", | ||
| 515 | + status=201, | ||
| 516 | + ) | ||
| 517 | + yield rsps | ||
| 518 | + | ||
| 519 | + | ||
| 507 | 520 | @pytest.fixture | |
| 508 | 521 | def resp_start_pull_mirroring_project(): | |
| 509 | 522 | with responses.RequestsMock() as rsps: | |
@@ -753,6 +766,10 @@ def test_project_pull_mirror(project, resp_start_pull_mirroring_project): | |||
| 753 | 766 | project.mirror_pull() | |
| 754 | 767 | ||
| 755 | 768 | ||
| 769 | + def test_project_restore(project, resp_restore_project): | ||
| 770 | + project.restore() | ||
| 771 | + | ||
| 772 | + | ||
| 756 | 773 | def test_project_snapshot(project, resp_snapshot_project): | |
| 757 | 774 | tar_file = project.snapshot() | |
| 758 | 775 | assert isinstance(tar_file, bytes) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments