Skip to main content

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:

  1. Clone the monorepo: git clone https://github.com/Nu11ified/GitForge.git
  2. Install dependencies: pip install -e sdks/python[dev]
  3. Make changes in sdks/python/
  4. Run tests: pytest sdks/python/
  5. Submit a PR to the monorepo

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitforge_py_sdk-0.1.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitforge_py_sdk-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

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

Hashes for gitforge_py_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c47cc5a1de5a57a5c37331a8d80854d436eba69679e27380ab5c49129d7fa2a7
MD5 b53c003ece9d3194d2cab423b4722a1f
BLAKE2b-256 8efcb0b95d772659958a009a62a83aecd1aa462381e5061ba5e48f9995fb10e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitforge_py_sdk-0.1.0.tar.gz:

Publisher: publish.yml on Nu11ified/gitforge-py-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gitforge_py_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gitforge_py_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6a334077a02c78e9eadf06ed5d433ac239e0b21f8cea7a354a7fd585245b9188
MD5 c292f54012d19c641b169cc5fffabdb4
BLAKE2b-256 091c3ec8ead807a6a5860014d7c7f507b300d1f83b383ff0bc0679066e09a906

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page