@@ -23,7 +23,7 @@ module.exports = class Branches extends ErrorStash {
2323
2424 sync ( ) {
2525 const resArray = [ ]
26- return this . github . repos . get ( this . repo ) . then ( ( currentRepo ) => {
26+ return this . github . rest . repos . get ( this . repo ) . then ( ( currentRepo ) => {
2727 return Promise . all (
2828 this . branches
2929 . filter ( branch => branch . protection !== undefined )
@@ -39,12 +39,12 @@ module.exports = class Branches extends ErrorStash {
3939 const params = Object . assign ( { } , p )
4040 if ( this . nop ) {
4141 resArray . push (
42- new NopCommand ( this . constructor . name , this . repo , this . github . repos . deleteBranchProtection . endpoint ( params ) , 'Delete Branch Protection' )
42+ new NopCommand ( this . constructor . name , this . repo , this . github . rest . repos . deleteBranchProtection . endpoint ( params ) , 'Delete Branch Protection' )
4343 )
4444 return Promise . resolve ( resArray )
4545 }
4646
47- return this . github . repos . deleteBranchProtection ( params ) . catch ( e => { return [ ] } )
47+ return this . github . rest . repos . deleteBranchProtection ( params ) . catch ( e => { return [ ] } )
4848 } else {
4949 // Branch protection is not empty
5050 let p = Object . assign ( this . repo , { branch : branch . name } )
@@ -54,7 +54,7 @@ module.exports = class Branches extends ErrorStash {
5454 }
5555 // Hack to handle closures and keep params from changing
5656 const params = Object . assign ( { } , p )
57- return this . github . repos . getBranchProtection ( params ) . then ( ( result ) => {
57+ return this . github . rest . repos . getBranchProtection ( params ) . then ( ( result ) => {
5858 const mergeDeep = new MergeDeep ( this . log , this . github , ignorableFields )
5959 const changes = mergeDeep . compareDeep ( { branch : { protection : this . reformatAndReturnBranchProtection ( result . data ) } } , { branch : { protection : Overrides . removeOverrides ( overrides , branch . protection , result . data ) } } )
6060 const results = { msg : `Followings changes will be applied to the branch protection for ${ params . branch . name } branch` , additions : changes . additions , modifications : changes . modifications , deletions : changes . deletions }
@@ -76,24 +76,24 @@ module.exports = class Branches extends ErrorStash {
7676 Object . assign ( params , branch . protection , { headers : previewHeaders } )
7777
7878 if ( this . nop ) {
79- resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . updateBranchProtection . endpoint ( params ) , 'Add Branch Protection' ) )
79+ resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . rest . repos . updateBranchProtection . endpoint ( params ) , 'Add Branch Protection' ) )
8080 return Promise . resolve ( resArray )
8181 }
8282 this . log . debug ( `Adding branch protection ${ JSON . stringify ( params ) } ` )
83- return this . github . repos . updateBranchProtection ( params ) . then ( res => this . log . debug ( `Branch protection applied successfully ${ JSON . stringify ( res . url ) } ` ) ) . catch ( e => { this . logError ( `Error applying branch protection ${ JSON . stringify ( e ) } ` ) ; return [ ] } )
83+ return this . github . rest . repos . updateBranchProtection ( params ) . then ( res => this . log . debug ( `Branch protection applied successfully ${ JSON . stringify ( res . url ) } ` ) ) . catch ( e => { this . logError ( `Error applying branch protection ${ JSON . stringify ( e ) } ` ) ; return [ ] } )
8484 } ) . catch ( ( e ) => {
8585 if ( e . status === 404 ) {
8686 Object . assign ( params , Overrides . removeOverrides ( overrides , branch . protection , { } ) , { headers : previewHeaders } )
8787 if ( this . nop ) {
88- resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . updateBranchProtection . endpoint ( params ) , 'Add Branch Protection' ) )
88+ resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . rest . repos . updateBranchProtection . endpoint ( params ) , 'Add Branch Protection' ) )
8989 return Promise . resolve ( resArray )
9090 }
9191 this . log . debug ( `Adding branch protection ${ JSON . stringify ( params ) } ` )
92- return this . github . repos . updateBranchProtection ( params ) . then ( res => this . log . debug ( `Branch protection applied successfully ${ JSON . stringify ( res . url ) } ` ) ) . catch ( e => { this . logError ( `Error applying branch protection ${ JSON . stringify ( e ) } ` ) ; return [ ] } )
92+ return this . github . rest . repos . updateBranchProtection ( params ) . then ( res => this . log . debug ( `Branch protection applied successfully ${ JSON . stringify ( res . url ) } ` ) ) . catch ( e => { this . logError ( `Error applying branch protection ${ JSON . stringify ( e ) } ` ) ; return [ ] } )
9393 } else {
9494 this . logError ( e )
9595 if ( this . nop ) {
96- resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . updateBranchProtection . endpoint ( params ) , `${ e } ` , 'ERROR' ) )
96+ resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . rest . repos . updateBranchProtection . endpoint ( params ) , `${ e } ` , 'ERROR' ) )
9797 return Promise . resolve ( resArray )
9898 }
9999 }
0 commit comments