Skip to content
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

Allow adding the URL of the PR to the release notes #582

Merged
merged 4 commits into from Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Expand Up @@ -169,12 +169,13 @@ If a pull requests is found with the label `major`/`minor`/`patch`, the correspo

You can use any of the following variables in `change-template`:

| Variable | Description |
| --------- | ----------------------------------------------------------- |
| `$NUMBER` | The number of the pull request, e.g. `42`. |
| `$TITLE` | The title of the pull request, e.g. `Add alien technology`. |
| `$AUTHOR` | The pull request author’s username, e.g. `gracehopper`. |
| `$BODY` | The body of the pull request e.g. `Fixed spelling mistake`. |
| Variable | Description |
| --------- | --------------------------------------------------------------------------- |
| `$NUMBER` | The number of the pull request, e.g. `42`. |
| `$TITLE` | The title of the pull request, e.g. `Add alien technology`. |
| `$AUTHOR` | The pull request author’s username, e.g. `gracehopper`. |
| `$BODY` | The body of the pull request e.g. `Fixed spelling mistake`. |
| `$URL` | The URL of the pull request e.g. `https://github.com/octocat/repo/pull/42`. |

## References

Expand Down
1 change: 1 addition & 0 deletions bin/generate-fixtures.js
Expand Up @@ -52,6 +52,7 @@ repos.forEach((repo) => {
name: REPO_NAME,
ref: repo.branch,
withPullRequestBody: true,
withPullRequestURL: true,
},
}),
}
Expand Down
3 changes: 3 additions & 0 deletions lib/commits.js
Expand Up @@ -8,6 +8,7 @@ module.exports.findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
$owner: String!
$ref: String!
$withPullRequestBody: Boolean!
$withPullRequestURL: Boolean!
$since: GitTimestamp
$after: String
) {
Expand Down Expand Up @@ -35,6 +36,7 @@ module.exports.findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
nodes {
title
number
url @include(if: $withPullRequestURL)
body @include(if: $withPullRequestBody)
author {
login
Expand Down Expand Up @@ -73,6 +75,7 @@ module.exports.findCommitsWithAssociatedPullRequests = async ({
owner,
ref,
withPullRequestBody: config['change-template'].includes('$BODY'),
withPullRequestURL: config['change-template'].includes('$URL'),
}
const dataPath = ['repository', 'ref', 'target', 'history']
const repoNameWithOwner = `${owner}/${repo}`
Expand Down
1 change: 1 addition & 0 deletions lib/releases.js
Expand Up @@ -163,6 +163,7 @@ const generateChangeLog = (mergedPullRequests, config) => {
$NUMBER: pullRequest.number,
$AUTHOR: pullRequest.author ? pullRequest.author.login : 'ghost',
$BODY: pullRequest.body,
$URL: pullRequest.url,
})
)
.join('\n')
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/__generated__/graphql-commits-forking.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/fixtures/__generated__/graphql-commits-merge-commit.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.