-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(github)!: support integration with GitHub repos #363
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
I like the idea of this being available. I've wanted contributor and PR callouts in changelogs before and not having them has kept me manually writing changelogs for some projects. Have you looked into testing whether If the features are not used if not configured my thought would be that it doesn't need gating, but then again for use in CI sometimes it's nice to be able to compile as trimmed down a binary as possible for the specific job at hand. |
ab2cef9
to
41801dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I noticed my comments added a few days ago are still pending. I'm submitting them now.)
Great feature! I added several comments that I found with a quick look.
Hey @alerque
Just tried that and At this point I start to doubt if I'm doing things efficiently because it takes around 10 seconds to complete the both I need a Rust guru to tell me if I'm properly parallelizing the requests or give me some feedback on this 💀 |
Makes sense to not add external dependencies if it doesn't actually gain you anything functionally or performance wise. |
I added the documentation: https://github.com/orhun/git-cliff/blob/feat/github_integration/website/docs/integration/github.md |
Off topic of this PR but on the topic of conventional commits and generated changelogs: my understanding of |
Yes, the changes that are in this PR is only scoped this feature. I think I'm going to squash the commits with a message such as "feat!: add github integration" or something. |
alright, here we go |
Resolves #119 #132 #112 #12
Description
This PR adds GitHub integration to
git-cliff
. The basic goal is to support generating the same changelog as the built-in GitHub changelog generator (with PR links and contributors). This means that we need to query the GitHub API for certain information and incorporate them in the changelog context.Usage
There is a new section in the config file for setting the GitHub remote:
These values are also passed to the template (via
additional_context
param ofChangelog::render
function):There are new values in the changelog context which you can use to add GitHub usernames / pull request numbers to the changelog:
Also, there is a new variable for contributors (
github.contributors
):One cool thing, no network requests are made if no GitHub-related variables are used in the template.
Example
cargo run -- --unreleased --config examples/github.toml
Implementation
There seems to be 2 ways of interacting with GitHub programmatically:
I'm using the REST API for the current implementation and I'm fetching all the commits and pull requests. This sounds suboptimal but unfortunately we need all the commits to generate the required release context. For example:
git cliff -u
: only generates the changelog for the unreleased changes. If we want to have a section there as "first contributors" then we need the whole commit/PR history to check if the user has contributed before. Unfortunately GitHub contributors API does not give us the SHA1 of the commits that belong to the contributors so I'm using the pull requests API.On top of that, there is pagination (max 100 entries in a page) so we need to send multiple requests to fetch all the history.
TL;DR: This is bad and it vastly slows down the changelog generation. But I don't know how to improve it. I have experimented with the GraphQL API but it also has pagination although you can filter stuff before hand. (also it requires a token at all times as mentioned before)
Ping top contributors @MarcoIeni @kenji-miyake @joshka @alerque for opinions/discussion.
TODO List
github
feature (?)github.toml
: same format as GitHub--github-repo
--github-token