@@ -321,48 +321,61 @@ ${this.results.reduce((x, y) => {
321321 }
322322 }
323323
324- // Overlay repo config
324+ // Overlay repo config
325325 // RepoConfigs should be preloaded but checking anyway
326326 const overrideRepoConfig = this . repoConfigs [ `${ repo . repo } .yml` ] ?. repository || this . repoConfigs [ `${ repo . repo } .yaml` ] ?. repository
327327 if ( overrideRepoConfig ) {
328328 repoConfig = this . mergeDeep . mergeDeep ( { } , repoConfig , overrideRepoConfig )
329329 }
330- const { shouldContinue, nopCommands} = await new Archive ( this . nop , this . github , repo , repoConfig , this . log ) . sync ( )
331- if ( nopCommands ) this . appendToResults ( nopCommands )
332- if ( shouldContinue ) {
333- if ( repoConfig ) {
334- try {
335- this . log . debug ( `found a matching repoconfig for this repo ${ JSON . stringify ( repoConfig ) } ` )
336- const childPlugins = this . childPluginsList ( repo )
337- const RepoPlugin = Settings . PLUGINS . repository
338- return new RepoPlugin ( this . nop , this . github , repo , repoConfig , this . installation_id , this . log , this . errors ) . sync ( ) . then ( res => {
339- this . appendToResults ( res )
340- return Promise . all (
341- childPlugins . map ( ( [ Plugin , config ] ) => {
342- return new Plugin ( this . nop , this . github , repo , config , this . log , this . errors ) . sync ( )
343- } ) )
344- } ) . then ( res => {
345- this . appendToResults ( res )
346- } )
347- } catch ( e ) {
348- if ( this . nop ) {
349- const nopcommand = new NopCommand ( this . constructor . name , this . repo , null , `${ e } ` , 'ERROR' )
350- this . log . error ( `NOPCOMMAND ${ JSON . stringify ( nopcommand ) } ` )
351- this . appendToResults ( [ nopcommand ] )
352- // throw e
353- } else {
354- throw e
355- }
356- }
357- } else {
358- this . log . debug ( `Didnt find any a matching repoconfig for this repo ${ JSON . stringify ( repo ) } in ${ JSON . stringify ( this . repoConfigs ) } ` )
330+ if ( repoConfig ) {
331+ try {
332+ this . log . debug ( `found a matching repoconfig for this repo ${ JSON . stringify ( repoConfig ) } ` )
333+
359334 const childPlugins = this . childPluginsList ( repo )
360- return Promise . all ( childPlugins . map ( ( [ Plugin , config ] ) => {
361- return new Plugin ( this . nop , this . github , repo , config , this . log , this . errors ) . sync ( ) . then ( res => {
362- this . appendToResults ( res )
335+ const RepoPlugin = Settings . PLUGINS . repository
336+
337+ const archivePlugin = new Archive ( this . nop , this . github , repo , repoConfig , this . log )
338+ const { shouldArchive, shouldUnarchive } = await archivePlugin . getState ( )
339+
340+ if ( shouldUnarchive ) {
341+ this . log . debug ( `Unarchiving repo ${ repo . repo } ` )
342+ const unArchiveResults = await archivePlugin . sync ( )
343+ this . appendToResults ( unArchiveResults )
344+ }
345+
346+ const repoResults = await new RepoPlugin ( this . nop , this . github , repo , repoConfig , this . installation_id , this . log , this . errors ) . sync ( )
347+ this . appendToResults ( repoResults )
348+
349+ const childResults = await Promise . all (
350+ childPlugins . map ( ( [ Plugin , config ] ) => {
351+ return new Plugin ( this . nop , this . github , repo , config , this . log , this . errors ) . sync ( )
363352 } )
364- } ) )
353+ )
354+ this . appendToResults ( childResults )
355+
356+ if ( shouldArchive ) {
357+ this . log . debug ( `Archiving repo ${ repo . repo } ` )
358+ const archiveResults = await archivePlugin . sync ( )
359+ this . appendToResults ( archiveResults )
360+ }
361+ } catch ( e ) {
362+ if ( this . nop ) {
363+ const nopcommand = new NopCommand ( this . constructor . name , this . repo , null , `${ e } ` , 'ERROR' )
364+ this . log . error ( `NOPCOMMAND ${ JSON . stringify ( nopcommand ) } ` )
365+ this . appendToResults ( [ nopcommand ] )
366+ // throw e
367+ } else {
368+ throw e
369+ }
365370 }
371+ } else {
372+ this . log . debug ( `Didnt find any a matching repoconfig for this repo ${ JSON . stringify ( repo ) } in ${ JSON . stringify ( this . repoConfigs ) } ` )
373+ const childPlugins = this . childPluginsList ( repo )
374+ return Promise . all ( childPlugins . map ( ( [ Plugin , config ] ) => {
375+ return new Plugin ( this . nop , this . github , repo , config , this . log , this . errors ) . sync ( ) . then ( res => {
376+ this . appendToResults ( res )
377+ } )
378+ } ) )
366379 }
367380 }
368381
@@ -885,17 +898,10 @@ ${this.results.reduce((x, y) => {
885898 const value = propertyFilter [ name ]
886899
887900 try {
888- const query = `props.${ name } . ${ value } `
901+ const query = `props.${ name } : ${ value } `
889902 const encodedQuery = encodeURIComponent ( query )
890-
891- return this . github . paginate (
892- this . github . repos . getCustomPropertiesValues ,
893- {
894- org : organizationName ,
895- repository_query : encodedQuery ,
896- per_page : 100
897- }
898- )
903+ const options = this . github . request . endpoint ( ( `/orgs/${ this . repo . owner } /properties/values?repository_query=${ encodedQuery } ` ) )
904+ return this . github . paginate ( options )
899905 } catch ( error ) {
900906 throw new Error ( `Failed to filter repositories for property ${ name } : ${ error . message } ` )
901907 }
0 commit comments