@@ -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
}
@@ -111,7 +111,7 @@ module.exports = class Repository {
111
111
} else {
112
112
this . log . debug ( `There are no changes for repo ${ JSON . stringify ( this . repo ) } .` )
113
113
if ( this . nop ) {
114
- resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `There are no changes for repo ${ JSON . stringify ( this . repo ) } .` ) )
114
+ resArray . push ( new NopCommand ( 'Repository' , this . repo , null , `[ ${ this . settings . name } ] There are no changes for repo ${ JSON . stringify ( this . repo ) } .` ) )
115
115
}
116
116
}
117
117
if ( this . nop ) {
@@ -123,7 +123,7 @@ module.exports = class Repository {
123
123
if ( e . status === 404 ) {
124
124
if ( this . force_create ) {
125
125
if ( this . template ) {
126
- this . log ( `Creating repo using template ${ this . template } ` )
126
+ this . log . debug ( `Creating repo using template ${ this . template } ` )
127
127
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 : '' }
128
128
129
129
if ( this . nop ) {
@@ -136,7 +136,7 @@ module.exports = class Repository {
136
136
// https://docs.github.com/en/rest/repos/repos#create-an-organization-repository uses org instead of owner like
137
137
// the API to create a repo with a template
138
138
this . settings . org = this . settings . owner
139
- this . log ( 'Creating repo with settings ' , this . settings )
139
+ this . log . debug ( 'Creating repo with settings ' , this . settings )
140
140
if ( this . nop ) {
141
141
this . log . debug ( `Creating Repo ${ JSON . stringify ( this . github . repos . createInOrg . endpoint ( this . settings ) ) } ` )
142
142
return Promise . resolve ( [
@@ -159,19 +159,19 @@ module.exports = class Repository {
159
159
}
160
160
161
161
renameBranch ( oldname , newname ) {
162
- const parms = {
162
+ const params = {
163
163
owner : this . settings . owner ,
164
164
repo : this . settings . repo ,
165
165
branch : oldname ,
166
166
new_name : newname
167
167
}
168
- this . log . debug ( `Rename default branch repo with settings ${ JSON . stringify ( parms ) } ` )
168
+ this . log . debug ( `Rename default branch repo with settings ${ JSON . stringify ( params ) } ` )
169
169
if ( this . nop ) {
170
170
return Promise . resolve ( [
171
- new NopCommand ( this . constructor . name , this . repo , this . github . repos . renameBranch . endpoint ( parms ) , 'Rename Branch' )
171
+ new NopCommand ( this . constructor . name , this . repo , this . github . repos . renameBranch . endpoint ( params ) , 'Rename Branch' )
172
172
] )
173
173
}
174
- return this . github . repos . renameBranch ( parms )
174
+ return this . github . repos . renameBranch ( params )
175
175
}
176
176
177
177
updaterepo ( resArray ) {
@@ -196,14 +196,14 @@ module.exports = class Repository {
196
196
if ( this . topics ) {
197
197
if ( repoData . data ?. topics . length !== this . topics . length ||
198
198
! repoData . data ?. topics . every ( t => this . topics . includes ( t ) ) ) {
199
- this . log ( `Updating repo with topics ${ this . topics . join ( ',' ) } ` )
199
+ this . log . debug ( `Updating repo with topics ${ this . topics . join ( ',' ) } ` )
200
200
if ( this . nop ) {
201
201
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . replaceAllTopics . endpoint ( parms ) , 'Update Topics' ) ) )
202
202
return Promise . resolve ( resArray )
203
203
}
204
204
return this . github . repos . replaceAllTopics ( parms )
205
205
} else {
206
- this . log ( `no need to update topics for ${ repoData . data . name } ` )
206
+ this . log . debug ( `no need to update topics for ${ repoData . data . name } ` )
207
207
if ( this . nop ) {
208
208
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , null , `no need to update topics for ${ repoData . data . name } ` ) ) )
209
209
return Promise . resolve ( resArray )
@@ -215,15 +215,15 @@ module.exports = class Repository {
215
215
// Added support for Code Security and Analysis
216
216
updateSecurity ( repoData , resArray ) {
217
217
if ( this . security ) {
218
- this . log ( `Found repo with security settings ${ JSON . stringify ( this . security ) } ` )
218
+ this . log . debug ( `Found repo with security settings ${ JSON . stringify ( this . security ) } ` )
219
219
if ( this . security ?. enableVulnerabilityAlerts === true || this . security ?. enableVulnerabilityAlerts === false ) {
220
220
if ( this . security . enableVulnerabilityAlerts === true ) {
221
- this . log ( `Enabling Dependabot alerts for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
221
+ this . log . debug ( `Enabling Dependabot alerts for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
222
222
if ( this . nop ) {
223
223
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , this . github . repos . enableVulnerabilityAlerts . endpoint ( {
224
224
owner : repoData . owner . login ,
225
225
repo : repoData . name
226
- } ) , 'Update Topics ' ) ) )
226
+ } ) , 'Update Security ' ) ) )
227
227
return Promise . resolve ( resArray )
228
228
}
229
229
return this . github . repos . enableVulnerabilityAlerts ( {
@@ -232,12 +232,12 @@ module.exports = class Repository {
232
232
} )
233
233
}
234
234
if ( this . security . enableVulnerabilityAlerts === false ) {
235
- this . log ( `Disabling Dependabot alerts for for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
235
+ this . log . debug ( `Disabling Dependabot alerts for for owner: ${ repoData . owner . login } and repo ${ repoData . name } ` )
236
236
if ( this . nop ) {
237
237
resArray . push ( ( new NopCommand ( this . constructor . name , this . github . repos . disableVulnerabilityAlerts . endpoint ( {
238
238
owner : repoData . owner . login ,
239
239
repo : repoData . name
240
- } ) , 'Update Topics ' ) ) )
240
+ } ) , 'Update Security ' ) ) )
241
241
return Promise . resolve ( resArray )
242
242
}
243
243
return this . github . repos . disableVulnerabilityAlerts ( {
@@ -246,7 +246,7 @@ module.exports = class Repository {
246
246
} )
247
247
}
248
248
} else {
249
- this . log ( `no need to update security for ${ repoData . name } ` )
249
+ this . log . debug ( `no need to update security for ${ repoData . name } ` )
250
250
if ( this . nop ) {
251
251
resArray . push ( ( new NopCommand ( this . constructor . name , this . repo , null , `no need to update security for ${ repoData . name } ` ) ) )
252
252
return Promise . resolve ( resArray )
0 commit comments