Skip to content

Commit

Permalink
fix: add more branch prefixes to remove
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Nov 2, 2018
1 parent 0b8201f commit 5444029
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ describe('#loadConfig', () => {

describe('#formatGitBranchName', () => {
it('removes any prefixes from a branch name', () => {
const result = formatGitBranchName('feature/123');
expect(result).toEqual('#123');
expect(formatGitBranchName('feature/123')).toEqual('#123');
expect(formatGitBranchName('feat/123')).toEqual('#123');
expect(formatGitBranchName('hotfix/456')).toEqual('#456');
expect(formatGitBranchName('fix/456')).toEqual('#456');
});

it('handles running on Travis CI when Git is not initialised', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export function findLongest(strings: string[]): number {
}

export function formatGitBranchName(branchName: string) {
const issueId = (branchName || '')
.replace('feature/', '') // Get rid of `feature/` prefix
.replace('fix/', '') // Get rid of `fix/` prefix
.toLocaleUpperCase(); // Uppercase issue IDs
const issueId = (branchName || '').replace(
/^(feature|feat|hotfix|fix)\//,
'',
);

return issueId ? `#${issueId}` : '';
}
Expand Down

0 comments on commit 5444029

Please sign in to comment.