Aggregate labels from merged pull requests
@onk @motemen
This is a revival of #56 originally done by @ohbarye, who kindly allowed me to take over the work. The only change I made is changing the config name from aggregate_labels to aggregate-labels because git config returns an error when the config name contains underscores.
Issue
Closes #54
Changes
As described in #54, this change adds a feature to add labels assigned to merged pull requests.
- Add
pr-release.aggregate-labelsconfig (orGIT_RELEASE_PR_AGGREGATE_LABELSenvironment variable). It accepts a boolean-ish value, "true" or anything. Only when it is "true",git-release-praggregates labels from merged pull requests. - When
pr-release.labelsis given at the same time, merge them. For example, whenpr-release.labels=foo,barand aggregated labels are "baz", labels would be ["foo", "bar", "baz"].
Testing
Confirmed git-pr-release with this change created a release pull request with a label assigned to a merged pull request.
> DEBUG=true GIT_PR_RELEASE_AGGREGATE_LABELS=true GIT_PR_RELEASE_BRANCH_PRODUCTION=production GIT_PR_RELEASE_BRANCH_STAGING=staging bundle exec ruby ./exe/git-pr-release
To use retry middleware with Faraday v2.0+, install `faraday-retry` gem
Executing `git config remote.origin.url`
Executing `git config -f .git-pr-release pr-release.template`
Executing `git config pr-release.template`
Executing `git config -f .git-pr-release pr-release.labels`
Executing `git config pr-release.labels`
Repository: masaru-iritani/git-pr-release
Production branch: production
Staging branch: staging
Template path:
Labels: [] + labels on merged PRs
Aggregate Labels: true
Executing `git rev-parse --is-shallow-repository`
Executing `git remote update origin`
Executing `git log --merges --pretty=format:%P origin/production..origin/staging`
Executing `git ls-remote origin refs/pull/*/head`
Executing `git merge-base 7b52c76689f00bef5c77950534ad11a17908c2de origin/production`
Executing `git config -f .git-pr-release pr-release.token`
Executing `git config pr-release.token`
To be released: #1 Update README.md
Searching for existing release pull requests...
Executing `git config remote.origin.url`
Executing `git config -f .git-pr-release pr-release.mention`
Executing `git config pr-release.mention`
diff: #<Diff::LCS::ContextChange: ["+", [0, nil], [0, "- [ ] #1 @masaru-iritani"]]>
Use line as is: - [ ] #1 @masaru-iritani
Pull request body:
- [ ] #1 @masaru-iritani
Updated pull request: https://github.com/masaru-iritani/git-pr-release/pull/2
Review Points
- Is
aggregate-labelsthe best name among other ideas such asreuse-labelsandsummarize-labels, etc.? - Should
aggregate-labelsbe given as a command line argument, not environment variable orgit config, like other boolean values such as--dry-runand--no-fecth? (It depends on this gem's command line design.)
@onk Thank you for taking a look into this! I'd like to know if there are any outstanding concerns or areas for improvement necessary for moving this forward. Your feedback would be greatly appreciated. Looking forward to your response!