Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-evans committed Oct 6, 2021
1 parent 843266d commit c12d2b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions dist/index.js
Expand Up @@ -387,7 +387,7 @@ function run() {
core.debug(`Inputs: ${util_1.inspect(inputs)}`);
const [headOwner, head] = inputValidator.parseHead(inputs.head);
const pullsHelper = new pulls_helper_1.PullsHelper(inputs.token);
const pulls = yield pullsHelper.get(inputs.repository, head, headOwner, inputs.base);
const pulls = yield pullsHelper.get(inputs.repository, head, headOwner, inputs.base, []);
if (pulls.length > 0) {
core.info(`${pulls.length} pull request(s) found.`);
// Checkout
Expand Down Expand Up @@ -474,7 +474,7 @@ class PullsHelper {
}
});
}
get(repository, head, headOwner, base) {
get(repository, head, headOwner, base, ignoreLabels) {
return __awaiter(this, void 0, void 0, function* () {
const [owner, repo] = repository.split('/');
const params = {
Expand Down Expand Up @@ -522,7 +522,12 @@ class PullsHelper {
p.node.headRepositoryOwner.login == headOwner) &&
// Filter heads from forks where 'maintainer can modify' is false
(p.node.headRepositoryOwner.login == owner ||
p.node.maintainerCanModify)) {
p.node.maintainerCanModify) &&
// Filter out pull requests with labels in the ignore list
p.node.labels.nodes.every(function (value) {
// Label is not in the ignore list
return !ignoreLabels.includes(value.name);
})) {
return new Pull(p.node.baseRefName, p.node.headRepository.url, p.node.headRepository.nameWithOwner, p.node.headRefName);
}
})
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Expand Up @@ -26,7 +26,8 @@ async function run(): Promise<void> {
inputs.repository,
head,
headOwner,
inputs.base
inputs.base,
[]
)

if (pulls.length > 0) {
Expand Down
10 changes: 8 additions & 2 deletions src/pulls-helper.ts
Expand Up @@ -19,7 +19,8 @@ export class PullsHelper {
repository: string,
head: string,
headOwner: string,
base: string
base: string,
ignoreLabels: string[]
): Promise<Pull[]> {
const [owner, repo] = repository.split('/')
const params: OctokitTypes.RequestParameters = {
Expand Down Expand Up @@ -66,7 +67,12 @@ export class PullsHelper {
p.node.headRepositoryOwner.login == headOwner) &&
// Filter heads from forks where 'maintainer can modify' is false
(p.node.headRepositoryOwner.login == owner ||
p.node.maintainerCanModify)
p.node.maintainerCanModify) &&
// Filter out pull requests with labels in the ignore list
p.node.labels.nodes.every(function (value: Label): boolean {
// Label is not in the ignore list
return !ignoreLabels.includes(value.name)
})
) {
return new Pull(
p.node.baseRefName,
Expand Down

0 comments on commit c12d2b8

Please sign in to comment.