@@ -43,7 +43,7 @@ const ignorableFields = [
4343]
4444
4545module . exports = class Repository {
46- constructor ( nop , github , repo , settings , installationId , log ) {
46+ constructor ( nop , github , repo , settings , installationId , log ) {
4747 this . installationId = installationId
4848 this . github = github
4949 this . settings = Object . assign ( { mediaType : { previews : [ 'nebula-preview' ] } } , settings , repo )
@@ -59,7 +59,7 @@ module.exports = class Repository {
5959 delete this . settings . template
6060 }
6161
62- sync ( ) {
62+ sync ( ) {
6363 const resArray = [ ]
6464 this . log . debug ( `Syncing Repo ${ this . settings . name } ` )
6565 this . settings . name = this . settings . name || this . settings . repo
@@ -100,9 +100,18 @@ module.exports = class Repository {
100100 }
101101 // Remove topics as it would be handled seperately
102102 delete this . settings . topics
103- promises . push ( this . updaterepo ( resArray ) . then ( ( resp ) => {
104- return this . updateSecurity ( resp . data , resArray )
105- } ) )
103+
104+ promises . push ( async ( ) => {
105+
106+ this . log . debug ( `Updating repo with settings ${ JSON . stringify ( this . topics ) } ${ JSON . stringify ( this . settings ) } ` )
107+
108+ if ( this . nop ) {
109+ resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . update . endpoint ( this . settings ) , 'Update Repo' ) )
110+ return this . updateSecurity ( resp . data , resArray )
111+ }
112+
113+ return this . updateSecurity ( await this . github . repos . update ( this . settings ) , resArray )
114+ } )
106115 }
107116 if ( topicChanges . hasChanges ) {
108117 promises . push ( this . updatetopics ( resp . data , resArray ) )
@@ -156,7 +165,7 @@ module.exports = class Repository {
156165 } )
157166 }
158167
159- renameBranch ( oldname , newname ) {
168+ renameBranch ( oldname , newname ) {
160169 const parms = {
161170 owner : this . settings . owner ,
162171 repo : this . settings . repo ,
@@ -172,16 +181,7 @@ module.exports = class Repository {
172181 return this . github . repos . renameBranch ( parms )
173182 }
174183
175- updaterepo ( resArray ) {
176- this . log . debug ( `Updating repo with settings ${ JSON . stringify ( this . topics ) } ${ JSON . stringify ( this . settings ) } ` )
177- if ( this . nop ) {
178- resArray . push ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . update . endpoint ( this . settings ) , 'Update Repo' ) )
179- return Promise . resolve ( resArray )
180- }
181- return this . github . repos . update ( this . settings )
182- }
183-
184- updatetopics ( repoData , resArray ) {
184+ updatetopics ( repoData , resArray ) {
185185 const parms = {
186186 owner : this . settings . owner ,
187187 repo : this . settings . repo ,
@@ -212,7 +212,7 @@ module.exports = class Repository {
212212 }
213213
214214 // Added support for Code Security and Analysis
215- updateSecurity ( repoData , resArray ) {
215+ updateSecurity ( repoData , resArray ) {
216216 if ( this . security ) {
217217 this . log ( `Found repo with security settings ${ JSON . stringify ( this . security ) } ` )
218218 if ( this . security ?. enableVulnerabilityAlerts === true || this . security ?. enableVulnerabilityAlerts === false ) {
0 commit comments