ghapi

Python wrapper for the GitHub API

APACHE-2.0 License

Downloads
1.1K
Stars
3
ghapi - v0.3.1: Patch for the diff parsing of Pull Requests Latest Release

Published by frgfm over 1 year ago

This minor release fixes the parsing of PR diffs.

What's Changed

Bug Fixes 🐛

Improvements

Full Changelog: https://github.com/frgfm/ghapi/compare/v0.3.0...v0.3.1

ghapi - v0.3.0: New support of content reading & file listing

Published by frgfm over 1 year ago

This release adds support of several Github API features for content reading/downloading and more advanced PR diff parsing.

Highlights

🔥 Additional support of features

This release comes with 3 new features:

  • repo content fetching
  • PR file diff listing
  • repo archive download
from ghapi.pulls import Repository, PullRequest

repo = Repository("frgfm", "ghapi")
# Get the bytes of each file content
content = repo.get_content()
# Get the download link for the archive
archive_url = repo.download_archive("main")
# Fetch the diff
pr = PullRequest(repo, 15)
file_list = pr.list_files()

Breaking changes

Nothing to report 🥳

What's Changed

New Features 🚀

Improvements

Full Changelog: https://github.com/frgfm/ghapi/compare/v0.2.0...v0.3.0

ghapi - v0.2.0: New support of GH features and rework of review submission

Published by frgfm almost 2 years ago

This release adds support of several Github API features and refactors review submissions.

Highlights

🔍 Parsing PR diff

The PR diff parser was a bit rough in v0.1.0 so a few efforts were put in to provide a better interface. The following snippet:

from ghapi.pulls import Repository, PullRequest

pr = PullRequest(Repository("frgfm", "ghapi"), 15)
# Get the PR information
pr.get_diff()

used to yield

{'README.md': [('@@ -99,7 +99,7 @@ print("\\n".join(full_diff["torchcam/methods/gradient.py"][0]))',
   ' \n ## Setup\n \n-Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install ghapi_client.\n+Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install `ghapi`.\n \n ### Developer installation\n \n'),
  ('@@ -119,7 +119,7 @@ The full package documentation is available [here](https://frgfm.github.io/ghapi',
   ' \n ## Contributing\n \n-Feeling like extending the range of possibilities of CAM? Or perhaps submitting a paper implementation? Any sort of contribution is greatly appreciated!\n+Feeling like extending the range of supported API feature? Or perhaps submitting a new feature idea? Any sort of contribution is greatly appreciated!\n \n You can find a short guide in [`CONTRIBUTING`](CONTRIBUTING.md) to help grow this project!\n \n')]}

and now yields

{'README.md': [{'start': {'left': 102, 'right': 102},
   'end': {'left': 102, 'right': 102},
   'text': '-Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install ghapi_client.\n+Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install `ghapi`.'},
  {'start': {'left': 122, 'right': 122},
   'end': {'left': 122, 'right': 122},
   'text': '-Feeling like extending the range of possibilities of CAM? Or perhaps submitting a paper implementation? Any sort of contribution is greatly appreciated!\n+Feeling like extending the range of supported API feature? Or perhaps submitting a new feature idea? Any sort of contribution is greatly appreciated!'}]}

🎁 Enter Search, Repository, User

The support of GitHub API features has been significantly extended in this release:

  • search repos and users
  • fetch information from users or list their repositories
  • fetch information from repositories or list their pull requests

Breaking changes

Review submission

The worflow of review submission has changed from:

from ghapi import Repository, PullRequest, Review
pr = PullRequest(Repository("owner-login", "awesome-repo"), 1)
pr.conn.set_token("MY_DUMMY_TOKEN")
review = Review(pr)
review.stage_comment("README.md", "This is weird!", 9)
review.submit("Thanks for the PR :pray:")

to

from ghapi import Repository, PullRequest, Review, Comment
pr = PullRequest(Repository("owner-login", "awesome-repo"), 1)
pr.conn.set_token("MY_DUMMY_TOKEN")
comment = Comment("README.md", "This is weird!", 9)
review = Review.from_comments(pr, "Thanks for the PR :pray:", [comment])

This improvement allows the user to then use the object to either fetch information or list the review comments.

What's Changed

Breaking Changes 🛠

New Features 🚀

Bug Fixes 🐛

Improvements

Full Changelog: https://github.com/frgfm/ghapi/compare/v0.1.1...v0.2.0

ghapi - v0.1.1: Fixes a bug in PR diff parsing

Published by frgfm almost 2 years ago

This patch release fixes the parsing of PR diff and updates installation instructions.

What's Changed

Bug Fixes 🐛

Improvements

Full Changelog: https://github.com/frgfm/ghapi/compare/v0.1.0...v0.1.1

ghapi - v0.1.0: GitHub reviews in Python made easy

Published by frgfm almost 2 years ago

This first release allows you to access PR information and submit PR reviews through GitHub API.

Highlights

🐍 Submit a PR review in Python

This repository is made in pure python with a minimal set of dependencies so that you can make the most of GitHub API in Python!

from ghapi.pulls import Repository, PullRequest, Review

pr = PullRequest(Repository("JohnDoe", "awesome-repo"), 1)
# Set your GitHub API token
pr.conn.set_token("MY_PERSONAL_TOKEN")
# Create & submit a review
review = Review(pr)
review.stage_comment("README.md", "Nice title! Perhaps you could add some formatting?", 1)
review.submit("Thanks for the PR!\nI left a minor comment!")

📖 Simple documentation for a simple tool

This project is no rocket science, it only wraps the GitHub API with a Python client.
Go check the documentation to start using it!

image

What's Changed

Breaking Changes 🛠

New Features 🚀

Bug Fixes 🐛

New Contributors

Full Changelog: https://github.com/frgfm/ghapi/commits/v0.1.0

Package Rankings
Top 18.02% on Pypi.org