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

Allow for skipping "Handle unhelpful comments" via a label(s) #42

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ nissuer comes with a default configuration, but you can override certain behavio

- nissuer can hide "+1", "same issue", etc. comments on issues (partially based on [Refined GitHub](https://github.com/refined-github/refined-github/blob/c864a20b57bb433aaf3952f88d83c9fc481ae6ff/source/helpers/is-low-quality-comment.ts#L2-L3)). It won't hide comments from the repo organization members.
- nissuer can also update the hidden comment with a note from the maintainers, explaining to the user why the comment was hidden. This is used for education purposes, so hopefully the user will be more considerate in the future.
- nissuer can skip the "marking as off-topic and hidden" if certain a label(s) are present on the issue.

| Input | Description | Default Value |
| -------------------------- | ---------------------------------------------------------------------------------- | ------------- |
| `comment-add-explainer` | Add an explainer to a comment that was marked as off-topic. | `true` |
| `comment-unhelpful-weight` | If an issue comment is below this rate, it will be marked as off-topic and hidden. | `0.3` |
| Input | Description | Default Value |
| --------------------------------- | ------------------------------------------------------------------------------------------ | ------------- |
| `comment-add-explainer` | Add an explainer to a comment that was marked as off-topic. | `true` |
| `comment-unhelpful-weight` | If an issue comment is below this rate, it will be marked as off-topic and hidden. | `0.3` |
| 'comment-unhelpful-ignore-labels` | Comma-separated list of labels that will prevent a comment from being marked as off-topic. | |

### Validate reproduction URLs

Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ const config = {
comments: {
unhelpfulWeight: Number(getInput("comment_unhelpful_weight")) || 0.3,
addExplainer: getBooleanOrUndefined("comment_add_explainer") ?? true,
ignoreLabels: getInput("comment_unhelpful_ignore_labels")
.split(",")
.map((l) => l.trim()),
},
webhook: {
url: getInput("webhook_url"),
Expand Down Expand Up @@ -276,6 +279,10 @@ async function hideUnhelpfulComments() {
const { comment, action, issue } = context.payload
if (action !== "created" || !comment || !issue) return

// if the issue has any of labels given from comment-unhelpful-ignore-labels, then skip hiding the comment
const issueLabels = issue.labels.map((label) => label.name)
if (issueLabels.some((label) => config.comments.ignoreLabels.includes(label))) return

const {
node_id: subjectId,
body,
Expand Down