Python SDK for the GitForge REST API
Project description
gitforge
Python SDK for GitForge — Git infrastructure for developers who build on Git.
Install
pip install gitforge
Requires Python 3.10+.
Quick Start
from gitforge import GitForge
client = GitForge(
base_url="https://api.git-forge.dev",
token="gf_your_token_here",
)
# Create a repo
repo = await client.repos.create(
name="my-repo",
visibility="private",
)
# Commit files without a git client
await client.repo(repo.id).commits \
.create(
branch="main",
message="initial commit",
author_name="Your Name",
author_email="you@example.com",
) \
.add_file("README.md", "# My Project") \
.add_file("src/main.py", "print('hello')") \
.send()
# List repos
repos = await client.repos.list(limit=10)
# Search code
results = await client.search.code("def handle_push")
Resources
| Resource | Methods |
|---|---|
repos |
create, list, get, update, delete |
branches |
list, create, delete, promote |
tags |
list, create, delete |
commits |
create (builder), list, get |
files |
get_blob, get_tree |
search |
code |
tokens |
create, list, revoke |
mirrors |
list, create, sync, delete |
webhooks |
create, list, update, delete, test |
Webhook Validation
from gitforge.webhooks import validate_webhook
is_valid = validate_webhook(
payload=raw_body,
signature=request.headers["x-gitforge-signature"],
secret="your_webhook_secret",
timestamp=request.headers.get("x-gitforge-timestamp"),
tolerance=300,
)
Error Handling
from gitforge import GitForgeError
try:
await client.repos.get("nonexistent")
except GitForgeError as e:
print(e.status) # 404
print(e.code) # "NOT_FOUND"
print(e.message)
Contributing
This SDK is developed inside the GitForge monorepo at sdks/python/ and published to this repo via git subtree.
To contribute:
- Clone the monorepo:
git clone https://github.com/Nu11ified/GitForge.git - Install dependencies:
pip install -e sdks/python[dev] - Make changes in
sdks/python/ - Run tests:
pytest sdks/python/ - Submit a PR to the monorepo
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitforge_py_sdk-0.1.0.tar.gz.
File metadata
- Download URL: gitforge_py_sdk-0.1.0.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c47cc5a1de5a57a5c37331a8d80854d436eba69679e27380ab5c49129d7fa2a7
|
|
| MD5 |
b53c003ece9d3194d2cab423b4722a1f
|
|
| BLAKE2b-256 |
8efcb0b95d772659958a009a62a83aecd1aa462381e5061ba5e48f9995fb10e5
|
Provenance
The following attestation bundles were made for gitforge_py_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on Nu11ified/gitforge-py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitforge_py_sdk-0.1.0.tar.gz -
Subject digest:
c47cc5a1de5a57a5c37331a8d80854d436eba69679e27380ab5c49129d7fa2a7 - Sigstore transparency entry: 1197202738
- Sigstore integration time:
-
Permalink:
Nu11ified/gitforge-py-sdk@a807159b8bd0b909371d36fcbc33a653d584fc46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nu11ified
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a807159b8bd0b909371d36fcbc33a653d584fc46 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gitforge_py_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gitforge_py_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a334077a02c78e9eadf06ed5d433ac239e0b21f8cea7a354a7fd585245b9188
|
|
| MD5 |
c292f54012d19c641b169cc5fffabdb4
|
|
| BLAKE2b-256 |
091c3ec8ead807a6a5860014d7c7f507b300d1f83b383ff0bc0679066e09a906
|
Provenance
The following attestation bundles were made for gitforge_py_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Nu11ified/gitforge-py-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gitforge_py_sdk-0.1.0-py3-none-any.whl -
Subject digest:
6a334077a02c78e9eadf06ed5d433ac239e0b21f8cea7a354a7fd585245b9188 - Sigstore transparency entry: 1197202760
- Sigstore integration time:
-
Permalink:
Nu11ified/gitforge-py-sdk@a807159b8bd0b909371d36fcbc33a653d584fc46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Nu11ified
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a807159b8bd0b909371d36fcbc33a653d584fc46 -
Trigger Event:
push
-
Statement type: