@@ -53,7 +53,7 @@ module.exports = function (app) {
53
53
} )
54
54
}
55
55
56
- function processNextBackport ( ) {
56
+ function processNextBackport ( ) {
57
57
const item = queue . shift ( )
58
58
if ( ! item ) return
59
59
@@ -67,18 +67,18 @@ function processNextBackport() {
67
67
item ( )
68
68
}
69
69
70
- function queueAttemptBackport ( options , version , isLTS ) {
71
- queue . push ( function ( ) {
70
+ function queueAttemptBackport ( options , version , isLTS ) {
71
+ queue . push ( function ( ) {
72
72
options . logger . debug ( `processing a new backport to v${ version } ` )
73
73
attemptBackport ( options , version , isLTS , processNextBackport )
74
74
} )
75
75
}
76
76
77
- function attemptBackport ( options , version , isLTS , cb ) {
77
+ function attemptBackport ( options , version , isLTS , cb ) {
78
78
// Start
79
79
gitAmAbort ( )
80
80
81
- function wrapCP ( cmd , args , opts , callback ) {
81
+ function wrapCP ( cmd , args , opts , callback ) {
82
82
let exited = false
83
83
84
84
if ( arguments . length === 3 ) {
@@ -91,11 +91,11 @@ function attemptBackport(options, version, isLTS, cb) {
91
91
const cp = child_process . spawn ( cmd , args , opts )
92
92
const argsString = [ cmd , ...args ] . join ( ' ' )
93
93
94
- cp . on ( 'error' , function ( err ) {
94
+ cp . on ( 'error' , function ( err ) {
95
95
debug ( `child_process err: ${ err } ` )
96
96
if ( ! exited ) onError ( )
97
97
} )
98
- cp . on ( 'exit' , function ( code ) {
98
+ cp . on ( 'exit' , function ( code ) {
99
99
exited = true
100
100
if ( ! cb ) {
101
101
debug ( `error before exit, code: ${ code } , on '${ argsString } '` )
@@ -119,7 +119,7 @@ function attemptBackport(options, version, isLTS, cb) {
119
119
return cp
120
120
}
121
121
122
- function onError ( ) {
122
+ function onError ( ) {
123
123
if ( ! cb ) return
124
124
const _cb = cb
125
125
setImmediate ( ( ) => {
@@ -133,19 +133,19 @@ function attemptBackport(options, version, isLTS, cb) {
133
133
cb = null
134
134
}
135
135
136
- function gitAmAbort ( ) {
136
+ function gitAmAbort ( ) {
137
137
// TODO(Fishrock123): this should probably just merge into wrapCP
138
138
let exited = false
139
- options . logger . debug ( ` aborting any previous backport attempt...` )
139
+ options . logger . debug ( ' aborting any previous backport attempt...' )
140
140
141
141
const cp = child_process . spawn ( 'git' , [ 'am' , '--abort' ] , { cwd : global . _node_repo_dir } )
142
142
const argsString = 'git am --abort'
143
143
144
- cp . on ( 'error' , function ( err ) {
144
+ cp . on ( 'error' , function ( err ) {
145
145
debug ( `child_process err: ${ err } ` )
146
146
if ( ! exited ) onError ( )
147
147
} )
148
- cp . on ( 'exit' , function ( ) {
148
+ cp . on ( 'exit' , function ( code ) {
149
149
exited = true
150
150
if ( ! cb ) {
151
151
debug ( `error before exit, code: ${ code } , on '${ argsString } '` )
@@ -155,33 +155,33 @@ function attemptBackport(options, version, isLTS, cb) {
155
155
} )
156
156
}
157
157
158
- function gitRemoteUpdate ( ) {
159
- options . logger . debug ( ` updating git remotes...` )
158
+ function gitRemoteUpdate ( ) {
159
+ options . logger . debug ( ' updating git remotes...' )
160
160
wrapCP ( 'git' , [ 'remote' , 'update' , '-p' ] , gitCheckout )
161
161
}
162
162
163
- function gitCheckout ( ) {
163
+ function gitCheckout ( ) {
164
164
options . logger . debug ( `checking out upstream/v${ version } .x-staging...` )
165
165
wrapCP ( 'git' , [ 'checkout' , `upstream/v${ version } .x-staging` ] , gitReset )
166
166
}
167
167
168
- function gitReset ( ) {
168
+ function gitReset ( ) {
169
169
options . logger . debug ( `resetting upstream/v${ version } .x-staging...` )
170
170
wrapCP ( 'git' , [ 'reset' , `upstream/v${ version } .x-staging` , '--hard' ] , fetchDiff )
171
171
}
172
172
173
- function fetchDiff ( ) {
173
+ function fetchDiff ( ) {
174
174
options . logger . debug ( `fetching diff from pr ${ options . prId } ...` )
175
175
176
176
const url = `https://patch-diff.githubusercontent.com/raw/${ options . owner } /${ options . repo } /pull/${ options . prId } .patch`
177
177
178
178
const req = request ( url )
179
179
180
- req . on ( 'error' , function ( err ) {
180
+ req . on ( 'error' , function ( err ) {
181
181
debug ( `request err: ${ err } ` )
182
182
return onError ( )
183
183
} )
184
- req . on ( 'response' , function ( response ) {
184
+ req . on ( 'response' , function ( response ) {
185
185
if ( response . statusCode !== 200 ) {
186
186
debug ( `request non-200 status: ${ response . statusCode } ` )
187
187
return onError ( )
@@ -191,17 +191,17 @@ function attemptBackport(options, version, isLTS, cb) {
191
191
gitAttemptBackport ( req )
192
192
}
193
193
194
- function gitAttemptBackport ( req ) {
194
+ function gitAttemptBackport ( req ) {
195
195
options . logger . debug ( `attempting a backport to v${ version } ...` )
196
- const cp = wrapCP ( 'git' , [ 'am' ] , { stdio : 'pipe' } , function done ( ) {
196
+ const cp = wrapCP ( 'git' , [ 'am' ] , { stdio : 'pipe' } , function done ( ) {
197
197
// Success!
198
198
if ( isLTS ) {
199
199
updatePrWithLabels ( options , [ `lts-watch-v${ version } .x` ] )
200
200
} // else {
201
201
// TODO(Fishrock123): Re-enable this, but do a check first
202
202
// to make sure the label was set by the bot only.
203
203
// removeLabelFromPR(options, `dont-land-on-v${version}.x`)
204
- //}
204
+ // }
205
205
206
206
setImmediate ( ( ) => {
207
207
options . logger . debug ( `backport to v${ version } successful` )
0 commit comments