Skip to content

Commit

Permalink
fix: use proper query for searching title
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg authored and gr2m committed Feb 15, 2018
1 parent fbf1246 commit edecf92
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion lib/find-sr-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const ISSUE_ID = require('./definitions/sr-issue-id');

module.exports = async (github, title, owner, repo) => {
const {data: {items: issues}} = await github.search.issues({
q: `title:${title}+repo:${owner}/${repo}+type:issue+state:open`,
q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`,
});

return issues.filter(issue => issue.body && issue.body.includes(ISSUE_ID));
Expand Down
30 changes: 15 additions & 15 deletions test/fail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ test.serial('Open a new issue with the list of errors', async t => {
];
const github = authenticate()
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down Expand Up @@ -80,9 +80,9 @@ test.serial('Open a new issue with the list of errors and custom title and comme
];
const github = authenticate()
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down Expand Up @@ -112,9 +112,9 @@ test.serial('Open a new issue with assignees and the list of errors', async t =>
];
const github = authenticate()
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down Expand Up @@ -145,9 +145,9 @@ test.serial('Open a new issue without labels and the list of errors', async t =>
];
const github = authenticate()
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down Expand Up @@ -182,9 +182,9 @@ test.serial('Update the first existing issue with the list of errors', async t =
];
const github = authenticate()
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: issues})
.post(`/repos/${owner}/${repo}/issues/2/comments`, {
Expand Down
12 changes: 6 additions & 6 deletions test/find-sr-issue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ test.serial('Filter out issues without ID', async t => {
];
const github = authenticate({githubToken})
.get(
`/search/issues?q=${escape(`title:${title}`)}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}`
)}+${escape(title)}`
)
.reply(200, {items: issues});

Expand All @@ -69,9 +69,9 @@ test.serial('Return empty array if not issues found', async t => {
const issues = [];
const github = authenticate({githubToken})
.get(
`/search/issues?q=${escape(`title:${title}`)}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}`
)}+${escape(title)}`
)
.reply(200, {items: issues});

Expand All @@ -90,9 +90,9 @@ test.serial('Return empty array if not issues has matching ID', async t => {
const issues = [{number: 1, body: 'Issue 1 body', title}, {number: 2, body: 'Issue 2 body', title}];
const github = authenticate({githubToken})
.get(
`/search/issues?q=${escape(`title:${title}`)}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}`
)}+${escape(title)}`
)
.reply(200, {items: issues});

Expand Down
24 changes: 12 additions & 12 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ test.serial('Comment on PR included in the releases', async t => {
.post(`/repos/${owner}/${repo}/issues/1/comments`, {body: /This PR is included/})
.reply(200, {html_url: 'https://github.com/successcomment-1'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});

Expand All @@ -228,9 +228,9 @@ test.serial('Open a new issue with the list of errors', async t => {
.get(`/repos/${owner}/${repo}`)
.reply(200, {permissions: {push: true}})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down Expand Up @@ -289,9 +289,9 @@ test.serial('Verify, release and notify success', async t => {
.post(`/repos/${owner}/${repo}/issues/1/comments`, {body: /This PR is included/})
.reply(200, {html_url: 'https://github.com/successcomment-1'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});
const githubUpload1 = upload({
Expand Down Expand Up @@ -338,9 +338,9 @@ test.serial('Verify and notify failure', async t => {
.get(`/repos/${owner}/${repo}`)
.reply(200, {permissions: {push: true}})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []})
.post(`/repos/${owner}/${repo}/issues`, {
Expand Down
36 changes: 18 additions & 18 deletions test/success.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ test.serial('Add comment to PRs associated with release commits and issues close
.post(`/repos/${owner}/${repo}/issues/4/comments`, {body: /This issue has been resolved/})
.reply(200, {html_url: 'https://github.com/successcomment-4'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});

Expand Down Expand Up @@ -126,9 +126,9 @@ test.serial('Make multiple search queries if necessary', async t => {
.post(`/repos/${owner}/${repo}/issues/6/comments`, {body: /This PR is included/})
.reply(200, {html_url: 'https://github.com/successcomment-6'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});

Expand Down Expand Up @@ -161,9 +161,9 @@ test.serial('Do not add comment if no PR is associated with release commits', as
)
.reply(200, {items: []})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});

Expand Down Expand Up @@ -199,9 +199,9 @@ test.serial('Add custom comment', async t => {
})
.reply(200, {html_url: 'https://github.com/successcomment-1'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: []});

Expand Down Expand Up @@ -238,9 +238,9 @@ test.serial('Ignore errors when adding comments and closing issues', async t =>
.post(`/repos/${owner}/${repo}/issues/2/comments`, {body: /This PR is included/})
.reply(200, {html_url: 'https://github.com/successcomment-2'})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: issues})
.patch(`/repos/${owner}/${repo}/issues/2`, {state: 'closed'})
Expand Down Expand Up @@ -284,9 +284,9 @@ test.serial('Close open issues when a release is successful', async t => {
)
.reply(200, {items: []})
.get(
`/search/issues?q=${escape(`title:${failTitle}`)}+${escape(`repo:${owner}/${repo}`)}+${escape(
'type:issue'
)}+${escape('state:open')}`
`/search/issues?q=${escape('in:title')}+${escape(`repo:${owner}/${repo}`)}+${escape('type:issue')}+${escape(
'state:open'
)}+${escape(failTitle)}`
)
.reply(200, {items: issues})
.patch(`/repos/${owner}/${repo}/issues/2`, {state: 'closed'})
Expand Down

0 comments on commit edecf92

Please sign in to comment.