-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #58
- Loading branch information
Showing
6 changed files
with
115 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,73 +92,73 @@ describe('parseCommits', () => { | |
describe('getFixes', () => { | ||
it('returns null with no fixes', () => { | ||
const message = 'Commit message with no fixes' | ||
expect(getFixes(message, remotes.github)).to.equal(null) | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.equal(null) | ||
}) | ||
|
||
it('parses a single fix', () => { | ||
const message = 'Commit that fixes #12' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '12', href: 'https://github.com/user/repo/issues/12' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '12', href: 'https://github.com/user/repo/issues/12', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses fix in commit notes', () => { | ||
const message = 'Commit message\n\nCloses #8' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '8', href: 'https://github.com/user/repo/issues/8' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '8', href: 'https://github.com/user/repo/issues/8', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses a commit that closes a pull request', () => { | ||
const message = 'Commit message\n\nCloses https://github.com/user/repo/pull/14' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/pull/14' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/pull/14', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses a commit that closes a bitbucket pull request', () => { | ||
const message = 'Commit message\n\nCloses https://github.com/user/repo/pull-requests/14' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/pull-requests/14' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/pull-requests/14', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses a commit that closes a gitlab pull request', () => { | ||
const message = 'Commit message\n\nCloses https://github.com/user/repo/merge_requests/14' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/merge_requests/14' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '14', href: 'https://github.com/user/repo/merge_requests/14', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses multiple fixes', () => { | ||
const message = 'Commit message\n\nFixes #1, fix #2, resolved #3, closes #4' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1' }, | ||
{ id: '2', href: 'https://github.com/user/repo/issues/2' }, | ||
{ id: '3', href: 'https://github.com/user/repo/issues/3' }, | ||
{ id: '4', href: 'https://github.com/user/repo/issues/4' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1', author: 'Commit Author' }, | ||
{ id: '2', href: 'https://github.com/user/repo/issues/2', author: 'Commit Author' }, | ||
{ id: '3', href: 'https://github.com/user/repo/issues/3', author: 'Commit Author' }, | ||
{ id: '4', href: 'https://github.com/user/repo/issues/4', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses fixes by issue URL', () => { | ||
const message = 'Commit message\n\nFixes https://github.com/user/repo/issues/1' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses multiple fixes by issue URL', () => { | ||
const message = 'Commit message\n\nFixes https://github.com/user/repo/issues/1 and fixes https://github.com/user/repo/issues/2' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1' }, | ||
{ id: '2', href: 'https://github.com/user/repo/issues/2' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/user/repo/issues/1', author: 'Commit Author' }, | ||
{ id: '2', href: 'https://github.com/user/repo/issues/2', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
it('parses external repo issues', () => { | ||
const message = 'Commit message\n\nFixes https://github.com/other-user/external-repo/issues/1' | ||
expect(getFixes(message, remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/other-user/external-repo/issues/1' } | ||
expect(getFixes(message, 'Commit Author', remotes.github)).to.deep.equal([ | ||
{ id: '1', href: 'https://github.com/other-user/external-repo/issues/1', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
|
@@ -167,8 +167,8 @@ describe('getFixes', () => { | |
issueUrl: 'http://example.com/issues/{id}' | ||
} | ||
const message = 'Commit message\n\nCloses #8' | ||
expect(getFixes(message, remotes.github, options)).to.deep.equal([ | ||
{ id: '8', href: 'http://example.com/issues/8' } | ||
expect(getFixes(message, 'Commit Author', remotes.github, options)).to.deep.equal([ | ||
{ id: '8', href: 'http://example.com/issues/8', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
|
@@ -178,8 +178,8 @@ describe('getFixes', () => { | |
issueUrl: 'http://example.com/issues/{id}' | ||
} | ||
const message = 'Commit message\n\nCloses ABC-1234' | ||
expect(getFixes(message, remotes.github, options)).to.deep.equal([ | ||
{ id: 'ABC-1234', href: 'http://example.com/issues/ABC-1234' } | ||
expect(getFixes(message, 'Commit Author', remotes.github, options)).to.deep.equal([ | ||
{ id: 'ABC-1234', href: 'http://example.com/issues/ABC-1234', author: 'Commit Author' } | ||
]) | ||
}) | ||
|
||
|
@@ -189,55 +189,59 @@ describe('getFixes', () => { | |
issueUrl: 'http://example.com/issues/{id}' | ||
} | ||
const message = 'Commit message\n\nFixes ABC-1234 and fixes ABC-2345 but not BCD-2345' | ||
expect(getFixes(message, remotes.github, options)).to.deep.equal([ | ||
{ id: 'ABC-1234', href: 'http://example.com/issues/ABC-1234' }, | ||
{ id: 'ABC-2345', href: 'http://example.com/issues/ABC-2345' } | ||
expect(getFixes(message, 'Commit Author', remotes.github, options)).to.deep.equal([ | ||
{ id: 'ABC-1234', href: 'http://example.com/issues/ABC-1234', author: 'Commit Author' }, | ||
{ id: 'ABC-2345', href: 'http://example.com/issues/ABC-2345', author: 'Commit Author' } | ||
]) | ||
}) | ||
}) | ||
|
||
describe('getMerge', () => { | ||
it('returns null on fail', () => { | ||
const message = 'Not a merge commit' | ||
expect(getMerge(message, remotes.github)).to.equal(null) | ||
expect(getMerge(message, 'Commit Author', remotes.github)).to.equal(null) | ||
}) | ||
|
||
describe('GitHub', () => { | ||
it('parses a merge', () => { | ||
const message = 'Merge pull request #3 from repo/branch\n\nPull request title' | ||
expect(getMerge(message, remotes.github)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.github)).to.deep.equal({ | ||
id: '3', | ||
message: 'Pull request title', | ||
href: 'https://github.com/user/repo/pull/3' | ||
href: 'https://github.com/user/repo/pull/3', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
|
||
it('parses a squash merge', () => { | ||
const message = 'Update dependencies to enable Greenkeeper 🌴 (#10)\n\n* chore(package): update dependencies' | ||
expect(getMerge(message, remotes.github)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.github)).to.deep.equal({ | ||
id: '10', | ||
message: 'Update dependencies to enable Greenkeeper 🌴', | ||
href: 'https://github.com/user/repo/pull/10' | ||
href: 'https://github.com/user/repo/pull/10', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
|
||
it('parses a squash merge with no message', () => { | ||
const message = 'Generate changelogs that show the commits between tags (#411)' | ||
expect(getMerge(message, remotes.github)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.github)).to.deep.equal({ | ||
id: '411', | ||
message: 'Generate changelogs that show the commits between tags', | ||
href: 'https://github.com/user/repo/pull/411' | ||
href: 'https://github.com/user/repo/pull/411', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
}) | ||
|
||
describe('GitLab', () => { | ||
it('parses a merge', () => { | ||
const message = 'Merge branch \'branch\' into \'master\'\n\nMemoize GitLab logger to reduce open file descriptors\n\nCloses gitlab-ee#3664\n\nSee merge request !15007' | ||
expect(getMerge(message, remotes.gitlab)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.gitlab)).to.deep.equal({ | ||
id: '15007', | ||
message: 'Memoize GitLab logger to reduce open file descriptors', | ||
href: 'https://gitlab.com/user/repo/merge_requests/15007' | ||
href: 'https://gitlab.com/user/repo/merge_requests/15007', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
|
||
|
@@ -247,21 +251,23 @@ describe('getMerge', () => { | |
hostname: 'gitlab.com', | ||
url: 'https://gitlab.com/user/repo/subgroup' | ||
} | ||
expect(getMerge(message, remote)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remote)).to.deep.equal({ | ||
id: '15007', | ||
message: 'Memoize GitLab logger to reduce open file descriptors', | ||
href: 'https://gitlab.com/user/repo/subgroup/merge_requests/15007' | ||
href: 'https://gitlab.com/user/repo/subgroup/merge_requests/15007', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
}) | ||
|
||
describe('BitBucket', () => { | ||
it('parses a merge', () => { | ||
const message = 'Merged in eshvedai/fix-schema-issue (pull request #4518)\n\nfix(component): re-export createSchema from editor-core\n\nApproved-by: Scott Sidwell <[email protected]>' | ||
expect(getMerge(message, remotes.bitbucket)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.bitbucket)).to.deep.equal({ | ||
id: '4518', | ||
message: 'fix(component): re-export createSchema from editor-core', | ||
href: 'https://bitbucket.org/user/repo/pull-requests/4518' | ||
href: 'https://bitbucket.org/user/repo/pull-requests/4518', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
}) | ||
|
@@ -273,10 +279,11 @@ describe('getMerge', () => { | |
'(..l)': '_$1_' | ||
} | ||
} | ||
expect(getMerge(message, remotes.github, options)).to.deep.equal({ | ||
expect(getMerge(message, 'Commit Author', remotes.github, options)).to.deep.equal({ | ||
id: '3', | ||
message: '_Pul_l request t_itl_e', | ||
href: 'https://github.com/user/repo/pull/3' | ||
href: 'https://github.com/user/repo/pull/3', | ||
author: 'Commit Author' | ||
}) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.