@@ -35,31 +35,30 @@ export async function createFile(contentBinary): Promise<any> {
3535 } )
3636}
3737
38- export async function updateFile (
39- sha : string ,
40- claFileContent ,
41- reactedCommitters : ReactedCommitterMap
42- ) : Promise < any > {
43- const octokitInstance : InstanceType < typeof GitHub > =
44- isRemoteRepoOrOrgConfigured ( ) ? getPATOctokit ( ) : getDefaultOctokitClient ( )
38+ export async function updateFile ( sha : string , claFileContent , reactedCommitters : ReactedCommitterMap ) : Promise < any > {
4539
46- const pullRequestNo = context . issue . number
47- claFileContent ?. signedContributors . push ( ...reactedCommitters . newSigned )
48- let contentString = JSON . stringify ( claFileContent , null , 2 )
49- let contentBinary = Buffer . from ( contentString ) . toString ( 'base64' )
50- await octokitInstance . repos . createOrUpdateFileContents ( {
51- owner : input . getRemoteOrgName ( ) || context . repo . owner ,
52- repo : input . getRemoteRepoName ( ) || context . repo . repo ,
53- path : input . getPathToSignatures ( ) ,
54- sha,
55- message : input . getSignedCommitMessage ( )
56- ? input
57- . getSignedCommitMessage ( )
58- . replace ( '$contributorName' , context . actor )
59- : `@${ context . actor } has signed the CLA from Pull Request #${ pullRequestNo } ` ,
60- content : contentBinary ,
61- branch : input . getBranch ( )
62- } )
40+ const octokitInstance : InstanceType < typeof GitHub > =
41+ 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+ } )
6362}
6463
6564function isRemoteRepoOrOrgConfigured ( ) : boolean {
0 commit comments