diff --git a/dist/index.js b/dist/index.js index 96194eea5..8bc1546ae 100644 --- a/dist/index.js +++ b/dist/index.js @@ -142591,6 +142591,8 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ ` body @include(if: $withPullRequestBody) author { login + __typename + url } baseRepository { nameWithOwner @@ -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}`) + } } } @@ -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 = [] diff --git a/lib/commits.js b/lib/commits.js index 1d0e230b0..d75259094 100644 --- a/lib/commits.js +++ b/lib/commits.js @@ -68,6 +68,8 @@ const findCommitsWithAssociatedPullRequestsQuery = /* GraphQL */ ` body @include(if: $withPullRequestBody) author { login + __typename + url } baseRepository { nameWithOwner diff --git a/lib/releases.js b/lib/releases.js index 1f22d6eb1..0d2905e4c 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -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}`) + } } } @@ -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 = [] diff --git a/test/releases.test.js b/test/releases.test.js index 67b329fc3..623e4cf80 100644 --- a/test/releases.test.js +++ b/test/releases.test.js @@ -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, @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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', () => { @@ -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 @@ -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