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
105105
106106program
107107 . command ( 'start-hotfix' )
108+ . arguments ( '[hotfix-branch]' )
108109 . description ( 'Create new hotfix branch' )
109- . action ( async ( ) => {
110+ . action ( async ( hotfixBranch ) => {
110111 try {
111112 await git . bailIfNotGitDirectory ( ) ;
112- await git . startHotfix ( ) ;
113+ await git . startHotfix ( hotfixBranch ) ;
113114 } catch ( e ) {
114- console . log ( e . message ) ;
115+ console . log ( e . message , e ) ;
115116 }
116117 } ) ;
117118
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ async function startFeature(config) {
265265 console . log ( 'feature branch created successfully' ) ;
266266}
267267
268- async function startHotfix ( ) {
268+ async function startHotfix ( hotfixBranch ) {
269269 if ( ! await isClean ( ) ) {
270270 const { confirm} = await inquirer . confirmStash ( ) ;
271271 if ( confirm ) {
@@ -274,11 +274,21 @@ async function startHotfix() {
274274 throw new Error ( 'Operation aborted.' ) ;
275275 }
276276 }
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+
280290 const baseBranch = 'master' ;
281- const targetBranch = `hotfix/ ${ issueNumber } - ${ refinedHotfix } ` ;
291+ await fetchAll ( ) ;
282292 await checkout ( baseBranch ) ;
283293 await resetHardToRemoteBranch ( `${ DEFAULT_REMOTE } /${ baseBranch } ` ) ;
284294 await createAndCheckoutBranch ( targetBranch ) ;
You can’t perform that action at this time.
0 commit comments