Skip to content

A Python module for interacting with git and Github

Notifications You must be signed in to change notification settings

jayspang/pyghub

Repository files navigation

Pyghub

Pybhub is a Python library for interfacing with the Github API.

Prerequisites

  1. Python 3.* (tested on 3.6 and 3.9) with pip.
  2. Windows (tested on Windows 11)
  3. Linux (tested on Ubuntu via WSL)

Installation

Use virtualenv. Optional, but recommended:

pip install virtualenv
python -m virtualenv pyghub
pyghub\Scripts\activate.bat  # `source ./pyghub/bin/activate` for Linux

Then...

pip install -r requirements.txt

set GH_TOKEN=<github personal access token>
python -m pyghub.cli get_repo -o Microsoft -r Terminal

Usage

From the Command Line:

To invoke Pyghub directly from a command line, see CLI.md.

As a Python Module

from pyghub.providers.github import Github
from pyghub.providers.git import Git

# Get Repo information for https://github.com/microsoft/terminal
gh = Github("api_key")
info = gh.get_repo("microsoft", "terminal")

# Clone the same repo to c:\git\terminal
g = Git()
g.clone_repo("https://github.com/microsoft/terminal", "c:\\git\\terminal")

# Pull, push
g.pull("c:\\git\\terminal", "origin", "main")
g.push("https://username:[email protected]/microsoft/terminal", "origin", "main") # note the credentials required for pushing)

Testing

#  Install dev dependencies
pip install -r dev-requirements.txt

#  Linting
python -m pylint pyghub

#  Unit tests (with code coverage)
python -m pytest --cov

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

A Python module for interacting with git and Github

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages