Skip to content

Commit

Permalink
fix(prepare): throw with --yes when git tag is missing (#570)
Browse files Browse the repository at this point in the history
* fix: throw with --yes when git tag is missing

* chore: update message

* chore: relocate a chunk of code

* chore: update error message
  • Loading branch information
Eunjae Lee authored Dec 31, 2019
1 parent 77b4569 commit cee5f35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/shipjs/src/flow/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async function prepare({
fetchTags({ dir, dryRun });
push({ remote, currentBranch: baseBranch, dir, dryRun });
const { revisionRange } = await getRevisionRange({
yes,
commitFrom,
currentVersion,
dir,
Expand Down
21 changes: 17 additions & 4 deletions packages/shipjs/src/step/prepare/getRevisionRange.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import inquirer from 'inquirer';
import { hasTag, silentExec } from 'shipjs-lib';
import runStep from '../runStep';
import { print } from '../../util';
import { info, warning } from '../../color';
import { print, exitProcess } from '../../util';
import { info, warning, error } from '../../color';

export default async ({ commitFrom, currentVersion, dir }) =>
export default async ({ yes, commitFrom, currentVersion, dir }) =>
await runStep(
{ title: 'Getting a revision range for this release.' },
async () => {
Expand All @@ -20,7 +20,20 @@ export default async ({ commitFrom, currentVersion, dir }) =>
return { revisionRange };
}

print(warning(`Git tag 'v${currentVersion}' doesn't exist.`));
const tagNotExistingMessage = `Git tag 'v${currentVersion}' doesn't exist.`;
if (yes) {
print(error(tagNotExistingMessage));
print(
info(
'Ship.js cannot figure out since which commit you want to release.'
)
);
print(info('Try again with the following option added:'));
print(info(' --commit-from SHA'));
exitProcess(1);
}

print(warning(tagNotExistingMessage));
const commits = silentExec(`git log --pretty=format:"%h%d %s"`, {
dir,
})
Expand Down

0 comments on commit cee5f35

Please sign in to comment.