@@ -50,7 +50,7 @@ module.exports = class Repository {
50
50
this . topics = this . settings . topics
51
51
this . security = this . settings . security
52
52
this . repo = repo
53
- this . log = log
53
+ this . log = log . child ( { context : 'Repository' , repository : this . repo . repo } )
54
54
this . nop = nop
55
55
this . force_create = this . settings . force_create
56
56
this . template = this . settings . template
@@ -82,18 +82,18 @@ module.exports = class Repository {
82
82
this . log . debug ( `Result of comparing topics for changes source ${ JSON . stringify ( resp . data . topics ) } target ${ JSON . stringify ( this . topics ) } = ${ topicResults } ` )
83
83
84
84
if ( this . nop && changes . hasChanges ) {
85
- resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `Repo settings changes: ${ results } ` ) )
85
+ resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `[ ${ this . settings . name } ] Repo settings changes: ${ results } ` ) )
86
86
}
87
87
if ( this . nop && topicChanges . hasChanges ) {
88
- resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `Repo topics changes ${ topicResults } ` ) )
88
+ resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `[ ${ this . settings . name } ] Repo topics changes ${ topicResults } ` ) )
89
89
}
90
90
const promises = [ ]
91
91
if ( changes . hasChanges ) {
92
92
this . log . debug ( 'There are repo changes' )
93
93
if ( this . settings . default_branch && ( resp . data . default_branch !== this . settings . default_branch ) ) {
94
94
this . log . debug ( 'There is a rename of the default branch' )
95
95
if ( this . nop ) {
96
- resArray . push ( new NopCommand ( 'Repository' , this . repo , this . github . repos . renameBranch . endpoint ( resp . data . default_branch , this . settings . default_branch ) , `Repo rename default branch to ${ this . settings . default_branch } ` ) )
96
+ resArray . push ( new NopCommand ( 'Repository' , this . repo , this . github . repos . renameBranch . endpoint ( resp . data . default_branch , this . settings . default_branch ) , `[ ${ this . settings . name } ] Repo rename default branch to ${ this . settings . default_branch } ` ) )
97
97
} else {
98
98
promises . push ( this . renameBranch ( resp . data . default_branch , this . settings . default_branch ) )
99
99
}
@@ -114,7 +114,7 @@ module.exports = class Repository {
114
114
} else {
115
115
this . log . debug ( `There are no changes for repo ${ JSON . stringify ( this . repo ) } .` )
116
116
if ( this . nop ) {
117
- resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `There are no changes for repo ${ JSON . stringify ( this . repo ) } .` ) )
117
+ resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `[ ${ this . settings . name } ] There are no changes for repo ${ JSON . stringify ( this . repo ) } .` ) )
118
118
}
119
119
}
120
120
if ( this . nop ) {
@@ -126,7 +126,7 @@ module.exports = class Repository {
126
126
if ( e . status === 404 ) {
127
127
if ( this . force_create ) {
128
128
if ( this . template ) {
129
- this . log ( `Creating repo using template ${ this . template } ` )
129
+ this . log . debug ( `Creating repo using template ${ this . template } ` )
130
130
const options = { template_owner : this . repo . owner , template_repo : this . template , owner : this . repo . owner , name : this . repo . repo , private : ( this . settings . private ? this . settings . private : true ) , description : this . settings . description ? this . settings . description : '' }
131
131
132
132
if ( this . nop ) {
@@ -139,7 +139,7 @@ module.exports = class Repository {
139
139
// https://docs.github.com/en/rest/repos/repos#create-an-organization-repository uses org instead of owner like
140
140
// the API to create a repo with a template
141
141
this . settings . org = this . settings . owner
142
- this . log ( 'Creating repo with settings ' , this . settings )
142
+ this . log . debug ( 'Creating repo with settings ' , this . settings )
143
143
if ( this . nop ) {
144
144
this . log . debug ( `Creating Repo ${ JSON . stringify ( this . github . repos . createInOrg . endpoint ( this . settings ) ) } ` )
145
145
return Promise . resolve ( [
@@ -162,19 +162,19 @@ module.exports = class Repository {
162
162
}
163
163
164
164
renameBranch ( oldname , newname ) {
165
- const parms = {
165
+ const params = {
166
166
owner : this . settings . owner ,
167
167
repo : this . settings . repo ,
168
168
branch : oldname ,
169
169
new_name : newname
170
170
}
171
- this . log . debug ( `Rename default branch repo with settings ${ JSON . stringify ( parms ) } ` )
171
+ this . log . debug ( `Rename default branch repo with settings ${ JSON . stringify ( params ) } ` )
172
172
if ( this . nop ) {
173
173
return Promise . resolve ( [
174
- new NopCommand ( this . constructor . name , this . repo , this . github . repos . renameBranch . endpoint ( parms ) , 'Rename Branch' )
174
+ new NopCommand ( this . constructor . name , this . repo , this . github . repos . renameBranch . endpoint ( params ) , 'Rename Branch' )
175
175
] )
176
176
}
177
- return this . github . repos . renameBranch ( parms )
177
+ return this . github . repos . renameBranch ( params )
178
178
}
179
179
180
180
updaterepo ( resArray ) {
@@ -199,14 +199,14 @@ module.exports = class Repository {
199
199
if ( this . topics ) {
200
200
if ( repoData . data ?. topics . length !== this . topics . length ||
201
201
! repoData . data ?. topics . every ( t => this . topics . includes ( t ) ) ) {
202
- this . log ( `Updating repo with topics ${ this . topics . join ( ',' ) } ` )
202
+ this . log . debug ( `Updating repo with topics ${ this . topics . join ( ',' ) } ` )
203
203
if ( this . nop ) {
204
204
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . replaceAllTopics . endpoint ( parms ) , 'Update Topics' ) ) )
205
205
return Promise . resolve ( resArray )
206
206
}
207
207
return this . github . repos . replaceAllTopics ( parms )
208
208
} else {
209
- this . log ( `no need to update topics for ${ repoData . data . name } ` )
209
+ this . log . debug ( `no need to update topics for ${ repoData . data . name } ` )
210
210
if ( this . nop ) {
211
211
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , null , `no need to update topics for ${ repoData . data . name } ` ) ) )
212
212
return Promise . resolve ( resArray )
@@ -218,9 +218,9 @@ module.exports = class Repository {
218
218
// Added support for Code Security and Analysis
219
219
updateSecurity ( repoData , resArray ) {
220
220
if ( this . security ?. enableVulnerabilityAlerts === true || this . security ?. enableVulnerabilityAlerts === false ) {
221
- this . log ( `Found repo with security settings ${ JSON . stringify ( this . security ) } ` )
221
+ this . log . debug ( `Found repo with security settings ${ JSON . stringify ( this . security ) } ` )
222
222
if ( this . security . enableVulnerabilityAlerts === true ) {
223
- this . log ( `Enabling Dependabot alerts for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
223
+ this . log . debug ( `Enabling Dependabot alerts for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
224
224
if ( this . nop ) {
225
225
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . enableVulnerabilityAlerts . endpoint ( {
226
226
owner : repoData . owner . login ,
@@ -234,7 +234,7 @@ module.exports = class Repository {
234
234
} )
235
235
}
236
236
else {
237
- this . log ( `Disabling Dependabot alerts for for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
237
+ this . log . debug ( `Disabling Dependabot alerts for for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
238
238
if ( this . nop ) {
239
239
resArray . push ( ( new NopCommand ( this . constructor . name , this . github . repos . disableVulnerabilityAlerts . endpoint ( {
240
240
owner : repoData . owner . login ,
@@ -249,7 +249,7 @@ module.exports = class Repository {
249
249
}
250
250
}
251
251
else {
252
- this . log ( `no need to update security for ${ repoData . name } ` )
252
+ this . log . debug ( `no need to update security for ${ repoData . name } ` )
253
253
if ( this . nop ) {
254
254
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , null , `no need to update security for ${ repoData . name } ` ) ) )
255
255
return Promise . resolve ( resArray )
@@ -289,4 +289,4 @@ module.exports = class Repository {
289
289
}
290
290
}
291
291
}
292
- }
292
+ }
0 commit comments