Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Add program to generate changelog release entries #2626

Merged
merged 7 commits into from
Dec 4, 2019

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Nov 22, 2019

This Go program uses the GitHub API to automate the arduous task of creating a changelog entry for an upcoming release.

It:

  • Automatically obtains the tag of the latest release (to know from what commit to start looking for Pull Requests).
  • Identifies pull requests
  • Attempts to categorize pull requests in subsections using tags
  • Generates the list of contributors

I still need to clean the code up before it's ready to merge (e.g. there's a huge main() function)

@2opremio 2opremio force-pushed the changelog_generator branch 5 times, most recently from 7bde8ef to b5fb99a Compare November 22, 2019 16:17
@2opremio
Copy link
Contributor Author

@hiddeco I guess we could reuse this for the Helm Operator as well? Should I put it in a separate repo?

@hiddeco
Copy link
Member

hiddeco commented Nov 22, 2019

@2opremio yes, this can definitely be reused by the Helm operator. May require a slight rework of the CHANGELOG.md so that the categories match, but doing this will probably also make it easier for people familiar with both projects to work through / read the changes.

This Go program uses the GitHub API to automate the arduous task of
creating a changelog entry for an upcoming release.

It:

* Automatically obtains the tag of the latest release (to know from
  what commit to start looking for Pull Requests).
* Identifies pull requests
* Attempts to categorize pull requests in subsections using tags
* Generates the list of contributors
@2opremio 2opremio changed the title [WIP] Add program to generate changelog release entries Add program to generate changelog release entries Dec 4, 2019
@2opremio 2opremio marked this pull request as ready for review December 4, 2019 00:33
@2opremio
Copy link
Contributor Author

2opremio commented Dec 4, 2019

I decided against moving this to a new repo (it didn't feel right to create a repo just for this).

I did add flags to make it runnable to for the helm operator by just providing --gh-repo=helm-operator

prs := []*github.PullRequest{}
visitedPRs := map[int]struct{}{}
for _, commit := range commits {
commitProcessHook()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not super happy about this. It seems rather artificial. The alternative I considered is returning a channel and running asynchronously, but I think that's a bit overkill.

// Note: Unfortunately this will return all the PRs whose head branch contains the commit
// (i.e. not just the PR which incorporates the commit to the base repo).
// We deal with this by discarding duplicates.
prsForCommit, _, err := ghClient.PullRequests.ListPullRequestsWithCommit(ctx,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this on every commit is very slow (that's why I added the progress bar). As an alternative we could parse the commit messages looking for Merge messages (and messages ending with #number for rebased PRs, which don't have a Merge message). However, I deemed that to be a bit too fragile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can look for commits with more than one parent. That will catch all PR merges except those that are fast-forwards, which should be none.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will catch all PR merges except those that are fast-forwards, which should be none.

We explicitly disable that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I believe so. (But of course, that may change, you never know)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would rather not make assumptions.

Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work and does a handy task 🍍 Can we move it to a less ugly path? :-)

@2opremio
Copy link
Contributor Author

2opremio commented Dec 4, 2019

Can we move it to a less ugly path? :-)

Sure! What do you suggest?

@squaremo
Copy link
Member

squaremo commented Dec 4, 2019

Can we move it to a less ugly path? :-)

Sure! What do you suggest?

Maybe we could have:

  • internal/docs/releasing.md
  • internal/cmd/changelog/main.go

(of which, only the latter matters here)

@2opremio 2opremio merged commit 37bc2a6 into fluxcd:master Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants