codeberg-cli 0.4.1__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/PKG-INFO +1 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/pyproject.toml +1 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/client.py +13 -2
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/_format.py +24 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/dispatch.py +16 -5
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/run.py +12 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/runs.py +5 -2
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/workflows.py +1 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_actions.py +51 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_client.py +28 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/uv.lock +1 -1
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/.github/workflows/ci.yml +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/.github/workflows/release.yml +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/.gitignore +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/.python-version +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/Justfile +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/LICENSE +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/README.md +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/__main__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/config.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/git.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/helpers.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/actions/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/api.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/auth/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/auth/login.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/auth/logout.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/auth/status.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/auth/whoami.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/close.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/comment.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/labels/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/labels/add.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/labels/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/labels/remove.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/pin.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/reopen.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/search.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/subscribe.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/time/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/time/add.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/time/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/unpin.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/unsubscribe.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/issue/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/label/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/label/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/label/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/label/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/label/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/milestone/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/notifications.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/org/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/org/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/org/members.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/org/teams.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/org/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/check_merge.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/checkout.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/close.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/comment.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/commits.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/diff.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/files.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/merge.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/reopen.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/update.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/pr/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/upload.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/release/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/archive.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/branch/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/branch/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/branch/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/branch/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/branch/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/clone.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/add.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/commits.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/contents.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/edit.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/fork.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/forks/sync.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/forks.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/languages.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/migrate.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/search.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/star.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/stargazers.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/tag/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/tag/create.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/tag/delete.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/tag/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/topics/__init__.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/topics/list.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/topics/set.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/transfer.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/unstar.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/unwatch.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/view.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/watch.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/watchers.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/user.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_api.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_auth.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_config.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_git.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_issue.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_pr.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_release.py +0 -0
- {codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/tests/test_repo.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codeberg-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A Forgejo CLI — works with Codeberg and any Forgejo instance
|
|
5
5
|
Project-URL: Homepage, https://codeberg.org/ThatXliner/codeberg-cli
|
|
6
6
|
Project-URL: Repository, https://codeberg.org/ThatXliner/codeberg-cli
|
|
@@ -16,6 +16,10 @@ _VERBS = {
|
|
|
16
16
|
class ClientError(RuntimeError):
|
|
17
17
|
"""Raised when the API returns a non-2xx status."""
|
|
18
18
|
|
|
19
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
20
|
+
super().__init__(message)
|
|
21
|
+
self.status_code = status_code
|
|
22
|
+
|
|
19
23
|
|
|
20
24
|
def _response_error_message(response: httpx.Response) -> str:
|
|
21
25
|
if not response.text:
|
|
@@ -52,7 +56,12 @@ class Client:
|
|
|
52
56
|
raw = raw.rstrip("/")
|
|
53
57
|
if not raw.endswith("/api/v1"):
|
|
54
58
|
raw += "/api/v1"
|
|
55
|
-
self._client = httpx.Client(
|
|
59
|
+
self._client = httpx.Client(
|
|
60
|
+
base_url=raw,
|
|
61
|
+
headers=headers,
|
|
62
|
+
timeout=30.0,
|
|
63
|
+
follow_redirects=True,
|
|
64
|
+
)
|
|
56
65
|
|
|
57
66
|
@property
|
|
58
67
|
def base_url(self) -> str:
|
|
@@ -99,7 +108,9 @@ class Client:
|
|
|
99
108
|
response = self._client.request(method, path, **kwargs)
|
|
100
109
|
if not response.is_success:
|
|
101
110
|
msg = _response_error_message(response)
|
|
102
|
-
raise ClientError(
|
|
111
|
+
raise ClientError(
|
|
112
|
+
f"{response.status_code} {msg}", status_code=response.status_code
|
|
113
|
+
)
|
|
103
114
|
if response.status_code == 204:
|
|
104
115
|
return None
|
|
105
116
|
return response.json()
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, Callable, TypeVar
|
|
2
|
+
|
|
3
|
+
from codeberg_cli.client import ClientError
|
|
4
|
+
from xclif.errors import UsageError
|
|
5
|
+
|
|
6
|
+
T = TypeVar("T")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def actions_request(repo: str, call: Callable[[], T]) -> T:
|
|
10
|
+
"""Run an Actions API *call*, turning a 404 into a clear message.
|
|
11
|
+
|
|
12
|
+
Forgejo returns 404 for Actions endpoints when Actions is not enabled on
|
|
13
|
+
the repository (or the repo does not exist), which is otherwise surfaced as
|
|
14
|
+
an opaque ``404 The target couldn't be found.`` traceback.
|
|
15
|
+
"""
|
|
16
|
+
try:
|
|
17
|
+
return call()
|
|
18
|
+
except ClientError as exc:
|
|
19
|
+
if exc.status_code == 404:
|
|
20
|
+
raise UsageError(
|
|
21
|
+
f"No Actions found for {repo}.",
|
|
22
|
+
hint="Actions may be disabled for this repository, or the repository may not exist.",
|
|
23
|
+
) from exc
|
|
24
|
+
raise
|
|
2
25
|
|
|
3
26
|
|
|
4
27
|
def _first(run: dict[str, Any], *keys: str, default: str = "") -> Any:
|
|
@@ -23,9 +23,20 @@ def _(
|
|
|
23
23
|
return 1
|
|
24
24
|
repo = inferred
|
|
25
25
|
|
|
26
|
-
client
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
from codeberg_cli.client import ClientError
|
|
27
|
+
from xclif.errors import UsageError
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
client.post(
|
|
31
|
+
f"/repos/{repo}/actions/workflows/{workflow}/dispatches",
|
|
32
|
+
data={"ref": ref},
|
|
33
|
+
action="Dispatching workflow",
|
|
34
|
+
)
|
|
35
|
+
except ClientError as exc:
|
|
36
|
+
if exc.status_code == 404:
|
|
37
|
+
raise UsageError(
|
|
38
|
+
f"No workflow {workflow!r} found in {repo}.",
|
|
39
|
+
hint="List workflows with 'cb actions workflows', or Actions may be disabled for this repository.",
|
|
40
|
+
) from exc
|
|
41
|
+
raise
|
|
31
42
|
rich.print(f"[green]Dispatched {workflow} on {ref} in {repo}.[/green]")
|
|
@@ -24,7 +24,18 @@ def _(
|
|
|
24
24
|
return 1
|
|
25
25
|
repo = inferred
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
from codeberg_cli.client import ClientError
|
|
28
|
+
from xclif.errors import UsageError
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
run = client.get(f"/repos/{repo}/actions/runs/{run_id}")
|
|
32
|
+
except ClientError as exc:
|
|
33
|
+
if exc.status_code == 404:
|
|
34
|
+
raise UsageError(
|
|
35
|
+
f"No run #{run_id} found in {repo}.",
|
|
36
|
+
hint="Check the run ID with 'cb actions runs', or Actions may be disabled for this repository.",
|
|
37
|
+
) from exc
|
|
38
|
+
raise
|
|
28
39
|
|
|
29
40
|
if is_json_mode():
|
|
30
41
|
output(run)
|
|
@@ -6,7 +6,7 @@ from codeberg_cli.git import infer_repo
|
|
|
6
6
|
from codeberg_cli.helpers import print_table, require_client
|
|
7
7
|
from xclif import Option, command
|
|
8
8
|
|
|
9
|
-
from codeberg_cli.routes.actions._format import list_runs, normalize_run
|
|
9
|
+
from codeberg_cli.routes.actions._format import actions_request, list_runs, normalize_run
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@command("runs")
|
|
@@ -24,7 +24,10 @@ def _(
|
|
|
24
24
|
return 1
|
|
25
25
|
repo = inferred
|
|
26
26
|
|
|
27
|
-
response =
|
|
27
|
+
response = actions_request(
|
|
28
|
+
repo,
|
|
29
|
+
lambda: client.get(f"/repos/{repo}/actions/runs", params={"limit": limit, "page": 1}),
|
|
30
|
+
)
|
|
28
31
|
runs = list_runs(response)
|
|
29
32
|
|
|
30
33
|
if not runs:
|
|
@@ -143,3 +143,54 @@ def test_actions_workflows_handles_missing_workflow_dir(httpx_mock, capsys, tmp_
|
|
|
143
143
|
cmd.execute(["--repo", "owner/repo"])
|
|
144
144
|
captured = capsys.readouterr()
|
|
145
145
|
assert "No workflows in owner/repo." in captured.out
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def test_actions_runs_404_raises_clear_error(httpx_mock, capsys, tmp_path, monkeypatch):
|
|
149
|
+
"""A 404 (Actions disabled) becomes a clean message, not a traceback."""
|
|
150
|
+
_login(monkeypatch, tmp_path)
|
|
151
|
+
httpx_mock.add_response(
|
|
152
|
+
url="https://codeberg.org/api/v1/repos/owner/repo/actions/runs?limit=20&page=1",
|
|
153
|
+
status_code=404,
|
|
154
|
+
json={"message": "The target couldn't be found."},
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
from codeberg_cli.routes.actions.runs import _ as cmd
|
|
158
|
+
|
|
159
|
+
rc = cmd.execute(["--repo", "owner/repo"])
|
|
160
|
+
assert rc == 2
|
|
161
|
+
captured = capsys.readouterr()
|
|
162
|
+
assert "No Actions found for owner/repo." in captured.err
|
|
163
|
+
assert "Actions may be disabled" in captured.err
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def test_actions_run_404_raises_clear_error(httpx_mock, capsys, tmp_path, monkeypatch):
|
|
167
|
+
_login(monkeypatch, tmp_path)
|
|
168
|
+
httpx_mock.add_response(
|
|
169
|
+
url="https://codeberg.org/api/v1/repos/owner/repo/actions/runs/999",
|
|
170
|
+
status_code=404,
|
|
171
|
+
json={"message": "The target couldn't be found."},
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
from codeberg_cli.routes.actions.run import _ as cmd
|
|
175
|
+
|
|
176
|
+
rc = cmd.execute(["999", "--repo", "owner/repo"])
|
|
177
|
+
assert rc == 2
|
|
178
|
+
captured = capsys.readouterr()
|
|
179
|
+
assert "No run #999 found in owner/repo." in captured.err
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_actions_dispatch_404_raises_clear_error(httpx_mock, capsys, tmp_path, monkeypatch):
|
|
183
|
+
_login(monkeypatch, tmp_path)
|
|
184
|
+
httpx_mock.add_response(
|
|
185
|
+
url="https://codeberg.org/api/v1/repos/owner/repo/actions/workflows/ci.yml/dispatches",
|
|
186
|
+
status_code=404,
|
|
187
|
+
json={"message": "The target couldn't be found."},
|
|
188
|
+
method="POST",
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
from codeberg_cli.routes.actions.dispatch import _ as cmd
|
|
192
|
+
|
|
193
|
+
rc = cmd.execute(["ci.yml", "--repo", "owner/repo"])
|
|
194
|
+
assert rc == 2
|
|
195
|
+
captured = capsys.readouterr()
|
|
196
|
+
assert "No workflow 'ci.yml' found in owner/repo." in captured.err
|
|
@@ -49,6 +49,34 @@ def test_client_error_with_non_json_body(httpx_mock):
|
|
|
49
49
|
assert str(exc.value) == "502 Bad Gateway"
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def test_client_error_exposes_status_code(httpx_mock):
|
|
53
|
+
httpx_mock.add_response(
|
|
54
|
+
url="https://codeberg.org/api/v1/user",
|
|
55
|
+
status_code=404,
|
|
56
|
+
json={"message": "not found"},
|
|
57
|
+
)
|
|
58
|
+
client = Client(token="t")
|
|
59
|
+
with pytest.raises(ClientError) as exc:
|
|
60
|
+
client.get("/user")
|
|
61
|
+
assert exc.value.status_code == 404
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_client_follows_redirects(httpx_mock):
|
|
65
|
+
"""A 301 (e.g. a renamed repo) is followed to the final location."""
|
|
66
|
+
httpx_mock.add_response(
|
|
67
|
+
url="https://codeberg.org/api/v1/repos/owner/old-name",
|
|
68
|
+
status_code=301,
|
|
69
|
+
headers={"Location": "https://codeberg.org/api/v1/repos/owner/new-name"},
|
|
70
|
+
)
|
|
71
|
+
httpx_mock.add_response(
|
|
72
|
+
url="https://codeberg.org/api/v1/repos/owner/new-name",
|
|
73
|
+
json={"full_name": "owner/new-name"},
|
|
74
|
+
)
|
|
75
|
+
client = Client(token="t")
|
|
76
|
+
result = client.get("/repos/owner/old-name")
|
|
77
|
+
assert result == {"full_name": "owner/new-name"}
|
|
78
|
+
|
|
79
|
+
|
|
52
80
|
def test_client_no_auth(httpx_mock):
|
|
53
81
|
"""Client without token can still be created."""
|
|
54
82
|
httpx_mock.add_response(url="https://codeberg.org/api/v1/version", json={"version": "1.22"})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{codeberg_cli-0.4.1 → codeberg_cli-0.4.2}/src/codeberg_cli/routes/repo/collaborator/delete.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|