Skip to content

Commit f4faf18

Browse files
committed
fix: create empty commit for custom pr sign comment as well
1 parent a895a43 commit f4faf18

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ __tests__/runner/*
22
.vscode
33
node_modules
44
lib
5+
.idea

src/addEmptyCommit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { context } from '@actions/github'
33

44
import * as core from '@actions/core'
55
import * as input from './shared/getInputs'
6+
import { getPrSignComment } from './shared/pr-sign-comment'
67

78

89
export async function addEmptyCommit() {
@@ -11,8 +12,8 @@ export async function addEmptyCommit() {
1112

1213
if (context.payload.comment) {
1314

14-
//Do empty commit only when the contributor signs the CLA with the PR comment
15-
if (context.payload.comment.body === 'I have read the CLA Document and I hereby sign the CLA') {
15+
//Do empty commit only when the contributor signs the CLA with the PR comment
16+
if (context.payload.comment.body.toLowerCase().trim() === getPrSignComment().toLowerCase().trim()) {
1617
try {
1718
const message = input.getSignedCommitMessage() ?
1819
input.getSignedCommitMessage().replace('$contributorName', contributorName) :

src/pullrequest/pullRequestCommentContent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
CommitterMap
33
} from '../interfaces'
44
import * as input from '../shared/getInputs'
5+
import { getPrSignComment } from '../shared/pr-sign-comment'
56

67
export function commentContent(signed: boolean, committerMap: CommitterMap): string {
78
// using a `string` true or false purposely as github action input cannot have a boolean value
@@ -72,7 +73,7 @@ function cla(signed: boolean, committerMap: CommitterMap): string {
7273
let lineOne = (input.getCustomNotSignedPrComment() || `<br/>Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that $you sign our [Contributor License Agreement](${input.getPathToDocument()}) before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.<br/>`).replace('$you', you)
7374
let text = `**CLA Assistant Lite bot:** ${lineOne}
7475
- - -
75-
${input.getCustomPrSignComment() || "I have read the CLA Document and I hereby sign the CLA"}
76+
${getPrSignComment()}
7677
- - -
7778
`
7879

@@ -94,4 +95,4 @@ function cla(signed: boolean, committerMap: CommitterMap): string {
9495

9596
text += '<sub>You can retrigger this bot by commenting **recheck** in this Pull Request</sub>'
9697
return text
97-
}
98+
}

src/shared/pr-sign-comment.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as input from './getInputs'
2+
3+
export function getPrSignComment() {
4+
return input.getCustomPrSignComment() || "I have read the CLA Document and I hereby sign the CLA"
5+
}

0 commit comments

Comments
 (0)