Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter issues by labels when listing if possible #1084

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mraleph
Copy link

@mraleph mraleph commented Aug 30, 2023

Description:

  • If only-issue-labels and only-pr-labels are not specified
    we limit the listing to only-labels.
  • If only-issue-labels and only-pr-labels are specified
    but are the same, we limit the listing to these labels.
  • If we don't need to make neither issues nor PRs as stale
    (days-before-issue-stale and days-before-pr-stale are
    negative) and stale label is the same for issues and PRs
    then we filter by this label.

This allows to significantly limit amount of processing done by this action on repos with large number of open issues.

Related issue:

#1046

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

* If `only-issue-labels` and `only-pr-labels` are not specified
  we limit the listing to `only-labels`.
* If `only-issue-labels` and `only-pr-labels` are specified
  but are the same, we limit the listing to these labels.
* If we don't need to make neither issues nor PRs as stale
  (`days-before-issue-stale` and `days-before-pr-stale` are
  negative) and stale label is the same for issues and PRs
  then we filter by this label.
Copy link

@lrhn lrhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Drive-by-comments. Sorry, not sorry 😉)

dist/index.js Show resolved Hide resolved
dist/index.js Show resolved Hide resolved
dist/index.js Show resolved Hide resolved
if (!(0, should_mark_when_stale_1.shouldMarkWhenStale)(this._getDaysBeforeIssueStale()) &&
!(0, should_mark_when_stale_1.shouldMarkWhenStale)(this._getDaysBeforePrStale()) &&
this.options.stalePrLabel === this.options.staleIssueLabel &&
!labels.includes(this.options.staleIssueLabel)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The includes doesn't require the text to be an entire label. If we have labels stale and maybe-stale, then the includes('stale') will match a maybe-stale label.
Consider over-engineering this as:

!new RegExp('(?:^|,)' + this.options.staleIssueLabel + '(?:,|$)').test(labels)

If there can be surrounding whitespace around the label, then:

!new RegExp('(?:^|,)\\s*' + this.options.staleIssueLabel + '\\s*(?:,|$)').test(labels)

(Or the, maybe, more memory-intensive, but less RegExp-y:

  ![...labels.split(',').map(s=>s.trim())].includes(this.options.staleIssueLable)

)

@dsame dsame linked an issue Sep 1, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reduce the number of issues this action queries
2 participants