Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Ignore pinned issues #266

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sambostock
Copy link

Context

Pinned Issues should never be considered stale, as they are obviously meant to stick around, or they wouldn't be pinned.

Currently, the bot treats Pinned Issues the same as any other issue. The workaround is to also add a label to these issues, to prevent the bot from flagging them.

What does this do?

This adds a filter step to the getStale function, which filters out Pinned Issues. This results in Pinned Issues never being marked as stale

Considerations

The GraphQL API is used to fetch the Pinned Issues, as the REST API does not support this functionality.

To access this information, the Pinned Issues Preview feature had to be enabled, via the special Accept header. This should be removed once the feature is released.

In case the feature is removed or altered, causing an error, the code rescues errors and proceeds as if no issues are pinned.

}
}

async getPinnedNumbers(type) {
Copy link
Author

Choose a reason for hiding this comment

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

We could potentially add a config setting to control if pinned issues should be ignored or not, but I wasn't sure if it was worth it.

Comment on lines +87 to +94
return {
...results,
data: {
...results.data,
total_count: nonPinned.length,
items: nonPinned,
}
}
Copy link
Author

Choose a reason for hiding this comment

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

I opted to preserve any untouched portions of the return payload, rather than just return {data:{items: nonPinned}}, despite the fact they aren't used.

It felt weird to change the return type, rather than just the contents.

Comment on lines +110 to +124
`
query Issues($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
pinnedIssues(first: 100) {
nodes {
number
}
pageInfo {
# This should always be false, as only 3 issues can be pinned at the same time
hasNextPage
}
}
}
}
`,
Copy link
Author

Choose a reason for hiding this comment

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

I originally extracted this into a constant, but decided it might be clearer to have it nearby.

Comment on lines +117 to +120
pageInfo {
# This should always be false, as only 3 issues can be pinned at the same time
hasNextPage
}
Copy link
Author

Choose a reason for hiding this comment

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

This could go away, but I felt it was was useful to document why we don't have to paginate.


return data.repository.pinnedIssues.nodes.map(issue => issue.number)
} catch (error) {
this.logger.error(`Encountered an error while excluding pinned items for ${owner}/${repo}: ${error}`)
Copy link
Author

@sambostock sambostock Mar 14, 2020

Choose a reason for hiding this comment

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

I wasn't sure if this was the best way to log errors, but I think it's important that the bot not break if the Pinned Issues Preview API changes.

@andig
Copy link

andig commented May 28, 2020

This PR would address a current issue: https://stackoverflow.com/questions/62064833/github-probot-why-are-pinned-issues-treated-as-style-and-marked-as-wont-fix. The default config of ignoring a pinned label is misleading. Either this PR could address it or Stalebot should be able to react/ be configured based on issue state and labels both.

Stack Overflow
Using Probot on Github and it is configured like this:

exemptLabels:

  • pinned
  • security

Label to use when marking an issue as stale

staleLabel: wontfix
...
yet Probot marks pinned issue as "

@stale
Copy link

stale bot commented Sep 2, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

@stale stale bot added the wontfix label Sep 2, 2020
@andig
Copy link

andig commented Sep 2, 2020

Pinned Issues should never be considered stale, as they are obviously meant to stick around, or they wouldn't be pinned.

This is still relevant and would be highly appreciated.

@stale stale bot removed the wontfix label Sep 2, 2020
@stale
Copy link

stale bot commented Dec 25, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

@stale stale bot added the wontfix label Dec 25, 2020
@stale stale bot removed the wontfix label May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants