Skip to content

Commit 5bfe123

Browse files
authored
Merge pull request #128 from contributor-assistant/fix-commit-message
Fix commit message
2 parents 5cc070a + 0ce7444 commit 5bfe123

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
4949
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
5050
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
51-
#signed-commit-message: 'For example: $contributorName has signed the CLA'
51+
#signed-commit-message: 'For example: $contributorName has signed the CLA in $owner/$repo#$pullRequestNo'
5252
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
5353
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
5454
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'

dist/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,8 @@ function updateFile(sha, claFileContent, reactedCommitters) {
19041904
return __awaiter(this, void 0, void 0, function* () {
19051905
const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)();
19061906
const pullRequestNo = github_1.context.issue.number;
1907+
const owner = github_1.context.issue.owner;
1908+
const repo = github_1.context.issue.repo;
19071909
claFileContent === null || claFileContent === void 0 ? void 0 : claFileContent.signedContributors.push(...reactedCommitters.newSigned);
19081910
let contentString = JSON.stringify(claFileContent, null, 2);
19091911
let contentBinary = Buffer.from(contentString).toString('base64');
@@ -1916,7 +1918,10 @@ function updateFile(sha, claFileContent, reactedCommitters) {
19161918
? input
19171919
.getSignedCommitMessage()
19181920
.replace('$contributorName', github_1.context.actor)
1919-
: `@${github_1.context.actor} has signed the CLA from Pull Request #${pullRequestNo}`,
1921+
// .replace('$pullRequestNo', pullRequestNo.toString())
1922+
.replace('$owner', owner)
1923+
.replace('$repo', repo)
1924+
: `@${github_1.context.actor} has signed the CLA in ${owner}/${repo}#${pullRequestNo}`,
19201925
content: contentBinary,
19211926
branch: input.getBranch()
19221927
});

src/persistence/persistence.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,37 @@ export async function createFile(contentBinary): Promise<any> {
3535
})
3636
}
3737

38-
export async function updateFile(sha: string, claFileContent, reactedCommitters: ReactedCommitterMap): Promise<any> {
39-
40-
const octokitInstance: InstanceType<typeof GitHub> =
38+
export async function updateFile(
39+
sha: string,
40+
claFileContent,
41+
reactedCommitters: ReactedCommitterMap
42+
): Promise<any> {
43+
const octokitInstance: InstanceType<typeof GitHub> =
4144
isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient()
42-
const pullRequestNo = context.issue.number
43-
claFileContent?.signedContributors.push(...reactedCommitters.newSigned)
44-
let contentString = JSON.stringify(claFileContent, null, 2)
45-
let contentBinary = Buffer.from(contentString).toString("base64")
46-
await octokitInstance.repos.createOrUpdateFileContents({
47-
owner: input.getRemoteOrgName() || context.repo.owner,
48-
repo: input.getRemoteRepoName() || context.repo.repo,
49-
path: input.getPathToSignatures(),
50-
sha,
51-
message: input.getSignedCommitMessage()
52-
? input
53-
.getSignedCommitMessage()
54-
.replace("$contributorName", context.actor)
55-
.replace("$pullRequestNo", context.issue.number.toString())
56-
.replace("$owner", context.issue.owner)
57-
.replace("$repo", context.issue.repo)
58-
: `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`,
59-
content: contentBinary,
60-
branch: input.getBranch()
61-
})
45+
46+
const pullRequestNo = context.issue.number
47+
const owner = context.issue.owner
48+
const repo = context.issue.repo
49+
50+
claFileContent?.signedContributors.push(...reactedCommitters.newSigned)
51+
let contentString = JSON.stringify(claFileContent, null, 2)
52+
let contentBinary = Buffer.from(contentString).toString('base64')
53+
await octokitInstance.repos.createOrUpdateFileContents({
54+
owner: input.getRemoteOrgName() || context.repo.owner,
55+
repo: input.getRemoteRepoName() || context.repo.repo,
56+
path: input.getPathToSignatures(),
57+
sha,
58+
message: input.getSignedCommitMessage()
59+
? input
60+
.getSignedCommitMessage()
61+
.replace('$contributorName', context.actor)
62+
// .replace('$pullRequestNo', pullRequestNo.toString())
63+
.replace('$owner', owner)
64+
.replace('$repo', repo)
65+
: `@${context.actor} has signed the CLA in ${owner}/${repo}#${pullRequestNo}`,
66+
content: contentBinary,
67+
branch: input.getBranch()
68+
})
6269
}
6370

6471
function isRemoteRepoOrOrgConfigured(): boolean {

0 commit comments

Comments
 (0)