diff --git a/README.md b/README.md index 1382fae1..ac28f3c4 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ jobs: #remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository) #remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository) #create-file-commit-message: 'For example: Creating file for storing CLA Signatures' - #signed-commit-message: 'For example: $contributorName has signed the CLA' + #signed-commit-message: 'For example: $contributorName has signed the CLA in $owner/$repo#$pullRequestNo' #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA' #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' diff --git a/dist/index.js b/dist/index.js index 0ca7390c..6ac87be9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1904,6 +1904,8 @@ function updateFile(sha, claFileContent, reactedCommitters) { return __awaiter(this, void 0, void 0, function* () { const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)(); const pullRequestNo = github_1.context.issue.number; + const owner = github_1.context.issue.owner; + const repo = github_1.context.issue.repo; claFileContent === null || claFileContent === void 0 ? void 0 : claFileContent.signedContributors.push(...reactedCommitters.newSigned); let contentString = JSON.stringify(claFileContent, null, 2); let contentBinary = Buffer.from(contentString).toString('base64'); @@ -1916,7 +1918,10 @@ function updateFile(sha, claFileContent, reactedCommitters) { ? input .getSignedCommitMessage() .replace('$contributorName', github_1.context.actor) - : `@${github_1.context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, + // .replace('$pullRequestNo', pullRequestNo.toString()) + .replace('$owner', owner) + .replace('$repo', repo) + : `@${github_1.context.actor} has signed the CLA in ${owner}/${repo}#${pullRequestNo}`, content: contentBinary, branch: input.getBranch() }); diff --git a/src/persistence/persistence.ts b/src/persistence/persistence.ts index ecbee079..f5a08e48 100644 --- a/src/persistence/persistence.ts +++ b/src/persistence/persistence.ts @@ -35,30 +35,37 @@ export async function createFile(contentBinary): Promise { }) } -export async function updateFile(sha: string, claFileContent, reactedCommitters: ReactedCommitterMap): Promise { - - const octokitInstance: InstanceType = +export async function updateFile( + sha: string, + claFileContent, + reactedCommitters: ReactedCommitterMap +): Promise { + const octokitInstance: InstanceType = isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient() - const pullRequestNo = context.issue.number - claFileContent?.signedContributors.push(...reactedCommitters.newSigned) - let contentString = JSON.stringify(claFileContent, null, 2) - let contentBinary = Buffer.from(contentString).toString("base64") - await octokitInstance.repos.createOrUpdateFileContents({ - owner: input.getRemoteOrgName() || context.repo.owner, - repo: input.getRemoteRepoName() || context.repo.repo, - path: input.getPathToSignatures(), - sha, - message: input.getSignedCommitMessage() - ? input - .getSignedCommitMessage() - .replace("$contributorName", context.actor) - .replace("$pullRequestNo", context.issue.number.toString()) - .replace("$owner", context.issue.owner) - .replace("$repo", context.issue.repo) - : `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, - content: contentBinary, - branch: input.getBranch() - }) + + const pullRequestNo = context.issue.number + const owner = context.issue.owner + const repo = context.issue.repo + + claFileContent?.signedContributors.push(...reactedCommitters.newSigned) + let contentString = JSON.stringify(claFileContent, null, 2) + let contentBinary = Buffer.from(contentString).toString('base64') + await octokitInstance.repos.createOrUpdateFileContents({ + owner: input.getRemoteOrgName() || context.repo.owner, + repo: input.getRemoteRepoName() || context.repo.repo, + path: input.getPathToSignatures(), + sha, + message: input.getSignedCommitMessage() + ? input + .getSignedCommitMessage() + .replace('$contributorName', context.actor) + // .replace('$pullRequestNo', pullRequestNo.toString()) + .replace('$owner', owner) + .replace('$repo', repo) + : `@${context.actor} has signed the CLA in ${owner}/${repo}#${pullRequestNo}`, + content: contentBinary, + branch: input.getBranch() + }) } function isRemoteRepoOrOrgConfigured(): boolean {