Skip to content

Commit

Permalink
Add support for colon-separation
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll committed Oct 17, 2019
1 parent d72b653 commit 324dbb8
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/app/lib/util/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function findLinks(issue, types) {

const namePart = '[a-z0-9-]+';

const typePart = '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved|child of|parent of|depends on|needs|requires|required by|needed by|related to)\\s+';
const typePart = '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved|child of|parent of|depends on|needs|requires|required by|needed by|related to):?\\s+';
const issueShortHandPart = `(?:(${namePart})\\/(${namePart}))?#(\\d+)`;
const issueUrlPart = `https:\\/\\/github.com\\/(${namePart})\\/(${namePart})\\/(?:issues|pull)\\/(\\d+)`;
const issuePart = `(?:${issueShortHandPart}|${issueUrlPart})`;
Expand Down Expand Up @@ -130,4 +130,4 @@ function filterLinks(links, filterMap) {

module.exports.findLinks = findLinks;

module.exports.linkTypes = linkTypes;
module.exports.linkTypes = linkTypes;
142 changes: 119 additions & 23 deletions packages/app/test/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('util', function() {
'FOO (needs #1)',
'Requires #2, needs #3, depends on #4, ' +
'requires foo/bar#5, ' +
'requires https://github.com/foo/bar/issues/6\n' +
'requires: foo/bar#6, ' +
'requires https://github.com/foo/bar/issues/7\n' +
'requires https://github.com/foo/bar/pull/1828\n' +
'requires https://github.com/foo/bar/issues/new ' +
'requires https://github.com/foo ' +
Expand Down Expand Up @@ -61,10 +62,14 @@ describe('util', function() {
type: DEPENDS_ON, number: 6,
owner: 'foo', repo: 'bar'
},
{
type: DEPENDS_ON, number: 7,
owner: 'foo', repo: 'bar'
},
{
type: DEPENDS_ON, number: 1828,
owner: 'foo', repo: 'bar'
}
},
]);
});

Expand All @@ -76,7 +81,8 @@ describe('util', function() {
'FOO (required by #1)',
'Required by #2, needed by #3 ' +
'required by foo/bar#5, ' +
'required by https://github.com/foo/bar/issues/6\n' +
'required by: foo/bar#6, ' +
'required by https://github.com/foo/bar/issues/7\n' +
'required by https://github.com/foo/bar/pull/1828\n' +
'required by https://github.com/foo/bar/issues/new ' +
'required by https://github.com/foo ' +
Expand Down Expand Up @@ -105,6 +111,10 @@ describe('util', function() {
type: REQUIRED_BY, number: 6,
owner: 'foo', repo: 'bar'
},
{
type: REQUIRED_BY, number: 7,
owner: 'foo', repo: 'bar'
},
{
type: REQUIRED_BY, number: 1828,
owner: 'foo', repo: 'bar'
Expand All @@ -121,7 +131,8 @@ describe('util', function() {
'close foo/bar#5, ' +
'closes foo/bar#6, ' +
'closed foo/bar#7, ' +
'closes https://github.com/foo/bar/issues/6\n' +
'close: foo/bar#8, ' +
'closes https://github.com/foo/bar/issues/9\n' +
'closes https://github.com/foo/bar/pull/1828\n' +
'closes https://github.com/foo/bar/issues/new ' +
'closes https://github.com/foo ' +
Expand Down Expand Up @@ -155,7 +166,11 @@ describe('util', function() {
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 6,
type: CLOSES, number: 8,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 9,
owner: 'foo', repo: 'bar'
},
{
Expand All @@ -170,10 +185,12 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO (fixes #1)',
'Fix #2' +
'Fixes #3 ' +
'Fixed #4' +
'fixes https://github.com/foo/bar/issues/6\n' +
'Fixes #2, closes #3' +
'fix foo/bar#5, ' +
'fixes foo/bar#6, ' +
'fixed foo/bar#7, ' +
'fix: foo/bar#8, ' +
'fixes https://github.com/foo/bar/issues/9\n' +
'fixes https://github.com/foo/bar/pull/1828\n' +
'fixes https://github.com/foo/bar/issues/new ' +
'fixes https://github.com/foo ' +
Expand All @@ -195,12 +212,25 @@ describe('util', function() {
type: CLOSES, number: 3
},
{
type: CLOSES, number: 4
type: CLOSES, number: 5,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 6,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 7,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 8,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 9,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 1828,
owner: 'foo', repo: 'bar'
Expand All @@ -213,10 +243,12 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO (resolves #1)',
'Resolve #2' +
'Resolves #3 ' +
'Resolved #4' +
'resolves https://github.com/foo/bar/issues/6\n' +
'resolves #2, resolves #3' +
'resolve foo/bar#5, ' +
'resolves foo/bar#6, ' +
'resolved foo/bar#7, ' +
'resolve: foo/bar#8, ' +
'resolves https://github.com/foo/bar/issues/9\n' +
'resolves https://github.com/foo/bar/pull/1828\n' +
'resolves https://github.com/foo/bar/issues/new ' +
'resolves https://github.com/foo ' +
Expand All @@ -238,12 +270,25 @@ describe('util', function() {
type: CLOSES, number: 3
},
{
type: CLOSES, number: 4
type: CLOSES, number: 5,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 6,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 7,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 8,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 9,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 1828,
owner: 'foo', repo: 'bar'
Expand All @@ -256,7 +301,8 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO',
'Related to #2, related to https://github.com/foo/bar/pull/1828'
'Related to #2, related to https://github.com/foo/bar/pull/1828\n' +
'Related to: #3'
);

// when
Expand All @@ -270,7 +316,10 @@ describe('util', function() {
{
type: LINKED_TO, number: 1828,
owner: 'foo', repo: 'bar'
}
},
{
type: LINKED_TO, number: 3
},
]);
});

Expand All @@ -280,7 +329,9 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO (child of #1)',
'Parent of #2, parent of https://github.com/foo/bar/pull/1828'
'Parent of #2, parent of https://github.com/foo/bar/pull/1828\n ' +
'Parent of: #3' +
'Child of: #4'
);

// when
Expand All @@ -297,7 +348,13 @@ describe('util', function() {
{
type: PARENT_OF, number: 1828,
owner: 'foo', repo: 'bar'
}
},
{
type: PARENT_OF, number: 3
},
{
type: CHILD_OF, number: 4
},
]);
});

Expand All @@ -309,7 +366,8 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO',
'Closes #2, #5, https://github.com/foo/bar/issues/1828, #10'
'Closes #2, #5, https://github.com/foo/bar/issues/1828, #10\n ' +
'Closes: #3, #4, https://github.com/foo/bar/issues/1829, #11'
);

// when
Expand All @@ -329,6 +387,19 @@ describe('util', function() {
},
{
type: CLOSES, number: 10
},
{
type: CLOSES, number: 3
},
{
type: CLOSES, number: 4
},
{
type: CLOSES, number: 1829,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 11
}
]);
});
Expand All @@ -339,7 +410,8 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO',
'Closes #2 https://github.com/foo/bar/issues/1828 #10'
'Closes #2 https://github.com/foo/bar/issues/1828 #10\n' +
'Closes: #3 https://github.com/foo/bar/issues/1829 #11'
);

// when
Expand All @@ -356,6 +428,16 @@ describe('util', function() {
},
{
type: CLOSES, number: 10
},
{
type: CLOSES, number: 3
},
{
type: CLOSES, number: 1829,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 11
}
]);
});
Expand All @@ -366,7 +448,8 @@ describe('util', function() {
// given
const issue = createIssue(
'FOO',
'Closes https://github.com/foo/bar/issues/1 and #5, and #10, and, #12'
'Closes https://github.com/foo/bar/issues/1 and #5, and #10, and, #12\n' +
'Closes: https://github.com/foo/bar/issues/101 and #105, and #110, and, #112'
);

// when
Expand All @@ -386,6 +469,19 @@ describe('util', function() {
},
{
type: CLOSES, number: 12
},
{
type: CLOSES, number: 101,
owner: 'foo', repo: 'bar'
},
{
type: CLOSES, number: 105
},
{
type: CLOSES, number: 110
},
{
type: CLOSES, number: 112
}
]);
});
Expand Down Expand Up @@ -590,4 +686,4 @@ function createIssue(title, body) {
body
};

}
}

0 comments on commit 324dbb8

Please sign in to comment.