diff --git a/lib/add-contributor.js b/lib/add-contributor.js index bdd30d10..451b8c82 100644 --- a/lib/add-contributor.js +++ b/lib/add-contributor.js @@ -4,7 +4,7 @@ const getUserDetails = require("./get-user-details"); const ContentFiles = require("./modules/content-files"); const convertMessage = require("commit-conv"); -const { generatePrTitle } = require("./modules/helpers"); +const { generatePrTitle, generatePrBody } = require("./modules/helpers"); async function addContributor({ context, @@ -62,15 +62,20 @@ async function addContributor({ convention }); + const skipCi = config.get().skipCi; + const prBodyMessage = `Adds @${who} as a contributor for ${contributions.join( + ", " + )}.\n\nThis was requested by ${commentReply.replyingToWho()} [in this comment](${commentReply.replyingToWhere()})` + + const prBody = generatePrBody(prBodyMessage, skipCi); + // create or update pull request const { pullRequestURL, pullCreated, } = await repository.createPullRequestFromFiles({ title: prTitle, - body: `Adds @${who} as a contributor for ${contributions.join( - ", " - )}.\n\nThis was requested by ${commentReply.replyingToWho()} [in this comment](${commentReply.replyingToWhere()})`, + body: prBody, filesByPath: filesByPathToUpdate, branchName, convention, diff --git a/lib/modules/helpers.js b/lib/modules/helpers.js index 4a161933..5f54d4c8 100644 --- a/lib/modules/helpers.js +++ b/lib/modules/helpers.js @@ -6,6 +6,10 @@ function generateValidProfileLink(blog, githubProfileURL) { return githubProfileURL || '' } +function generatePrBody(message, skipCi) { + return skipCi ? message.concat('\n\n[skip ci]') : message; +} + function generatePrTitle(message, contributions) { const contributionsTitlePartLimit = 3 @@ -19,6 +23,7 @@ function generatePrTitle(message, contributions) { } module.exports = { + generatePrBody, generatePrTitle, - generateValidProfileLink + generateValidProfileLink, } diff --git a/test/integration/__snapshots__/issue_comment.test.js.snap b/test/integration/__snapshots__/issue_comment.test.js.snap index da4b9233..1cf3bee7 100644 --- a/test/integration/__snapshots__/issue_comment.test.js.snap +++ b/test/integration/__snapshots__/issue_comment.test.js.snap @@ -585,7 +585,9 @@ Object { "base": "master", "body": "Adds @jakebolam as a contributor for code, doc, infra. -This was requested by jakebolam [in this comment](https://github.com/all-contributors/all-contributors-bot/pull/1#issuecomment-453012966)", +This was requested by jakebolam [in this comment](https://github.com/all-contributors/all-contributors-bot/pull/1#issuecomment-453012966) + +[skip ci]", "head": "all-contributors/add-jakebolam", "maintainer_can_modify": true, "title": "docs: add jakebolam as a contributor for code, doc, and infra", diff --git a/test/unit/helpers.test.js b/test/unit/helpers.test.js index bcd8ccf0..ff1197d9 100644 --- a/test/unit/helpers.test.js +++ b/test/unit/helpers.test.js @@ -1,8 +1,25 @@ const { + generatePrBody, generatePrTitle, generateValidProfileLink, } = require('../../lib/modules/helpers'); +describe('generatePrBody', () => { + const message = 'This is a test'; + + test('returns message without skip ci', async () => { + const prBodyMessage = generatePrBody(message, false); + + expect(prBodyMessage).toEqual(message); + }); + + test('returns message with skip ci', async () => { + const prBodyMessage = generatePrBody(message, true); + + expect(prBodyMessage).toEqual(message.concat('\n\n[skip ci]')); + }); +}); + describe('generatePrTitle', () => { const message = 'add tenshiAMD as a contributor';