@@ -242,39 +242,32 @@ export class CIHelper {
242242 }
243243 }
244244 }
245+ if ( result ) {
246+ await this . notes . push ( this . urlRepo ) ;
247+ }
245248 return result ;
246249 }
247250
248251 /**
249252 * Process all open PRs.
250253 *
251- * @returns true if `refs/notes/gitgitgadget` was updated (and needs to
252- * be pushed)
254+ * @returns true if `refs/notes/gitgitgadget` was updated
253255 */
254256 public async handleOpenPRs ( ) : Promise < boolean > {
255257 const options = await this . getGitGitGadgetOptions ( ) ;
256258 if ( ! options . openPRs ) {
257259 return false ;
258260 }
259261 let result = false ;
260- let optionsUpdated = false ;
261262 for ( const pullRequestURL in options . openPRs ) {
262263 if ( ! Object . prototype . hasOwnProperty . call ( options . openPRs , pullRequestURL ) ) {
263264 continue ;
264265 }
265266 console . log ( `Handling ${ pullRequestURL } ` ) ;
266- const [ notesUpdated , optionsUpdated2 ] = await this . handlePR ( pullRequestURL , options ) ;
267- if ( notesUpdated ) {
267+ const [ notesUpdated , optionsUpdated ] = await this . handlePR ( pullRequestURL , options ) ;
268+ if ( notesUpdated || optionsUpdated ) {
268269 result = true ;
269270 }
270- if ( optionsUpdated2 ) {
271- optionsUpdated = true ;
272- }
273- }
274-
275- if ( optionsUpdated ) {
276- await this . notes . set ( "" , options , true ) ;
277- result = true ;
278271 }
279272
280273 return result ;
@@ -296,18 +289,10 @@ export class CIHelper {
296289 * require `refs/notes/gitgitgadget` to be pushed. The second is `true`
297290 * if the `options` were updated.
298291 */
299- public async handlePR ( pullRequestURL : string , options ? : IGitGitGadgetOptions ) : Promise < [ boolean , boolean ] > {
292+ public async handlePR ( pullRequestURL : string , options : IGitGitGadgetOptions ) : Promise < [ boolean , boolean ] > {
300293 await this . maybeUpdateGGGNotes ( ) ;
301294 await this . maybeUpdateMail2CommitMap ( ) ;
302295
303- let updateOptionsInRef : boolean ;
304- if ( options ) {
305- updateOptionsInRef = false ;
306- } else {
307- options = await this . getGitGitGadgetOptions ( ) ;
308- updateOptionsInRef = true ;
309- }
310-
311296 const prMeta = await this . notes . get < IPatchSeriesMetadata > ( pullRequestURL ) ;
312297 if ( ! prMeta || ! prMeta . coverLetterMessageId ) {
313298 return [ false , false ] ;
@@ -418,10 +403,14 @@ export class CIHelper {
418403 await this . notes . set ( pullRequestURL , prMeta , true ) ;
419404 }
420405
421- if ( optionsUpdated && updateOptionsInRef ) {
406+ if ( optionsUpdated ) {
422407 await this . notes . set ( "" , options , true ) ;
423408 }
424409
410+ if ( notesUpdated || optionsUpdated ) {
411+ await this . notes . push ( this . urlRepo ) ;
412+ }
413+
425414 return [ notesUpdated , optionsUpdated ] ;
426415 }
427416
@@ -816,7 +805,11 @@ export class CIHelper {
816805 this . github ,
817806 this . config . mailrepo . branch ,
818807 ) ;
819- return await mailArchiveGit . processMails ( prFilter ) ;
808+ if ( await mailArchiveGit . processMails ( prFilter ) ) {
809+ await this . notes . push ( this . urlRepo ) ;
810+ return true ;
811+ }
812+ return false ;
820813 }
821814
822815 public async updateOpenPrs ( ) : Promise < boolean > {
@@ -885,6 +878,7 @@ export class CIHelper {
885878 if ( optionsChanged ) {
886879 console . log ( `Changed options:\n${ toPrettyJSON ( options ) } ` ) ;
887880 await this . notes . set ( "" , options , true ) ;
881+ await this . notes . push ( this . urlRepo ) ;
888882 }
889883
890884 return optionsChanged ;
0 commit comments