Skip to content

Commit

Permalink
Use = and & in compare URLs ( #131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain DAZY committed Sep 27, 2019
1 parent 781955f commit bc31d42
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/generate-test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ async function run () {
const releases = parseReleases(commits, remotes.github, null, options)
const commitsNoRemote = parseCommits(gitLog, remotes.null, options)
const releasesNoRemote = parseReleases(commitsNoRemote, remotes.null, null, options)
const commitsBitbucketCorporate = parseCommits(gitLog, remotes.bitbucketCorporate, options)
const releasesBitbucketCorporate = parseReleases(commitsBitbucketCorporate, remotes.bitbucketCorporate, null, options)
await writeObject('commits.js', commits)
await writeObject('commits-no-remote.js', commitsNoRemote)
await writeObject('commits-bitbucket-corporate.js', commitsBitbucketCorporate)
await writeObject('releases.js', releases)
await writeTemplate('template-compact.md', 'compact', releases)
await writeTemplate('template-keepachangelog.md', 'keepachangelog', releases)
await writeTemplate('template-json.json', 'json', releases)
await writeTemplate('template-compact-no-remote.md', 'compact', releasesNoRemote)
await writeTemplate('template-compact-bitbucket-corporate.md', 'compact', releasesBitbucketCorporate)
}

run().catch(e => console.error(e))
3 changes: 3 additions & 0 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ function cleanTemplate (template) {
// Fix multiple blank lines
.replace(/\n\n\n+/g, '\n\n')
.replace(/\n\n$/, '\n')
// Fix release comparison URLs for corporate Bitbucket servers
.replace(/=/g, '=')
.replace(/&/g, '&')
}

export async function compileTemplate ({ template, handlebarsSetup }, data) {
Expand Down
310 changes: 310 additions & 0 deletions test/data/commits-bitbucket-corporate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
export default [
{
"hash": "2401ee4706e94629f48830bab9ed5812c032734a",
"shorthash": "2401ee4",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T21:57:19.000Z",
"tag": null,
"subject": "Unreleased commit",
"message": "Unreleased commit\n\nFixes #6",
"fixes": [
{
"id": "6",
"href": "https://example.com/git/users/issues/6",
"author": "Pete Cook"
}
],
"href": "https://example.com/git/users/commit/2401ee4706e94629f48830bab9ed5812c032734a",
"breaking": false,
"files": 5,
"insertions": 10,
"deletions": 10,
"merge": null
},
{
"hash": "77bb243170408cd18e70ca05bf8b3ca7646ea437",
"shorthash": "77bb243",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T12:03:09.000Z",
"tag": "v1.0.0",
"subject": "1.0.0",
"message": "1.0.0\n\nThis is my major release description.\n\n- And a bullet point",
"fixes": null,
"href": "https://example.com/git/users/commit/77bb243170408cd18e70ca05bf8b3ca7646ea437",
"breaking": false,
"files": 2,
"insertions": 8,
"deletions": 2,
"merge": null
},
{
"hash": "b0b304049847d9568585bc11399fa6cfa4cab5dc",
"shorthash": "b0b3040",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T21:57:19.000Z",
"tag": null,
"subject": "Some breaking change",
"message": "Some breaking change",
"fixes": null,
"href": "https://example.com/git/users/commit/b0b304049847d9568585bc11399fa6cfa4cab5dc",
"breaking": false,
"files": 5,
"insertions": 10,
"deletions": 10,
"merge": null
},
{
"hash": "db92947e6129cc20cd7777b7ed90b2bd547918c0",
"shorthash": "db92947",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T21:19:17.000Z",
"tag": "v0.1.0",
"subject": "0.1.0",
"message": "0.1.0",
"fixes": null,
"href": "https://example.com/git/users/commit/db92947e6129cc20cd7777b7ed90b2bd547918c0",
"breaking": false,
"files": 2,
"insertions": 8,
"deletions": 2,
"merge": null
},
{
"hash": "e9a43b2bf50449fc0d84465308e6008cc1597bb3",
"shorthash": "e9a43b2",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T21:19:19.000Z",
"tag": null,
"subject": "Another commit that fixes nothing but with less changes",
"message": "Another commit that fixes nothing but with less changes",
"fixes": null,
"href": "https://example.com/git/users/commit/e9a43b2bf50449fc0d84465308e6008cc1597bb3",
"breaking": false,
"files": 1,
"insertions": 1,
"deletions": 1,
"merge": null
},
{
"hash": "12c0624e7e419a70bd5f3b403d7e0bd8f23ec617",
"shorthash": "12c0624",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T21:18:19.000Z",
"tag": null,
"subject": "Commit that fixes nothing with `backticks` and <html>",
"message": "Commit that fixes nothing with `backticks` and <html>",
"fixes": null,
"href": "https://example.com/git/users/commit/12c0624e7e419a70bd5f3b403d7e0bd8f23ec617",
"breaking": false,
"files": 1,
"insertions": 2,
"deletions": 3,
"merge": null
},
{
"hash": "ef17dcc732d282f027aa3bddf8f91cbb05998cc8",
"shorthash": "ef17dcc",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-28T21:17:17.000Z",
"tag": "v0.0.2",
"subject": "0.0.2",
"message": "0.0.2",
"fixes": null,
"href": "https://example.com/git/users/commit/ef17dcc732d282f027aa3bddf8f91cbb05998cc8",
"breaking": false,
"files": 2,
"insertions": 8,
"deletions": 2,
"merge": null
},
{
"hash": "0e24bf427a51eac52133cc731b4b5d74a7e04672",
"shorthash": "0e24bf4",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-24T20:29:22.000Z",
"tag": null,
"subject": "Merge pull request #5 from repo/branch",
"message": "Merge pull request #5 from repo/branch\n\nShould not parse #4 in PR title",
"fixes": null,
"href": "https://example.com/git/users/commit/0e24bf427a51eac52133cc731b4b5d74a7e04672",
"breaking": false,
"merge": {
"id": "5",
"message": "Should not parse #4 in PR title",
"href": "https://example.com/git/users/pull/5",
"author": "Pete Cook",
"commit": {
"hash": "0e24bf427a51eac52133cc731b4b5d74a7e04672",
"shorthash": "0e24bf4",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-24T20:29:22.000Z",
"tag": null,
"subject": "Merge pull request #5 from repo/branch",
"message": "Merge pull request #5 from repo/branch\n\nShould not parse #4 in PR title",
"fixes": null,
"href": "https://example.com/git/users/commit/0e24bf427a51eac52133cc731b4b5d74a7e04672",
"breaking": false
}
}
},
{
"hash": "92839699a6aaea148dcd72ea897321e66cae0c18",
"shorthash": "9283969",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-29T11:35:54.000Z",
"tag": null,
"subject": "Merge remote-tracking branch 'random-branch' into master",
"message": "Merge remote-tracking branch 'random-branch' into master",
"fixes": null,
"href": "https://example.com/git/users/commit/92839699a6aaea148dcd72ea897321e66cae0c18",
"breaking": false,
"files": 1,
"insertions": 1,
"deletions": 0,
"merge": null
},
{
"hash": "17fbef87e82889f01d8257900f7edc55b05918a2",
"shorthash": "17fbef8",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-28T11:35:54.000Z",
"tag": null,
"subject": "Commit 4 fixes #4 in the subject",
"message": "Commit 4 fixes #4 in the subject\n\nWith some extra notes here",
"fixes": [
{
"id": "4",
"href": "https://example.com/git/users/issues/4",
"author": "Pete Cook"
}
],
"href": "https://example.com/git/users/commit/17fbef87e82889f01d8257900f7edc55b05918a2",
"breaking": false,
"files": 1,
"insertions": 1,
"deletions": 0,
"merge": null
},
{
"hash": "796edd129a6aaea148dcd72ea897321e66cae0c1",
"shorthash": "796edd1",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T12:03:09.000Z",
"tag": "v0.0.1",
"subject": "0.0.1",
"message": "0.0.1",
"fixes": null,
"href": "https://example.com/git/users/commit/796edd129a6aaea148dcd72ea897321e66cae0c1",
"breaking": false,
"files": 2,
"insertions": 8,
"deletions": 2,
"merge": null
},
{
"hash": "31b7d3da24d64e32a0a7e558f254d01c348613f3",
"shorthash": "31b7d3d",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T11:37:05.000Z",
"tag": null,
"subject": "Merge pull request #3 from repo/branch",
"message": "Merge pull request #3 from repo/branch\n\nThird commit with same name as PR",
"fixes": null,
"href": "https://example.com/git/users/commit/31b7d3da24d64e32a0a7e558f254d01c348613f3",
"breaking": false,
"merge": {
"id": "3",
"message": "Third commit with same name as PR",
"href": "https://example.com/git/users/pull/3",
"author": "Pete Cook",
"commit": {
"hash": "31b7d3da24d64e32a0a7e558f254d01c348613f3",
"shorthash": "31b7d3d",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T11:37:05.000Z",
"tag": null,
"subject": "Merge pull request #3 from repo/branch",
"message": "Merge pull request #3 from repo/branch\n\nThird commit with same name as PR",
"fixes": null,
"href": "https://example.com/git/users/commit/31b7d3da24d64e32a0a7e558f254d01c348613f3",
"breaking": false
}
}
},
{
"hash": "1c2694e44a032d2ab6d6eaa381beaf23ba3d9573",
"shorthash": "1c2694e",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T11:31:06.000Z",
"tag": null,
"subject": "Third commit with same name as PR",
"message": "Third commit with same name as PR",
"fixes": null,
"href": "https://example.com/git/users/commit/1c2694e44a032d2ab6d6eaa381beaf23ba3d9573",
"breaking": false,
"files": 8,
"insertions": 57,
"deletions": 53,
"merge": null
},
{
"hash": "90ef33485369fc7892d11b2e4da04ffb64df1e99",
"shorthash": "90ef334",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-15T11:31:06.000Z",
"tag": null,
"subject": "Second commit",
"message": "Second commit\n\nResolves #1 and fixes https://github.com/user/repo/issues/2",
"fixes": [
{
"id": "1",
"href": "https://example.com/git/users/issues/1",
"author": "Pete Cook"
},
{
"id": "2",
"href": "https://github.com/user/repo/issues/2",
"author": "Pete Cook"
}
],
"href": "https://example.com/git/users/commit/90ef33485369fc7892d11b2e4da04ffb64df1e99",
"breaking": false,
"files": 8,
"insertions": 57,
"deletions": 53,
"merge": null
},
{
"hash": "158fdde54b6188c9f9ca3034e9cb5bcc3fe3ff69",
"shorthash": "158fdde",
"author": "Pete Cook",
"email": "[email protected]",
"date": "2015-12-14T17:06:12.000Z",
"tag": null,
"subject": "First commit",
"message": "First commit",
"fixes": null,
"href": "https://example.com/git/users/commit/158fdde54b6188c9f9ca3034e9cb5bcc3fe3ff69",
"breaking": false,
"files": 7,
"insertions": 37,
"deletions": 22,
"merge": null
}
]
3 changes: 3 additions & 0 deletions test/data/remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default {
gitlab: getRemote('https://gitlab.com/user/repo'),
gitlabSubgroup: getRemote('https://gitlab.com/user/repo/subgroup.git'),
bitbucket: getRemote('https://bitbucket.org/user/repo'),
bitbucketCorporate: getRemote('https://example.com/git/users/user/repos/repo',{
compareUrl: 'https://example.com/git/users/user/repos/repo/compare/commits?targetBranch=refs/heads/{from}&sourceBranch=refs/heads/{to}'
}),
azure: getRemote('https://dev.azure.com/user/project/_git/repo'),
visualstudio: getRemote('https://user.visualstudio.com/project/_git/repo')
}
33 changes: 33 additions & 0 deletions test/data/template-compact-bitbucket-corporate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [v1.0.0](https://example.com/git/users/user/repos/repo/compare/commits?targetBranch=refs/heads/v0.1.0&sourceBranch=refs/heads/v1.0.0)

> 15 December 2015
- Some breaking change [`b0b3040`](https://example.com/git/users/commit/b0b304049847d9568585bc11399fa6cfa4cab5dc)

#### [v0.1.0](https://example.com/git/users/user/repos/repo/compare/commits?targetBranch=refs/heads/v0.0.2&sourceBranch=refs/heads/v0.1.0)

> 29 December 2015
- Commit that fixes nothing with `backticks` and <html> [`12c0624`](https://example.com/git/users/commit/12c0624e7e419a70bd5f3b403d7e0bd8f23ec617)
- Another commit that fixes nothing but with less changes [`e9a43b2`](https://example.com/git/users/commit/e9a43b2bf50449fc0d84465308e6008cc1597bb3)

#### [v0.0.2](https://example.com/git/users/user/repos/repo/compare/commits?targetBranch=refs/heads/v0.0.1&sourceBranch=refs/heads/v0.0.2)

> 28 December 2015
- Should not parse #4 in PR title [`#5`](https://example.com/git/users/pull/5)
- Commit 4 fixes #4 in the subject [`#4`](https://example.com/git/users/issues/4)

#### v0.0.1

> 15 December 2015
- Third commit with same name as PR [`#3`](https://example.com/git/users/pull/3)
- Second commit [`#1`](https://example.com/git/users/issues/1) [`#2`](https://github.com/user/repo/issues/2)
- First commit [`158fdde`](https://example.com/git/users/commit/158fdde54b6188c9f9ca3034e9cb5bcc3fe3ff69)
5 changes: 5 additions & 0 deletions test/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('parseReleases', () => {
expect(releases[0].href).to.equal('https://bitbucket.org/user/repo/compare/v1.0.0..v0.1.0')
})

it('parses bitbucket corporate releases', () => {
const releases = parseReleases(commits, remotes.bitbucketCorporate, null, options)
expect(releases[0].href).to.equal('https://example.com/git/users/user/repos/repo/compare/commits?targetBranch=refs/heads/v0.1.0&sourceBranch=refs/heads/v1.0.0')
})

it('parses azure devops releases', () => {
const releases = parseReleases(commits, remotes.azure, null, options)
expect(releases[0].href).to.equal('https://dev.azure.com/user/project/_git/repo/branches?baseVersion=GTv1.0.0&targetVersion=GTv0.1.0&_a=commits')
Expand Down
Loading

0 comments on commit bc31d42

Please sign in to comment.