Skip to content

Commit

Permalink
Merge pull request #115 from silviogutierrez/patch-1
Browse files Browse the repository at this point in the history
Add owner and repo variables to commit message template
  • Loading branch information
ibakshay committed Feb 9, 2023
2 parents 724af84 + 7467a39 commit 5cc070a
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions src/persistence/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,30 @@ export async function createFile(contentBinary): Promise<any> {
})
}

export async function updateFile(
sha: string,
claFileContent,
reactedCommitters: ReactedCommitterMap
): Promise<any> {
const octokitInstance: InstanceType<typeof GitHub> =
isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient()
export async function updateFile(sha: string, claFileContent, reactedCommitters: ReactedCommitterMap): Promise<any> {

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)
: `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`,
content: contentBinary,
branch: input.getBranch()
})
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()
})
}

function isRemoteRepoOrOrgConfigured(): boolean {
Expand Down

0 comments on commit 5cc070a

Please sign in to comment.