diff --git a/git-changelog-generator/src/generator.ts b/git-changelog-generator/src/generator.ts index 7930c8e..87af309 100644 --- a/git-changelog-generator/src/generator.ts +++ b/git-changelog-generator/src/generator.ts @@ -81,7 +81,12 @@ export function generateCommitList( listText += '* ' if ((commit.jiraTicket != null) && (options.jiraUrl != null)) { - listText += `[${commit.jiraTicket}](${options.jiraUrl}/browse/${commit.jiraTicket}) - ` + const isGithubTicket = !isNaN(Number(commit.jiraTicket)) + if (isGithubTicket) { + listText += `[#${commit.jiraTicket}](${options.jiraUrl}/issues/${commit.jiraTicket}) - ` + } else { + listText += `[${commit.jiraTicket}](${options.jiraUrl}/browse/${commit.jiraTicket}) - ` + } } if (commit.scope != null) { diff --git a/git-changelog-generator/test/generator.test.ts b/git-changelog-generator/test/generator.test.ts index b2ed8dc..a98dc34 100644 --- a/git-changelog-generator/test/generator.test.ts +++ b/git-changelog-generator/test/generator.test.ts @@ -491,7 +491,7 @@ test('hide Jira tickets if Jira URL is not provided', () => { expect(actual).toBe(expected) }) -test('show Jira tickets and links if Jira URL is not provided', () => { +test('show Jira tickets and links if Jira URL is provided', () => { const commits = [ createFakeCommit( 'abd0ae703769b889814fc1c896b55e96a1e9dbce', @@ -562,6 +562,77 @@ test('show Jira tickets and links if Jira URL is not provided', () => { expect(actual).toBe(expected) }) +test('show Github tickets and links if Jira (interpted as Github) URL is provided', () => { + const commits = + [ createFakeCommit( + 'abd0ae703769b889814fc1c896b55e96a1e9dbce', + 'fix: lock OnDemandProvider into mutex', + '2018-11-20T08:29:38+01:00', + 'This prevents thread synchronization errors.\n Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + 'fa5e0250f59bf5c8acdab7ae5e8070459a321a1d', + 'test(retrofit): add JUnit dependency', + '2018-11-20T07:57:01+01:00', + 'Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + '962b3eb5cd9c6c9673ab2d818a560fe1a18765bb', + '[#6] feat: use SupervisorJob on ViewModel', + '2018-11-20T07:48:42+01:00', + 'This makes all jobs created by VM independent\n Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + '340762ccc0ac26ab71c0579ac1f2a61211c0140c', + 'feat: make LiveData observing utils inline', + '2018-11-07T07:48:01+01:00', + 'This fixes #5.\n\nSigned-off-by: Matej Drobnič ', + ), + createFakeCommit( + '1ef779cdc35cf5844bb78965658cb818901a61a6', + 'feat: remove ResourceLiveData.setValue deprecation', + '2018-11-07T07:43:33+01:00', + 'Synchronous updating of LiveData still has its own uses, provided it is called on UI thread and outside any general try/catch blocks.\n Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + '017ffa996837a25851f695203320cc268a4fdb2e', + 'docs: add SectionRecyclerAdapter.getInnerPosition docs', + '2018-11-07T07:42:04+01:00', + 'Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + 'a1a2f8b747ac2f93afd03455da27d1008277050b', + 'docs: add experimental suppress explanation', + '2018-11-07T07:30:23+01:00', + 'Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + '33a28b0fcf73dabf01395488ac1c4663ef06b162', + 'feat: add RxCoroutinesTimeMachine', + '2018-11-05T14:20:25+01:00', + 'Signed-off-by: Matej Drobnič ', + ), + createFakeCommit( + 'c5062acebab8775afb400f42b27ee5dcc6ef4106', + 'test: add RxCoroutinesTimeMachine', + '2018-11-05T08:49:12+01:00', + ), + createFakeCommit( + '817668bf18e9a8292a6baf87740a583b95f7173f', + 'fix(android): PreferenceProperty null default crash', + '2018-09-26T13:37:48+02:00', + 'This fixes bug where PreferenceProperty type is one of the Java\'s primitive types (int, long etc.) and its default value is null. Crash occures when trying to read non-null value from the preferences.', +),] + + const expected = fs.readFileSync('test/test-files/example-minor-release-with-ticket-and-github-links-changelog.txt').toString().trim() + const actual = generateChangelog(commits, { + gitCommitUrlPrefix: 'http://hydra/testProject/commit/', + jiraUrl: 'https://github.com/inovait/myproject' + }) + + expect(actual).toBe(expected) +}) + test('Show unimportant commits if they have Jira tickets assigned', () => { const commits = [ createFakeCommit( diff --git a/git-changelog-generator/test/test-files/example-minor-release-with-ticket-and-github-links-changelog.txt b/git-changelog-generator/test/test-files/example-minor-release-with-ticket-and-github-links-changelog.txt new file mode 100644 index 0000000..86f2830 --- /dev/null +++ b/git-changelog-generator/test/test-files/example-minor-release-with-ticket-and-github-links-changelog.txt @@ -0,0 +1,11 @@ +### Features + +* add RxCoroutinesTimeMachine ([33a28b0f](http://hydra/testProject/commit/33a28b0fcf73dabf01395488ac1c4663ef06b162)) +* remove ResourceLiveData.setValue deprecation ([1ef779cd](http://hydra/testProject/commit/1ef779cdc35cf5844bb78965658cb818901a61a6)) +* [#5](https://github.com/inovait/myproject/issues/5) - make LiveData observing utils inline ([340762cc](http://hydra/testProject/commit/340762ccc0ac26ab71c0579ac1f2a61211c0140c)) +* [#6](https://github.com/inovait/myproject/issues/6) - use SupervisorJob on ViewModel ([962b3eb5](http://hydra/testProject/commit/962b3eb5cd9c6c9673ab2d818a560fe1a18765bb)) + +### Bug Fixes + +* **android**: PreferenceProperty null default crash ([817668bf](http://hydra/testProject/commit/817668bf18e9a8292a6baf87740a583b95f7173f)) +* lock OnDemandProvider into mutex ([abd0ae70](http://hydra/testProject/commit/abd0ae703769b889814fc1c896b55e96a1e9dbce))