Skip to content

Commit

Permalink
fix: create empty commit for custom pr sign comment as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Mar 9, 2024
1 parent a895a43 commit f4faf18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __tests__/runner/*
.vscode
node_modules
lib
.idea
5 changes: 3 additions & 2 deletions src/addEmptyCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { context } from '@actions/github'

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


export async function addEmptyCommit() {
Expand All @@ -11,8 +12,8 @@ export async function addEmptyCommit() {

if (context.payload.comment) {

//Do empty commit only when the contributor signs the CLA with the PR comment
if (context.payload.comment.body === 'I have read the CLA Document and I hereby sign the CLA') {
//Do empty commit only when the contributor signs the CLA with the PR comment
if (context.payload.comment.body.toLowerCase().trim() === getPrSignComment().toLowerCase().trim()) {
try {
const message = input.getSignedCommitMessage() ?
input.getSignedCommitMessage().replace('$contributorName', contributorName) :
Expand Down
5 changes: 3 additions & 2 deletions src/pullrequest/pullRequestCommentContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CommitterMap
} from '../interfaces'
import * as input from '../shared/getInputs'
import { getPrSignComment } from '../shared/pr-sign-comment'

export function commentContent(signed: boolean, committerMap: CommitterMap): string {
// using a `string` true or false purposely as github action input cannot have a boolean value
Expand Down Expand Up @@ -72,7 +73,7 @@ function cla(signed: boolean, committerMap: CommitterMap): string {
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)
let text = `**CLA Assistant Lite bot:** ${lineOne}
- - -
${input.getCustomPrSignComment() || "I have read the CLA Document and I hereby sign the CLA"}
${getPrSignComment()}
- - -
`

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

text += '<sub>You can retrigger this bot by commenting **recheck** in this Pull Request</sub>'
return text
}
}
5 changes: 5 additions & 0 deletions src/shared/pr-sign-comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as input from './getInputs'

export function getPrSignComment() {
return input.getCustomPrSignComment() || "I have read the CLA Document and I hereby sign the CLA"
}

0 comments on commit f4faf18

Please sign in to comment.