aedev.project_manager.codeberg
helpers to access codeberg.org via its V1 API
Codeberg is based on Forgejo (a fork of Gitea) and its API (documented at `https://codeberg.org/api/swagger`__).
this module is a first start, currently only to allow an initial push of a repo to codeberg.org, used as 2nd mirror. (similar to GitHub, also not allowing initial pushes of a new repository). the plan is to move all my repositories from GitLab to Codeberg (and then using GitLab as mirror).
created this module because the Python libraries pygitea (https://github.com/jo-nas/pygitea and https://github.com/h44z/pygitea) were in 2026 no longer maintained (since ~2019).
- another api endpoint example to determine the repo url:
url = f’https://codeberg.org/api/v1/repos/{user_or_org_name}/{repo_name}’ response = requests.get(url, headers={“Authorization”: f”token {token}”, “Accept”: “application/json”}, timeout=10) if response.status_code == 200:
return response.json()[‘clone_url’]
Functions
|
check if the repository exists for the specified user or organisation/group and create it if it doesn't. |
|
wait until the initial post/upload got finished to set the main/default branch. |
- class _RequestsKwargs[source]
Bases:
TypedDicttype of the used arguments of the requests package methods (get/patch/post/..).
- __optional_keys__ = frozenset({'headers', 'timeout'})
- __orig_bases__ = (<function TypedDict>,)
- __required_keys__ = frozenset({})
- __total__ = False
- _headers(token)[source]
compile the standard header fields to be sent to codeberg (with authentication token).
- ensure_repo(user_or_group_name, repo_name, token, desc='', private=False)[source]
check if the repository exists for the specified user or organisation/group and create it if it doesn’t.
- Parameters:
- Return type:
- Returns:
error message if repo is not accessible or could not be created, else empty string.