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

Add README, fix --cleanup-reviewed-prs #8

Merged
merged 2 commits into from
Nov 9, 2024
Merged
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
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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. |
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down