Skip to content

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

License

Notifications You must be signed in to change notification settings

colinodell/pygitops

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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', '[email protected]')
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

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 93.9%
  • Shell 5.1%
  • Dockerfile 1.0%