Skip to content

Commit

Permalink
fix: use release version in changelog title
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 20, 2022
1 parent 25d8acc commit 04671a6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npx changelogen@latest [...args] [<rootDir>]
- `--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

Expand Down
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 6 additions & 2 deletions src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion test/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04671a6

Please sign in to comment.