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 commit message #128

Merged
merged 5 commits into from
Feb 9, 2023
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
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