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.16.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

pygitops-0.16.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygitops-0.16.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pygitops-0.16.1.tar.gz
Algorithm Hash digest
SHA256 9925f3e6dc92fbe6a736cdb9458cfd66021d502fdd6f4f56a45bbfaf666b96d0
MD5 75843793ff5bc2992cf0786c716208c7
BLAKE2b-256 4f47fbc921a230ae8dac71a2f8b93db837d69b8cb7f6b16cd8fbd4d8b2468e32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygitops-0.16.1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pygitops-0.16.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09d772ec49f6ad2e8c3d366de18b17808a94b2e3735693be474ab035a87cb944
MD5 eed504a4aec7e4ac445c31ba989751b3
BLAKE2b-256 322fe49d6dce6354f4c08f2c6c4e1962b52138b9b3244d1b2dae9f74f05e2cbf

See more details on using hashes here.

Supported by

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