Skip to content

Commit bad58c8

Browse files
authored
feat: add skip ci flag in PR description (#432)
1 parent 945264d commit bad58c8

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

lib/add-contributor.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const getUserDetails = require("./get-user-details");
44
const ContentFiles = require("./modules/content-files");
55
const convertMessage = require("commit-conv");
66

7-
const { generatePrTitle } = require("./modules/helpers");
7+
const { generatePrTitle, generatePrBody } = require("./modules/helpers");
88

99
async function addContributor({
1010
context,
@@ -62,15 +62,20 @@ async function addContributor({
6262
convention
6363
});
6464

65+
const skipCi = config.get().skipCi;
66+
const prBodyMessage = `Adds @${who} as a contributor for ${contributions.join(
67+
", "
68+
)}.\n\nThis was requested by ${commentReply.replyingToWho()} [in this comment](${commentReply.replyingToWhere()})`
69+
70+
const prBody = generatePrBody(prBodyMessage, skipCi);
71+
6572
// create or update pull request
6673
const {
6774
pullRequestURL,
6875
pullCreated,
6976
} = await repository.createPullRequestFromFiles({
7077
title: prTitle,
71-
body: `Adds @${who} as a contributor for ${contributions.join(
72-
", "
73-
)}.\n\nThis was requested by ${commentReply.replyingToWho()} [in this comment](${commentReply.replyingToWhere()})`,
78+
body: prBody,
7479
filesByPath: filesByPathToUpdate,
7580
branchName,
7681
convention,

lib/modules/helpers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ function generateValidProfileLink(blog, githubProfileURL) {
66
return githubProfileURL || ''
77
}
88

9+
function generatePrBody(message, skipCi) {
10+
return skipCi ? message.concat('\n\n[skip ci]') : message;
11+
}
12+
913
function generatePrTitle(message, contributions) {
1014
const contributionsTitlePartLimit = 3
1115

@@ -19,6 +23,7 @@ function generatePrTitle(message, contributions) {
1923
}
2024

2125
module.exports = {
26+
generatePrBody,
2227
generatePrTitle,
23-
generateValidProfileLink
28+
generateValidProfileLink,
2429
}

test/integration/__snapshots__/issue_comment.test.js.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ Object {
585585
"base": "master",
586586
"body": "Adds @jakebolam as a contributor for code, doc, infra.
587587
588-
This was requested by jakebolam [in this comment](https://github.com/all-contributors/all-contributors-bot/pull/1#issuecomment-453012966)",
588+
This was requested by jakebolam [in this comment](https://github.com/all-contributors/all-contributors-bot/pull/1#issuecomment-453012966)
589+
590+
[skip ci]",
589591
"head": "all-contributors/add-jakebolam",
590592
"maintainer_can_modify": true,
591593
"title": "docs: add jakebolam as a contributor for code, doc, and infra",

test/unit/helpers.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
const {
2+
generatePrBody,
23
generatePrTitle,
34
generateValidProfileLink,
45
} = require('../../lib/modules/helpers');
56

7+
describe('generatePrBody', () => {
8+
const message = 'This is a test';
9+
10+
test('returns message without skip ci', async () => {
11+
const prBodyMessage = generatePrBody(message, false);
12+
13+
expect(prBodyMessage).toEqual(message);
14+
});
15+
16+
test('returns message with skip ci', async () => {
17+
const prBodyMessage = generatePrBody(message, true);
18+
19+
expect(prBodyMessage).toEqual(message.concat('\n\n[skip ci]'));
20+
});
21+
});
22+
623
describe('generatePrTitle', () => {
724
const message = 'add tenshiAMD as a contributor';
825

0 commit comments

Comments
 (0)