@crazyfactory/gitflow
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -210,4 +210,4 @@ const Configstore = require('configstore'); | ||
try { | ||
const {stdout, stderr} = await exec('git status --porcelain'); | ||
return !stdout; | ||
const {exitCode} = await exec('git diff --quiet'); | ||
return exitCode !== 0; | ||
} catch (e) { | ||
@@ -247,12 +247,23 @@ return false; | ||
async function startFeature(config, featureBranch) { | ||
if (!await isClean()) { | ||
const {confirm} = await inquirer.confirmStash(); | ||
if (confirm) { | ||
await stash(); | ||
} else { | ||
throw new Error('Operation aborted.'); | ||
} | ||
async function doStash() { | ||
if (await isClean()) { | ||
return; | ||
} | ||
const {stashLabel} = await inquirer.promptStash(); | ||
if (!stashLabel) { | ||
throw new Error('Operation aborted.'); | ||
} | ||
if (stashLabel === '.') { | ||
await checkout('.'); | ||
return; | ||
} | ||
await stash(stashLabel.replace(/"|'/g, '')); | ||
} | ||
async function startFeature(config, featureBranch) { | ||
await doStash(); | ||
const {projectName, sprintNumber} = await inquirer.askProjectNameAndSprintNumber(config); | ||
@@ -280,10 +291,3 @@ const parts = (featureBranch || '').match(/^(\d+)-(.*)/) || []; | ||
async function startHotfix(hotfixBranch) { | ||
if (!await isClean()) { | ||
const {confirm} = await inquirer.confirmStash(); | ||
if (confirm) { | ||
await stash(); | ||
} else { | ||
throw new Error('Operation aborted.'); | ||
} | ||
} | ||
await doStash(); | ||
@@ -312,10 +316,3 @@ let targetBranch = hotfixBranch ? `hotfix/${hotfixBranch}` : ''; | ||
async function startSprint(config, project, sprint) { | ||
if (!await isClean()) { | ||
const {confirm} = await inquirer.confirmStash(); | ||
if (confirm) { | ||
await stash(); | ||
} else { | ||
throw new Error('Operation aborted.'); | ||
} | ||
} | ||
await doStash(); | ||
@@ -342,4 +339,4 @@ const shouldAsk = !project || !/^\d+$/.test(sprint || ''); | ||
async function stash() { | ||
await exec('git stash'); | ||
async function stash(label) { | ||
await exec(`git stash push -m "${label || 'wip'}"`); | ||
} | ||
@@ -346,0 +343,0 @@ |
@@ -96,7 +96,7 @@ const inquirer = require('inquirer'); | ||
}, | ||
confirmStash: () => { | ||
promptStash: () => { | ||
const question = { | ||
message: 'You have some local changes. Say yes if you want to stash and continue, say no if you want to cancel.', | ||
name: 'confirm', | ||
type: 'confirm' | ||
message: 'You have some local changes. Enter label to stash them.\n (Press ENTER to abort process, Type `.` to discard changes and continue.)', | ||
name: 'stashLabel', | ||
type: 'input' | ||
}; | ||
@@ -103,0 +103,0 @@ return inquirer.prompt(question) |
@@ -26,3 +26,3 @@ { | ||
}, | ||
"version": "1.5.0" | ||
"version": "1.6.0" | ||
} |
# Gitflow | ||
## Install | ||
``` | ||
```sh | ||
$ npm install -g @crazyfactory/gitflow | ||
@@ -22,3 +22,3 @@ ``` | ||
### `$ gitflow start-sprint` | ||
### `$ gitflow start-sprint [project] [sprintNum]` | ||
- Create new local sprint branch | ||
@@ -34,3 +34,3 @@ - Branch out from `origin/develop` | ||
### `$ gitflow start-feature` | ||
### `$ gitflow start-feature [feature-branch]` | ||
- Create new local feature branch | ||
@@ -46,3 +46,3 @@ - Branch out from `origin/{project_name}/sprint-{number}` | ||
### `$ gitflow start-hotfix` | ||
### `$ gitflow start-hotfix [hotfix-branch]` | ||
- Create a new local hotfix branch | ||
@@ -49,0 +49,0 @@ - Branch out from `origin/master` |
23961
674