Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ibakshay committed Feb 9, 2023
1 parent 5cc070a commit a9e6bc9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
4 changes: 4 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,7 @@ 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;
console.log(JSON.stringify(github_1.context.issue, null, 3));
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,6 +1917,9 @@ function updateFile(sha, claFileContent, reactedCommitters) {
? input
.getSignedCommitMessage()
.replace('$contributorName', github_1.context.actor)
.replace('$pullRequestNo', github_1.context.issue.number.toString())
.replace('$owner', github_1.context.issue.owner)
.replace('$repo', github_1.context.issue.repo)
: `@${github_1.context.actor} has signed the CLA from Pull Request #${pullRequestNo}`,
content: contentBinary,
branch: input.getBranch()
Expand Down
51 changes: 28 additions & 23 deletions src/persistence/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,35 @@ 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
console.log(JSON.stringify(context.issue, null, 3))
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 a9e6bc9

Please sign in to comment.