From 04671a6a0530cd6e01c43448dcb9d5513c471fb2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 20 Sep 2022 12:52:12 +0200 Subject: [PATCH] fix: use release version in changelog title --- CHANGELOG.md | 10 +++++----- README.md | 1 + src/cli.ts | 3 ++- src/markdown.ts | 8 ++++++-- test/git.test.ts | 4 +++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 243d95e..9f8dd7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [0.3.1](https://github.com/unjs/changelogen/compare/v0.3.0...main) +## [0.3.1](https://github.com/unjs/changelogen/compare/v0.3.0...v0.3.1) ### 🚀 Enhancements @@ -18,7 +18,7 @@ All notable changes to this project will be documented in this file. See [standa - Ahad Birang - Pooya Parsa -## [main](https://github.com/unjs/changelogen/compare/v0.2.3...main) +## [0.3.0](https://github.com/unjs/changelogen/compare/v0.2.3...v0.3.0) ### 🚀 Enhancements @@ -33,7 +33,7 @@ All notable changes to this project will be documented in this file. See [standa - Pooya Parsa -## [main](https://github.com/unjs/changelogen/compare/v0.2.2...main) +## [0.2.3](https://github.com/unjs/changelogen/compare/v0.2.2...v0.2.3) ### 🩹 Fixes @@ -44,7 +44,7 @@ All notable changes to this project will be documented in this file. See [standa - Pooya Parsa -## [main](https://github.com/unjs/changelogen/compare/v0.2.1...main) +## [0.2.2](https://github.com/unjs/changelogen/compare/v0.2.1...v0.2.2) ### 🚀 Enhancements @@ -59,7 +59,7 @@ All notable changes to this project will be documented in this file. See [standa - Pooya Parsa -## [main](https://github.com/unjs/changelogen/compare/v0.2.0...main) +## [0.2.1](https://github.com/unjs/changelogen/compare/v0.2.0...v0.2.1) ### 🩹 Fixes diff --git a/README.md b/README.md index bb5e545..e67c819 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ npx changelogen@latest [...args] [] - `--output`: Changelog file name to create or update. Defaults to `CHANGELOG.md` and resolved relative to rootDir. Use `--no-output` to write to console only. - `--bump`: Determine semver change and update version in `package.json`. - `--release`. Bumps version in `package.json` and creates commit and git tags using local `git`. You can disable commit using `--no-commit` and tag using `--no-tag`. +- `-r`: Release as specific version. ## Configuration diff --git a/src/cli.ts b/src/cli.ts index 08098a7..f2a97af 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -36,7 +36,8 @@ async function main () { if (args.bump || args.release) { const newVersion = await bumpVersion(commits, config) if (!newVersion) { - throw new Error('Unable to bump version based on changes.') + consola.error('Unable to bump version based on changes.') + process.exit(1) } config.newVersion = newVersion } diff --git a/src/markdown.ts b/src/markdown.ts index 4c48ebe..4c7c9a5 100644 --- a/src/markdown.ts +++ b/src/markdown.ts @@ -10,11 +10,15 @@ export function generateMarkDown (commits: GitCommit[], config: ChangelogConfig) const breakingChanges = [] // Version Title - const compareLink = config.github ? `https://github.com/${config.github}/compare/${config.from}...${config.to}` : '' + const v = config.newVersion && `v${config.newVersion}` markdown.push('', - '## ' + (compareLink ? `[${config.newVersion || config.to}](${compareLink})` : `${config.to} (${config.from}..${config.to})`) + '## ' + (v || `${config.from}...${config.to}`) , '') + if (config.github) { + markdown.push(`[compare changes](https://github.com/${config.github}/compare/${config.from}...${v || config.to})`, '') + } + for (const type in config.types) { const group = typeGroups[type] if (!group || !group.length) { diff --git a/test/git.test.ts b/test/git.test.ts index eeb96bd..aa110cb 100644 --- a/test/git.test.ts +++ b/test/git.test.ts @@ -115,7 +115,9 @@ describe('git', () => { const md = generateMarkDown(parsed, config) expect(md).toMatchInlineSnapshot(` - "## [27440655a169c2f462d891d2f243db54c174f6b7](https://github.com/unjs/changelogen/compare/31a08615bb7da611dcaefe33b510d23aa7d2cc29...27440655a169c2f462d891d2f243db54c174f6b7) + "## 31a08615bb7da611dcaefe33b510d23aa7d2cc29...27440655a169c2f462d891d2f243db54c174f6b7 + + [compare changes](https://github.com/unjs/changelogen/compare/31a08615bb7da611dcaefe33b510d23aa7d2cc29...27440655a169c2f462d891d2f243db54c174f6b7) ### 🩹 Fixes