Skip to content

Commit

Permalink
Filter on a specific repository (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-wizaplace authored and babeuloula committed Oct 8, 2019
1 parent 7874b1e commit 10defaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GITHUB_LABELS_ACCEPTED='["Accepted"]'
GITHUB_LABELS_WIP='["WIP", "Pending answer"]'
GITHUB_BRANCHS_COLORS='[{"master": "warning"}, {"develop": "success"}, {"feature-*": "primary"}, {"release*": "info"}, , {"hotfix-*": "danger"}]'
GITHUB_BRANCH_DEFAULT_COLOR=danger
GITHUB_FILTERS='["is:pr is:open -label:WIP", "is:pr is:draft"]'
GITHUB_FILTERS='["is:pr is:open -label:WIP", "is:pr is:draft repo:username/repository"]'
GITHUB_NOTIFICATIONS_EXCLUDE_REASONS='["assign", "comment", "invitation"]'
GITHUB_NOTIFICATIONS_EXCLUDE_REASONS_OTHER_REPOS='["review_requested", "state_change"]'
Expand All @@ -44,7 +44,8 @@ USE_MODE=label

If you don't want to reload on focus and reload every x ms, you just need to set `RELOAD_ON_FOCUS=0` and `RELOAD_EVERY=0`.

If you want to search PRs by filters, you can fill `GITHUB_FILTERS`. You can find a list of available filters [here](https://help.github.com/en/articles/searching-issues-and-pull-requests).
If you want to search PRs by filters, you can fill `GITHUB_FILTERS`. You can find a list of available filters [here](https://help.github.com/en/articles/searching-issues-and-pull-requests).
You can filter on a specific repository with `repo:username/repository`.

To fill `GITHUB_NOTIFICATIONS_EXCLUDE_REASONS` and `GITHUB_NOTIFICATIONS_EXCLUDE_REASONS_OTHER_REPOS` you can find the list [here](https://developer.github.com/v3/activity/notifications/#notification-reasons).

Expand Down
6 changes: 6 additions & 0 deletions src/Service/Github/PullRequestFilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ protected function search(array $params = []): array
// - "is:pr is:open -label:WIP"
// - "is:pr is:draft"
foreach ($this->githubFilters as $filter) {
if (1 === \preg_match("/repo\:[a-zA-Z0-9\/-]+/", $filter, $matches)
&& "repo:$username/$repository" !== $matches[0]
) {
continue;
}

foreach ($this->getAll($username, $repository, $filter, $params) as $pullRequest) {
$pullRequest = $pullRequestApi->show($username, $repository, $pullRequest['number']);

Expand Down

0 comments on commit 10defaf

Please sign in to comment.