Skip to main content

Wrapper for low-level git logic. Useful for systems automating git operations.

Project description

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

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

pygitops-0.18.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

pygitops-0.18.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pygitops-0.18.0.tar.gz.

File metadata

  • Download URL: pygitops-0.18.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for pygitops-0.18.0.tar.gz
Algorithm Hash digest
SHA256 fe59879b970daa01616be83981e4f7910a687f223c3fa26c7b6f2b6e00ac8707
MD5 0823e171c551c2cb1f01ca5188a7d6ca
BLAKE2b-256 dd8d11e4371af43faf39354bfce79d6d57c015e915124dc001c70ce4fe39eeb3

See more details on using hashes here.

File details

Details for the file pygitops-0.18.0-py3-none-any.whl.

File metadata

  • Download URL: pygitops-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for pygitops-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a679a51056b68666da9dd711747d47a5c39cd56470afcb37a7ac2b503368c146
MD5 1a4fc75a9c163c460a65d15fd0e76914
BLAKE2b-256 eee70c607d56bbdad2fa7043ee950193dd5aabe61d6eacdfe14918ab6e7f07f2

See more details on using hashes here.

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