Skip to content

Commit

Permalink
Merge pull request #128 from contributor-assistant/fix-commit-message
Browse files Browse the repository at this point in the history
Fix commit message
  • Loading branch information
ibakshay authored Feb 9, 2023
2 parents 5cc070a + 0ce7444 commit 5bfe123
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
7 changes: 6 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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()
});
Expand Down
53 changes: 30 additions & 23 deletions src/persistence/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,37 @@ export async function createFile(contentBinary): Promise<any> {
})
}

export async function updateFile(sha: string, claFileContent, reactedCommitters: ReactedCommitterMap): Promise<any> {

const octokitInstance: InstanceType<typeof GitHub> =
export async function updateFile(
sha: string,
claFileContent,
reactedCommitters: ReactedCommitterMap
): Promise<any> {
const octokitInstance: InstanceType<typeof GitHub> =
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 {
Expand Down

0 comments on commit 5bfe123

Please sign in to comment.