Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wayfair-incubator/pygitops
Wrapper for low-level git logic. Useful for systems automating git operations.
https://github.com/wayfair-incubator/pygitops
git git-wrapper hacktoberfest python
Last synced: about 5 hours ago
JSON representation
Wrapper for low-level git logic. Useful for systems automating git operations.
- Host: GitHub
- URL: https://github.com/wayfair-incubator/pygitops
- Owner: wayfair-incubator
- License: mit
- Created: 2020-12-10T15:21:12.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T23:47:35.000Z (7 days ago)
- Last Synced: 2024-11-01T00:25:39.116Z (7 days ago)
- Topics: git, git-wrapper, hacktoberfest, python
- Language: Python
- Homepage: https://wayfair-incubator.github.io/pygitops/
- Size: 1.5 MB
- Stars: 17
- Watchers: 4
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# pygitops
[![CI pipeline status](https://github.com/wayfair-incubator/pygitops/workflows/CI/badge.svg?branch=main)][ci]
[![PyPI](https://img.shields.io/pypi/v/pygitops)][pypi]
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pygitops)][pypi]
[![codecov](https://codecov.io/gh/wayfair-incubator/pygitops/branch/main/graph/badge.svg)][codecov]
[![Checked with mypy](https://img.shields.io/badge/mypy-checked-blue)][mypy-home]
[![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)][black-home]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:
```python
from pathlib import Pathfrom pygitops.operations import feature_branch, stage_commit_push_changes, get_updated_repo, build_github_repo_url
from git import Actor, Reporepo_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][pygitops-docs]
[ci]: https://github.com/wayfair-incubator/pygitops/actions
[pypi]: https://pypi.org/project/pygitops/
[codecov]: https://codecov.io/gh/wayfair-incubator/pygitops
[mypy-home]: http://mypy-lang.org/
[black-home]: https://github.com/psf/black
[pygitops-docs]: https://wayfair-incubator.github.io/pygitops/