livery.forge._gitea¶
livery.forge._gitea ¶
The Gitea backend: livery.forge.Forge over Gitea's REST v1 API.
Server floor: the 1.28 line, the first with workflow-run cancellation. Every other operation works on earlier servers; livery.forge.Checks.cancel_run probes the version once and raises livery.forge.Unsupported naming it when the server predates the endpoint.
Construction and the token rule: livery.forge.GiteaForge.connect
resolves the server once, an explicit url beating the configured
GITEA_URL, and reads GITEA_TOKEN unless a token is passed. The
token belongs to the configured host and no other:
livery.forge.gitea_is_configured_host is the test to apply before
constructing a client for a checkout's remote, and a foreign host is
read anonymously (token="") instead of being sent a token it never
issued.
Classes:
| Name | Description |
|---|---|
GiteaForge |
One Gitea server, spoken to through livery.forge.Forge's verbs. |
Functions:
| Name | Description |
|---|---|
gitea_configured_host |
The host |
gitea_is_configured_host |
Whether host is the server this environment holds a token for. |
Attributes:
| Name | Type | Description |
|---|---|---|
CANCEL_FLOOR |
|
GiteaForge ¶
One Gitea server, spoken to through livery.forge.Forge's verbs.
Build with livery.forge.GiteaForge.connect; the constructor takes the resolved values and applies no environment fallbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_base
|
str
|
The API root, |
required |
token
|
str
|
The token sent on every request; empty reads anonymously. |
required |
opener
|
Opener | None
|
The network seam; the redirect-refusing default when omitted. |
None
|
Bind the client to api_base with token.
Methods:
| Name | Description |
|---|---|
connect |
The server, resolved once, never inferred from ambient state. |
whoami |
The authenticated user's login name ( |
server_version |
The server's version string ( |
registry_url |
Gitea hosts all three: its package registry serves them. |
supports |
Gitea offers every named capability. |
repository |
The view onto one repository. Cheap, no network. |
members |
The org's member logins; a user namespace is its one login. |
teams |
The org's team names; a user namespace has none. |
codeowners |
Gitea's dialect: |
user_url |
The address of login's profile; nothing on the wire. |
create_repo |
Create the repository under an org or the token's own user. |
get_repo |
The repository's settings, or None when it does not exist. |
delete_repo |
Delete the repository; one already gone is success. |
Attributes:
| Name | Type | Description |
|---|---|---|
token |
str
|
The credential this connection authenticates with; empty when anonymous. |
Source code in packages/forge/src/livery/forge/_gitea.py
token
property
¶
token: str
The credential this connection authenticates with; empty when anonymous.
connect
classmethod
¶
connect(*, url: str = '', token: str | None = None, opener: Opener | None = None) -> GiteaForge
The server, resolved once, never inferred from ambient state.
An explicit url wins; GITEA_URL is the configured
default. token defaults to GITEA_TOKEN; a missing token
raises rather than silently reading anonymously, because an
unauthenticated write fails later and further from the cause.
tea prints no token of its own, so there is no CLI to fall
back to. Pass token="" to read a foreign or public server
anonymously on purpose.
Source code in packages/forge/src/livery/forge/_gitea.py
server_version ¶
server_version() -> str
The server's version string (GET /version), cached.
Source code in packages/forge/src/livery/forge/_gitea.py
registry_url ¶
registry_url(kind: RegistryKind, owner: str) -> str
Gitea hosts all three: its package registry serves them.
python answers the pypi registry base (its /simple
child is the read index, the base itself takes uploads);
conan the conan remote; container the image
reference prefix, which on Gitea is the web host itself.
Source code in packages/forge/src/livery/forge/_gitea.py
supports ¶
supports(capability: Capability) -> bool
Gitea offers every named capability.
Source code in packages/forge/src/livery/forge/_gitea.py
repository ¶
repository(owner: str, name: str) -> Repository
members ¶
The org's member logins; a user namespace is its one login.
Source code in packages/forge/src/livery/forge/_gitea.py
teams ¶
The org's team names; a user namespace has none.
Source code in packages/forge/src/livery/forge/_gitea.py
codeowners ¶
codeowners(entries: tuple[CodeownersEntry, ...]) -> Codeowners
Gitea's dialect: .gitea/CODEOWNERS, @owner lines.
Same shape as GitHub's; a per-path approval count is approximated repository-wide through protection.
Source code in packages/forge/src/livery/forge/_gitea.py
user_url ¶
create_repo ¶
create_repo(owner: str, name: str, *, private: bool = True, description: str = '') -> Repository
Create the repository under an org or the token's own user.
auto_init gives it the default branch the protocol
requires. Creating under a user other than the token's own is
not a thing Gitea offers and raises.
Source code in packages/forge/src/livery/forge/_gitea.py
get_repo ¶
The repository's settings, or None when it does not exist.
Source code in packages/forge/src/livery/forge/_gitea.py
delete_repo ¶
Delete the repository; one already gone is success.
Gitea deletes a repository with a long run history slowly (a loop repository with 1,400 runs outran a 30 s wait), so the request is given two minutes; the deletion completes on the server whether or not the client waits for it.
Source code in packages/forge/src/livery/forge/_gitea.py
gitea_configured_host ¶
gitea_configured_host() -> str
The host GITEA_TOKEN belongs to, from GITEA_URL, lowercased.
Empty when no server is configured. Never a checkout's remote: the point is to have something to compare a remote against.
Source code in packages/forge/src/livery/forge/_gitea.py
gitea_is_configured_host ¶
Whether host is the server this environment holds a token for.
Apply this before constructing a client for a host taken from a
checkout's remote; a foreign host is read with token="" rather
than sent a token it never issued.