@@ -37,6 +37,7 @@ export class CIHelper {
3737 protected testing : boolean ;
3838 private gggNotesUpdated : boolean ;
3939 private mail2CommitMapUpdated : boolean ;
40+ private notesPushToken : string | undefined ;
4041 protected maxCommitsExceptions : string [ ] ;
4142
4243 public constructor ( workDir : string , skipUpdate ?: boolean , gggConfigDir = "." ) {
@@ -53,6 +54,13 @@ export class CIHelper {
5354 this . urlRepo = `${ this . urlBase } ${ this . config . repo . name } /` ;
5455 }
5556
57+ public setAccessToken ( repositoryOwner : string , token : string ) : void {
58+ this . github . setAccessToken ( repositoryOwner , token ) ;
59+ if ( this . config . repo . owner === repositoryOwner ) {
60+ this . notesPushToken = token ;
61+ }
62+ }
63+
5664 /*
5765 * Given a commit that was contributed as a patch via GitGitGadget (i.e.
5866 * a commit with a Message-ID recorded in `refs/notes/gitgitgadget`),
@@ -243,7 +251,7 @@ export class CIHelper {
243251 }
244252 }
245253 if ( result ) {
246- await this . notes . push ( this . urlRepo ) ;
254+ await this . pushNotesRef ( ) ;
247255 }
248256 return result ;
249257 }
@@ -408,7 +416,7 @@ export class CIHelper {
408416 }
409417
410418 if ( notesUpdated || optionsUpdated ) {
411- await this . notes . push ( this . urlRepo ) ;
419+ await this . pushNotesRef ( ) ;
412420 }
413421
414422 return [ notesUpdated , optionsUpdated ] ;
@@ -568,7 +576,7 @@ export class CIHelper {
568576 } ;
569577
570578 try {
571- const gitGitGadget = await GitGitGadget . get ( this . gggConfigDir , this . workDir ) ;
579+ const gitGitGadget = await GitGitGadget . get ( this . gggConfigDir , this . workDir , this . notesPushToken ) ;
572580 if ( ! gitGitGadget . isUserAllowed ( comment . author ) ) {
573581 throw new Error ( `User ${ comment . author } is not yet permitted to use ${ this . config . app . displayName } ` ) ;
574582 }
@@ -774,7 +782,7 @@ export class CIHelper {
774782 await this . github . addPRComment ( prKey , redacted ) ;
775783 } ;
776784
777- const gitGitGadget = await GitGitGadget . get ( this . gggConfigDir , this . workDir ) ;
785+ const gitGitGadget = await GitGitGadget . get ( this . gggConfigDir , this . workDir , this . notesPushToken ) ;
778786 if ( ! pr . hasComments && ! gitGitGadget . isUserAllowed ( pr . author ) ) {
779787 const welcome = ( await readFile ( "res/WELCOME.md" ) ) . toString ( ) . replace ( / \$ { username} / g, pr . author ) ;
780788 await this . github . addPRComment ( prKey , welcome ) ;
@@ -806,7 +814,7 @@ export class CIHelper {
806814 this . config . mailrepo . branch ,
807815 ) ;
808816 if ( await mailArchiveGit . processMails ( prFilter ) ) {
809- await this . notes . push ( this . urlRepo ) ;
817+ await this . pushNotesRef ( ) ;
810818 return true ;
811819 }
812820 return false ;
@@ -878,7 +886,7 @@ export class CIHelper {
878886 if ( optionsChanged ) {
879887 console . log ( `Changed options:\n${ toPrettyJSON ( options ) } ` ) ;
880888 await this . notes . set ( "" , options , true ) ;
881- await this . notes . push ( this . urlRepo ) ;
889+ await this . pushNotesRef ( ) ;
882890 }
883891
884892 return optionsChanged ;
@@ -933,4 +941,8 @@ export class CIHelper {
933941 this . mail2CommitMapUpdated = true ;
934942 }
935943 }
944+
945+ private async pushNotesRef ( ) : Promise < void > {
946+ await this . notes . push ( this . urlRepo , this . notesPushToken ) ;
947+ }
936948}
0 commit comments