Skip to content

Commit

Permalink
feat(git-changelog-generator): add support for Github tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
matejdro committed Jun 21, 2024
1 parent da6478d commit 8c0ed24
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
7 changes: 6 additions & 1 deletion git-changelog-generator/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
73 changes: 72 additions & 1 deletion git-changelog-generator/test/generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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č <matej.drobnic@inova.si>',
),
createFakeCommit(
'fa5e0250f59bf5c8acdab7ae5e8070459a321a1d',
'test(retrofit): add JUnit dependency',
'2018-11-20T07:57:01+01:00',
'Signed-off-by: Matej Drobnič <matej.drobnic@inova.si>',
),
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č <matej.drobnic@inova.si>',
),
createFakeCommit(
'340762ccc0ac26ab71c0579ac1f2a61211c0140c',
'feat: make LiveData observing utils inline',
'2018-11-07T07:48:01+01:00',
'This fixes #5.\n\nSigned-off-by: Matej Drobnič <matej.drobnic@inova.si>',
),
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č <matej.drobnic@inova.si>',
),
createFakeCommit(
'017ffa996837a25851f695203320cc268a4fdb2e',
'docs: add SectionRecyclerAdapter.getInnerPosition docs',
'2018-11-07T07:42:04+01:00',
'Signed-off-by: Matej Drobnič <matej.drobnic@inova.si>',
),
createFakeCommit(
'a1a2f8b747ac2f93afd03455da27d1008277050b',
'docs: add experimental suppress explanation',
'2018-11-07T07:30:23+01:00',
'Signed-off-by: Matej Drobnič <matej.drobnic@inova.si>',
),
createFakeCommit(
'33a28b0fcf73dabf01395488ac1c4663ef06b162',
'feat: add RxCoroutinesTimeMachine',
'2018-11-05T14:20:25+01:00',
'Signed-off-by: Matej Drobnič <matej.drobnic@inova.si>',
),
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 8c0ed24

Please sign in to comment.