Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create empty commit for custom pr sign comment as well #147

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
Loading