forked from UpHabit/semantic-release-jira-releases
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding the ability to pass a regex to filter tickets (#10)
feat: adding the ability to pass a regex to filter tickets
- Loading branch information
Showing
10 changed files
with
167 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
'@babel/preset-typescript', | ||
], | ||
}; |
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
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
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { BaseConfig, Person, Commit, PreviousRelease, UpcomingRelease, PluginConfig, PluginContext, GenerateNotesContext } from "../lib/types"; | ||
|
||
export const baseConfig: BaseConfig = { | ||
$0: '', | ||
branch: 'test', | ||
debug: true, | ||
dryRun: true, | ||
} | ||
|
||
export const date = new Date("2019-01-01T00:00:00.000Z") | ||
|
||
export const author: Person = { | ||
name: 'test', | ||
email: 'email', | ||
date, | ||
} | ||
|
||
export const commits: Commit[] = [ | ||
'chore: fixing whitespace', | ||
'docs: adding regex unescaping', | ||
'fix: escaping regex', | ||
'docs: [FIX-321] editing readme', | ||
'feat: [UH-1258] better logging ', | ||
'feat: [UH-1258] Implement release creation', | ||
'fix: [FIX-123] typescript config', | ||
'fix: [TEST-123] test commit', | ||
].map(m => ({ | ||
author, | ||
committer: author, | ||
commitDate: date, | ||
body: '', | ||
hash: '', | ||
message: m, | ||
subject: '', | ||
commit: { | ||
long: '', | ||
short: '' | ||
} | ||
})) | ||
|
||
export const previousRelease: PreviousRelease = { | ||
gitHead: '', | ||
gitTag: '', | ||
version: '' | ||
} | ||
|
||
export const upcomingRelease: UpcomingRelease = { | ||
...previousRelease, | ||
notes: '', | ||
type: '' | ||
} | ||
|
||
export const pluginConfig: Partial<PluginConfig> = { | ||
...baseConfig, | ||
projectId: 'TEST', | ||
jiraHost: 'testjira.com' | ||
} | ||
|
||
export const logger = { | ||
info: jest.fn() | ||
} | ||
|
||
export const pluginContext: PluginContext = { | ||
cwd: '', | ||
env: {}, | ||
logger: logger as any, | ||
options: baseConfig, | ||
stderr: null, | ||
stdout: null, | ||
} | ||
export const context: GenerateNotesContext = { | ||
...pluginContext, | ||
commits, | ||
lastRelease: previousRelease, | ||
nextRelease: upcomingRelease | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getTickets } from "../lib/success"; | ||
import { pluginConfig, context } from "./fakedata"; | ||
import { PluginConfig } from "../lib/types"; | ||
|
||
describe('Success tests', () => { | ||
describe('#getTickets', () => { | ||
it('should analyze tickets with one ticketPrefix', () => { | ||
const config = { | ||
...pluginConfig, | ||
ticketPrefixes: ['UH'] | ||
} as PluginConfig; | ||
expect(getTickets(config, context)).toEqual(['UH-1258']) | ||
}) | ||
|
||
it('should analyze tickets with many ticketPrefix', () => { | ||
const config = { | ||
...pluginConfig, | ||
ticketPrefixes: ['UH', 'FIX'] | ||
} as PluginConfig | ||
expect(getTickets(config, context)).toEqual(['FIX-321', 'UH-1258', 'FIX-123']) | ||
}) | ||
|
||
it('should analyze tickets with ticketRegex', () => { | ||
const ticketRegex = '[A-Za-z]+-\\d+'; | ||
|
||
const config: PluginConfig = { | ||
...pluginConfig, | ||
ticketRegex | ||
} as PluginConfig; | ||
|
||
expect(getTickets(config, context)).toEqual(['FIX-321', 'UH-1258', 'FIX-123', 'TEST-123']) | ||
}) | ||
}) | ||
}) | ||
|