Skip to main content

pygitops

CI pipeline status PyPI PyPI - Python Version codecov Checked with mypy Code style: black

Pygitops is a wrapper around low-level GitPython logic, that makes it very simple to do basic git operations. This system is especially useful for systems that create automated pull requests, or otherwise operate on contents of repositories locally.

For example, clone a repository, make some changes, and push those changes to a branch:

from pathlib import Path

from pygitops.operations import feature_branch, stage_commit_push_changes, get_updated_repo, build_github_repo_url
from git import Actor, Repo

repo_name = 'some-repo'
repo_namespace = 'some-namespace'
branch_name = 'new-chores'
some_actor = Actor('some-service-account', 'some-service-account@some-enterprise.com')
commit_message = 'Add list of chores'

# Build the URL for cloning the repository 
repo_url = build_github_repo_url(
    "some-service-account_name",
    "some-access-token",
    repo_namespace,
    repo_name,
    "github.com",
)

# Clone the repository to the local filesystem (updating the repo if it is already present)
repo: Repo = get_updated_repo(
    repo_url, Path("some-clone-dir" / repo_name) 
)

# Make some changes on a feature branch, commit and push the changes
with feature_branch(repo, branch_name):
    Path('some-clone-dir' / repo_name / 'chores.txt').write_text('haircut\ngroceries\ndishes')

    stage_commit_push_changes(repo, branch_name, some_actor, commit_message)

Features

  • Clone repositories to your local filesystem from any remote git repository
  • Create feature branches and add commits, without worrying about the underlying GitPython complexity

Installation

pip install pygitops

Usage

For more information, please see the pygitops docs

Release files for pygitops 0.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygitops 0.18.0
File Size Uploaded
pygitops-0.18.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygitops 0.18.0
File Interpreter ABI Platform
pygitops-0.18.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / pygitops-0.18.0.tar.gz

Download URL pygitops-0.18.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fe59879b970daa01616be83981e4f7910a687f223c3fa26c7b6f2b6e00ac8707
BLAKE2b-256 checksum
How to use checksums
dd8d11e4371af43faf39354bfce79d6d57c015e915124dc001c70ce4fe39eeb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.11

Release files / pygitops-0.18.0-py3-none-any.whl

Download URL pygitops-0.18.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a679a51056b68666da9dd711747d47a5c39cd56470afcb37a7ac2b503368c146
BLAKE2b-256 checksum
How to use checksums
eee70c607d56bbdad2fa7043ee950193dd5aabe61d6eacdfe14918ab6e7f07f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.18.0 This release

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.2

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page