Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
fix: Incorrect Github Regex (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
therynamo authored Oct 20, 2020
1 parent 8e093f7 commit 87ce12b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,57 @@ describe('github finder', () => {
expect(githubFinder({ body })).toEqual(expectation);
});

it('should return 2 tickets, not one, if they grouped together by only words or whitespace', () => {
const PRBody = `
## Summary
https://git.you.com/wow/woohoo/issues/27158 and https://git.you.com/wow/woohoo/issue/27166
### Addresses issue
prod issue
### Steps to reproduce & screenshots/GIFs
`;
const expectation = {
tickets: [
{
fullLinkedUrl: 'https://git.you.com/wow/woohoo/issues/27158',
project: 'wow/woohoo',
issueNumber: '27158',
name: '27158',
},
{
fullLinkedUrl: 'https://git.you.com/wow/woohoo/issue/27166',
project: 'wow/woohoo',
issueNumber: '27166',
name: '27166',
},
],
name: 'github',
};

expect(githubFinder({ body: PRBody })).toEqual(expectation);
});

it('should return no tickets if there are only pull request', () => {
const PRBody = `
## Summary
https://git.you.com/wow/woohoo/pull/27158 and https://git.you.com/wow/woohoo/pull/27166
### Addresses issue
prod issue
### Steps to reproduce & screenshots/GIFs
`;
const expectation = {
tickets: [],
name: 'github',
};
expect(githubFinder({ body: PRBody })).toEqual(expectation);
});

it('should return no tickets if there are no ticket types', () => {
const expectation = {
tickets: [],
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ticketFinder/finders/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const githubDomain = config.get('github:domain') || 'https://github.com';
const owner = config.get('github:owner');
const repo = config.get('github:repo');

const GITHUB_QUALIFIED_URL = /(https:\/\/(?:www.git|git).*\..+\/\d+)/;
const GITHUB_QUALIFIED_URL = /(https:\/\/(?:www.git|git)(?:\.\w+|\w+)\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+\/[^pull]+\w+\/\d+)/;
const GITHUB_QUALIFIED_NUMBER_URL = /https:\/\/(?:www.git|git).*\..+\/(\d+)/;
const CLOSE_ISSUE_SYNTAX = /(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s(\S.*\/\S.*#\d+|#\d+)/;
const CLOSE_SYNTAX_NUMBER = /#(\d+)/;
Expand Down

0 comments on commit 87ce12b

Please sign in to comment.