Skip to content

Commit

Permalink
feat: add skip ci flag in PR description (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenshiAMD authored Oct 6, 2022
1 parent 945264d commit bad58c8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
13 changes: 9 additions & 4 deletions lib/add-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion lib/modules/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

module.exports = {
generatePrBody,
generatePrTitle,
generateValidProfileLink
generateValidProfileLink,
}
4 changes: 3 additions & 1 deletion test/integration/__snapshots__/issue_comment.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions test/unit/helpers.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

1 comment on commit bad58c8

@vercel
Copy link

@vercel vercel bot commented on bad58c8 Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.