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

Fix: Correctly mention bot accounts in release notes #1376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 22 additions & 5 deletions dist/index.js
Expand Up @@ -142591,6 +142591,8 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
body @include(if: $withPullRequestBody)
author {
login
__typename
url
}
baseRepository {
nameWithOwner
Expand Down Expand Up @@ -143027,7 +143029,13 @@ const contributorsSentence = ({ commits, pullRequests, config }) => {
pullRequest.author &&
!excludeContributors.includes(pullRequest.author.login)
) {
contributors.add(`@${pullRequest.author.login}`)
if (pullRequest.author.__typename === 'Bot') {
contributors.add(
`[${pullRequest.author.login}[bot]](${pullRequest.author.url})`
)
} else {
contributors.add(`@${pullRequest.author.login}`)
}
}
}

Expand Down Expand Up @@ -143151,17 +143159,26 @@ const generateChangeLog = (mergedPullRequests, config) => {

const pullRequestToString = (pullRequests) =>
pullRequests
.map((pullRequest) =>
template(config['change-template'], {
.map((pullRequest) => {
var pullAuthor = 'ghost'
if (pullRequest.author) {
pullAuthor =
pullRequest.author.__typename &&
pullRequest.author.__typename === 'Bot'
? `[${pullRequest.author.login}[bot]](${pullRequest.author.url})`
: pullRequest.author.login
}

return template(config['change-template'], {
$TITLE: escapeTitle(pullRequest.title),
$NUMBER: pullRequest.number,
$AUTHOR: pullRequest.author ? pullRequest.author.login : 'ghost',
$AUTHOR: pullAuthor,
$BODY: pullRequest.body,
$URL: pullRequest.url,
$BASE_REF_NAME: pullRequest.baseRefName,
$HEAD_REF_NAME: pullRequest.headRefName,
})
)
})
.join('\n')

const changeLog = []
Expand Down
2 changes: 2 additions & 0 deletions lib/commits.js
Expand Up @@ -68,6 +68,8 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ `
body @include(if: $withPullRequestBody)
author {
login
__typename
url
}
baseRepository {
nameWithOwner
Expand Down
25 changes: 20 additions & 5 deletions lib/releases.js
Expand Up @@ -111,7 +111,13 @@ const contributorsSentence = ({ commits, pullRequests, config }) => {
pullRequest.author &&
!excludeContributors.includes(pullRequest.author.login)
) {
contributors.add(`@${pullRequest.author.login}`)
if (pullRequest.author.__typename === 'Bot') {
contributors.add(
`[${pullRequest.author.login}[bot]](${pullRequest.author.url})`
)
} else {
contributors.add(`@${pullRequest.author.login}`)
}
}
}

Expand Down Expand Up @@ -235,17 +241,26 @@ const generateChangeLog = (mergedPullRequests, config) => {

const pullRequestToString = (pullRequests) =>
pullRequests
.map((pullRequest) =>
template(config['change-template'], {
.map((pullRequest) => {
var pullAuthor = 'ghost'
if (pullRequest.author) {
pullAuthor =
pullRequest.author.__typename &&
pullRequest.author.__typename === 'Bot'
? `[${pullRequest.author.login}[bot]](${pullRequest.author.url})`
: pullRequest.author.login
}

return template(config['change-template'], {
$TITLE: escapeTitle(pullRequest.title),
$NUMBER: pullRequest.number,
$AUTHOR: pullRequest.author ? pullRequest.author.login : 'ghost',
$AUTHOR: pullAuthor,
$BODY: pullRequest.body,
$URL: pullRequest.url,
$BASE_REF_NAME: pullRequest.baseRefName,
$HEAD_REF_NAME: pullRequest.headRefName,
})
)
})
.join('\n')

const changeLog = []
Expand Down
35 changes: 29 additions & 6 deletions test/releases.test.js
Expand Up @@ -80,6 +80,21 @@ const pullRequests = [
baseRefName: 'master',
headRefName: 'implement-feature',
},
{
title: 'Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples',
number: 0,
body: 'Updates the dependency ....',
url: 'https://github.com',
labels: { nodes: [{ name: 'dependencies' }] },
author: {
login: 'dependabot',
// although the RESTful API returns a `type: "Bot"`, GraphQL only allows us to look up based on the `__typename`
__typename: 'Bot',
url: 'https://github.com/apps/dependabot',
},
baseRefName: 'master',
headRefName: 'dependabot/go_modules/examples/golang.org/x/crypto-0.17.0',
},
]
const baseConfig = {
...DEFAULT_CONFIG,
Expand All @@ -99,7 +114,8 @@ describe('releases', () => {
* Fixes #4 (#5) @Happypig375
* 2*2 should equal to 4*1 (#6) @jetersen
* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost
* Adds @nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375"
* Adds @nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('escapes titles with \\s correctly', () => {
Expand All @@ -116,7 +132,8 @@ describe('releases', () => {
* Fixes #4 (#5) @Happypig375
* 2*2 should equal to 4*1 (#6) @jetersen
* Rename __confgs\\\\\\\\confg.yml to __configs\\\\\\\\config.yml (#7) @ghost
* Adds @nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375"
* Adds @nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('escapes titles with \\<*_& correctly', () => {
Expand All @@ -133,7 +150,8 @@ describe('releases', () => {
* Fixes #4 (#5) @Happypig375
* 2\\\\*2 should equal to 4\\\\*1 (#6) @jetersen
* Rename \\\\_\\\\_confgs\\\\\\\\confg.yml to \\\\_\\\\_configs\\\\\\\\config.yml (#7) @ghost
* Adds @nullable annotations to the 1\\\\*1+2\\\\*4 test in \`tests.java\` (#0) @Happypig375"
* Adds @nullable annotations to the 1\\\\*1+2\\\\*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('escapes titles with @s correctly', () => {
Expand All @@ -150,7 +168,8 @@ describe('releases', () => {
* Fixes #4 (#5) @Happypig375
* 2*2 should equal to 4*1 (#6) @jetersen
* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost
* Adds @<!---->nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375"
* Adds @<!---->nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('escapes titles with @s and #s correctly', () => {
Expand All @@ -167,7 +186,8 @@ describe('releases', () => {
* Fixes #<!---->4 (#5) @Happypig375
* 2*2 should equal to 4*1 (#6) @jetersen
* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost
* Adds @<!---->nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375"
* Adds @<!---->nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('escapes titles with \\<@*_&`# correctly', () => {
Expand All @@ -184,7 +204,8 @@ describe('releases', () => {
* Fixes #<!---->4 (#5) @Happypig375
* 2\\\\*2 should equal to 4\\\\*1 (#6) @jetersen
* Rename \\\\_\\\\_confgs\\\\\\\\confg.yml to \\\\_\\\\_configs\\\\\\\\config.yml (#7) @ghost
* Adds @<!---->nullable annotations to the 1\\\\*1+2\\\\*4 test in \\\\\`tests.java\\\\\` (#0) @Happypig375"
* Adds @<!---->nullable annotations to the 1\\\\*1+2\\\\*4 test in \\\\\`tests.java\\\\\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)"
`)
})
it('adds proper details/summary markdown when collapse-after is set and more than 3 PRs', () => {
Expand All @@ -197,6 +218,7 @@ describe('releases', () => {
"* B2 (#2) @ghost
* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost
* Adds @nullable annotations to the 1*1+2*4 test in \`tests.java\` (#0) @Happypig375
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)

## Bugs

Expand Down Expand Up @@ -227,6 +249,7 @@ describe('releases', () => {
* Fixes #4 (#5) @Happypig375
* 2*2 should equal to 4*1 (#6) @jetersen
* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /examples (#0) @[dependabot[bot]](https://github.com/apps/dependabot)

## Feature

Expand Down