File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,14 @@ program
105
105
106
106
program
107
107
. command ( 'start-hotfix' )
108
+ . arguments ( '[hotfix-branch]' )
108
109
. description ( 'Create new hotfix branch' )
109
- . action ( async ( ) => {
110
+ . action ( async ( hotfixBranch ) => {
110
111
try {
111
112
await git . bailIfNotGitDirectory ( ) ;
112
- await git . startHotfix ( ) ;
113
+ await git . startHotfix ( hotfixBranch ) ;
113
114
} catch ( e ) {
114
- console . log ( e . message ) ;
115
+ console . log ( e . message , e ) ;
115
116
}
116
117
} ) ;
117
118
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ async function startFeature(config) {
265
265
console . log ( 'feature branch created successfully' ) ;
266
266
}
267
267
268
- async function startHotfix ( ) {
268
+ async function startHotfix ( hotfixBranch ) {
269
269
if ( ! await isClean ( ) ) {
270
270
const { confirm} = await inquirer . confirmStash ( ) ;
271
271
if ( confirm ) {
@@ -274,11 +274,21 @@ async function startHotfix() {
274
274
throw new Error ( 'Operation aborted.' ) ;
275
275
}
276
276
}
277
- const { hotfix, issueNumber} = await inquirer . askIssueNumberAndHotfix ( ) ;
278
- const refinedHotfix = toDashCase ( hotfix ) ;
279
- await fetchAll ( ) ;
277
+
278
+ let targetBranch = hotfixBranch ? `hotfix/${ hotfixBranch } ` : '' ;
279
+ const shouldAsk = targetBranch === '' || ! / ^ \d + - ./ . test ( hotfixBranch ) ;
280
+
281
+ if ( shouldAsk ) {
282
+ if ( hotfixBranch ) {
283
+ console . log ( 'invalid hotfix target branch' ) ;
284
+ }
285
+ const { hotfix, issueNumber} = await inquirer . askIssueNumberAndHotfix ( ) ;
286
+ const refinedHotfix = toDashCase ( hotfix ) ;
287
+ targetBranch = `hotfix/${ issueNumber } -${ refinedHotfix } ` ;
288
+ }
289
+
280
290
const baseBranch = 'master' ;
281
- const targetBranch = `hotfix/ ${ issueNumber } - ${ refinedHotfix } ` ;
291
+ await fetchAll ( ) ;
282
292
await checkout ( baseBranch ) ;
283
293
await resetHardToRemoteBranch ( `${ DEFAULT_REMOTE } /${ baseBranch } ` ) ;
284
294
await createAndCheckoutBranch ( targetBranch ) ;
You can’t perform that action at this time.
0 commit comments