@@ -100,6 +100,30 @@ function diffCollected (options, branchCommits, callback) {
100
100
}
101
101
102
102
103
+ function applyCommits ( list , bail ) {
104
+ const cp = require ( 'child_process' )
105
+
106
+ let i = list . length
107
+ while ( i -- ) {
108
+ const commit = list [ i ]
109
+ const out = cp . spawnSync ( 'git' , [ 'cherry-pick' , commit . sha ] )
110
+
111
+ if ( out . status === 0 ) {
112
+ continue
113
+ }
114
+
115
+ const cleanup = cp . spawnSync ( 'git' , [ 'cherry-pick' , '--abort' ] )
116
+ if ( cleanup . status !== 0 ) {
117
+ console . error ( 'Error resetting git, bailing.' )
118
+ return
119
+ }
120
+
121
+ console . log ( `${ bail ? 'Bailing' : 'Skipping' } : Could not apply ${ commit . sha . slice ( 0 , 7 ) } ... ${ commit . summary } ` )
122
+ if ( bail ) return
123
+ }
124
+ }
125
+
126
+
103
127
function printCommits ( list , simple ) {
104
128
list = list . map ( ( commit ) => commitToOutput ( commit , simple , ghId ) )
105
129
@@ -134,6 +158,7 @@ if (require.main === module) {
134
158
, endRef = argv [ 'end-ref' ]
135
159
, excludeLabels = [ ]
136
160
, options
161
+ , bail = argv . bail
137
162
138
163
if ( argv [ 'patch-only' ] )
139
164
excludeLabels = [ 'semver-minor' , 'semver-major' ]
@@ -149,6 +174,11 @@ if (require.main === module) {
149
174
if ( err )
150
175
throw err
151
176
177
+ if ( argv . apply ) {
178
+ applyCommits ( list , bail )
179
+ return
180
+ }
181
+
152
182
printCommits ( list , simple )
153
183
} )
154
184
}
0 commit comments