Skip to content

Commit

Permalink
Explicitly render links for PRs and issues
Browse files Browse the repository at this point in the history
GitHub doesn't automatically parse them in markdown files like it does for PRs, issues and comments
  • Loading branch information
cookpete committed Dec 31, 2015
1 parent 7f12f81 commit 0a384cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/templates/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export default class Base {
}

renderMerge = ({ pr, message }) => {
return `* ${pr}: ${message}`
const href = pr.replace('#', this.origin + '/pull/')
return `* [${pr}](${href}): ${message}`
}

renderFixes = (fixes) => {
Expand All @@ -77,7 +78,9 @@ export default class Base {
}

renderFixNumber = (string) => {
return string.replace(this.origin + '/issues/', '#')
const href = string.replace('#', this.origin + '/issues/')
const number = string.replace(this.origin + '/issues/', '#')
return `[${number}](${href})`
}

renderCommits = (commits) => {
Expand All @@ -91,7 +94,9 @@ export default class Base {
}

renderCommit = ({ hash, subject }) => {
return `* ${hash.slice(0, this.commitHashLength)}: ${subject}`
const href = `${this.origin}/commit/${hash}`
const shortHash = hash.slice(0, this.commitHashLength)
return `* [\`${shortHash}\`](${href}): ${subject}`
}

sortCommits = (a, b) => {
Expand Down
10 changes: 5 additions & 5 deletions test/data/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ Generated by [auto-changelog](https://github.com/CookPete/auto-changelog)
## [Unreleased](https://github.com/user/repo/compare/v0.0.2...HEAD)
### Fixed
* #6: Unreleased commit
* [#6](https://github.com/user/repo/issues/6): Unreleased commit
## [v0.0.2](https://github.com/user/repo/compare/v0.0.1...v0.0.2) - 2015-12-28
### Merged
* #5: Should not parse #4 in PR title
* [#5](https://github.com/user/repo/pull/5): Should not parse #4 in PR title
### Fixed
* #4: Commit 4 fixes #4 in the subject
* [#4](https://github.com/user/repo/issues/4): Commit 4 fixes #4 in the subject
## v0.0.1 - 2015-12-15
### Merged
* #3: Pull request title
* [#3](https://github.com/user/repo/pull/3): Pull request title
### Fixed
* #1, #2: Second commit
* [#1](https://github.com/user/repo/issues/1), [#2](https://github.com/user/repo/issues/2): Second commit
`

0 comments on commit 0a384cd

Please sign in to comment.