-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(prepare): ask commit range when tag is missing (#471)
* fix(prepare): ask commit range when tag is missing * fix: update message
- Loading branch information
Eunjae Lee
authored
Nov 30, 2019
1 parent
f9e8712
commit f659c34
Showing
7 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
import { isWorkingTreeClean, getCurrentBranch, hasTag } from 'shipjs-lib'; | ||
import { isWorkingTreeClean, getCurrentBranch } from 'shipjs-lib'; | ||
|
||
const WORKING_TREE_NOT_CLEAN = 'workingTreeNotClean'; | ||
const CURRENT_BRANCH_INCORRECT = 'currentBranchIncorrect'; | ||
const NO_TAG_FOR_CURRENT_VERSION = 'noTagForCurrentVersion'; | ||
|
||
export default function validateBeforePrepare({ | ||
dir, | ||
currentTagName, | ||
baseBranches, | ||
} = {}) { | ||
export default function validateBeforePrepare({ dir, baseBranches } = {}) { | ||
const result = []; | ||
if (!isWorkingTreeClean(dir)) { | ||
result.push(WORKING_TREE_NOT_CLEAN); | ||
} | ||
if (baseBranches.indexOf(getCurrentBranch(dir)) === -1) { | ||
result.push(CURRENT_BRANCH_INCORRECT); | ||
} | ||
if (!hasTag(currentTagName, dir)) { | ||
result.push(NO_TAG_FOR_CURRENT_VERSION); | ||
} | ||
return result.length === 0 ? true : result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import inquirer from 'inquirer'; | ||
import { hasTag, silentExec } from 'shipjs-lib'; | ||
import runStep from '../runStep'; | ||
import { print } from '../../util'; | ||
import { info, warning } from '../../color'; | ||
|
||
export default async ({ currentVersion, dir }) => | ||
await runStep( | ||
{ title: 'Getting a commit range for this release.' }, | ||
async () => { | ||
let commitRange = `v${currentVersion}..HEAD`; | ||
if (hasTag(`v${currentVersion}`, dir)) { | ||
print(info(`✔ ${commitRange}`)); | ||
return { commitRange }; | ||
} | ||
|
||
print(warning(`Git tag 'v${currentVersion}' doesn't exist.`)); | ||
const commits = silentExec(`git log --pretty=format:"%h%d %s"`, { | ||
dir, | ||
}) | ||
.toString() | ||
.split('\n'); | ||
const { answer } = await inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
pageSize: 10, | ||
name: 'answer', | ||
message: 'Since which commit do you want to release?', | ||
choices: commits.map((commit, index) => `${index + 1}) ${commit}`), | ||
}, | ||
]); | ||
const [, commit] = answer.split(' '); | ||
|
||
commitRange = `${commit}..HEAD`; | ||
print(info(`✔ ${commitRange}`)); | ||
return { commitRange }; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters