From 261a528b436d7f38c824c1d75bdbfc98f0d4acb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wendt?= Date: Sat, 19 Oct 2024 18:09:23 +0200 Subject: [PATCH 1/2] docs: add README --- README.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e396997..d447e9c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,44 @@ # gh-cleanup-notifications -gh cli extension to clean up notifications in GitHub + +A GitHub (`gh`) CLI extension to clean up your GitHub notifications. + +## 📦 Installation + +1. Install the `gh` CLI - see the [installation](https://github.com/cli/cli#installation) + + _Installation requires a minimum version (2.0.0) of the GitHub CLI that supports extensions._ + +2. Install this extension: + + ```sh + gh extension install awendt/gh-cleanup-notifications + ``` + + +## ⚡️ Usage + +It's recommended to install `moreutils` for the `ts` utility: `brew install moreutils` + +Run + +``` +gh cleanup-notifications --dry-run --verbose | ts +``` + +and watch the extension fetch information about each pull request in your notifications. + +Notifications will be polled every minute, making use of the `Last-Modified` request header and adhering to the `X-Poll-Interval` response header as described [in this doc](https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28). + +## Options + +You can choose exactly which notifications will be cleaned up. By default, no notifications will be cleaned up. + +If you want to see an option in action but are not yet ready to do any cleanup, you can always specify `--dry-run`. + +| Option | What it does | +|----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| `--cleanup-closed-prs` | All notifications for closed pull requests will be marked as done. | +| `--cleanup-reassigned-prs` | All notifications with reason `subscribed` for pull requests that have been assigned to another person will be marked as done and unsubscribed | +| `--cleanup-reviewed-prs` | All notifications with reason `review_requested` for pull requests that have been assigned to another person will be marked as done and unsubscribed | +| `--dry-run` | Show the behavior but do not clean up any notifications. | +| `--verbose` | Print URLs as API requests are being sent. | From afce5636bb09a099acf01103d390c5927bfd967e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Wendt?= Date: Sat, 9 Nov 2024 17:37:00 +0100 Subject: [PATCH 2/2] fix: option --cleanup-reviewed-prs actually works as documented --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e343a42..cc2626a 100755 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ const doWork = async () => { } // Case 3: review requested but no reviews pending - if (options.cleanupReviewPrs) { + if (options.cleanupReviewedPrs) { const reviewRequestedAndReviewed = reducer.notificationsForReviewedPRs; console.debug("%d notifications for PRs requesting and gotten reviews, unsubscribing…", reviewRequestedAndReviewed.length); await github.unsubscribe(reviewRequestedAndReviewed);