Watch
0
0
Fork
You've already forked hyperhive
0

hive-forge: drop the subscription --ignore change (covered by #5053)

This commit is contained in:
atlas 2026-10-09 11:51:25 +02:00 • committed by mara
commit 4d164819b3
2 changed files with 11 additions and 46 deletions

View file

@ -1278,7 +1278,7 @@ Get/set this user's watch subscription on a repo, or --list all watched repos
###### **Options:**
* `--watch` — Subscribe (watch the repo)
* `--ignore` — Not supported: the forge API has no ignore endpoint. Errors; use `--unwatch` to stop notifications
* `--ignore` — Mute (mark ignored)
* `--unwatch` — Unsubscribe (clear watch + ignore)
* `--list` — List every repo the current user watches (ignores `[repo]`)

View file

@ -3,7 +3,7 @@
//! repo the user watches (`--list`, for auditing the notification
//! firehose).
use anyhow::{Result, bail};
use anyhow::Result;
use clap::Args as ClapArgs;
use serde_json::json;
@ -21,8 +21,7 @@ pub struct Args {
/// Subscribe (watch the repo).
#[arg(long, group = "action")]
watch: bool,
/// Not supported: the forge API has no ignore endpoint. Errors; use
/// `--unwatch` to stop notifications.
/// Mute (mark ignored).
#[arg(long, group = "action")]
ignore: bool,
/// Unsubscribe (clear watch + ignore).
@ -33,26 +32,14 @@ pub struct Args {
list: bool,
}
/// `--ignore` has no Forgejo endpoint; fail rather than subscribe.
fn reject_ignore(args: &Args) -> Result<()> {
if args.ignore {
bail!(
"--ignore is not supported: the forge API has no ignore endpoint; \
use `--unwatch` to stop notifications"
);
}
Ok(())
}
/// Run the `subscription` verb: `--list` all watched repos, set the
/// current repo's watch (`--watch` / `--ignore` / `--unwatch`), or get
/// its current state.
///
/// # Errors
/// Fails on `--ignore` (unsupported). Propagates transport / non-2xx
/// errors from the Forgejo client calls and from `print_json`.
/// Propagates transport / non-2xx errors from the Forgejo client calls
/// and from `print_json`.
pub fn run(client: &Client, args: Args) -> Result<()> {
reject_ignore(&args)?;
if args.list {
// List every repo the authed user watches, so an agent can audit
// its notification firehose and decide what to `--unwatch`. Not
@ -85,9 +72,12 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
println!("unsubscribed");
return Ok(());
}
if args.watch {
// Forgejo's PUT subscription endpoint takes no body: it always
// subscribes (watch).
if args.watch || args.ignore {
// Forgejo's PUT subscription endpoint takes no body — it always
// subscribes (watch). The old raw client sent a
// `{subscribed, ignored}` body which the server ignored, so
// `--ignore` has always behaved like `--watch` server-side; the
// typed call just makes that explicit.
let resp = client
.api()
.user_current_put_subscription(owner, name)
@ -112,28 +102,3 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
Err(e) => Err(e.into()),
}
}
#[cfg(test)]
mod tests {
use super::*;
use clap::Parser;
#[derive(Parser)]
struct Cli {
#[command(flatten)]
args: Args,
}
#[test]
fn ignore_is_rejected_pointing_at_unwatch() {
let cli = Cli::parse_from(["x", "--ignore"]);
let err = reject_ignore(&cli.args).unwrap_err().to_string();
assert!(err.contains("--unwatch"), "{err}");
}
#[test]
fn watch_is_not_rejected() {
let cli = Cli::parse_from(["x", "--watch"]);
assert!(reject_ignore(&cli.args).is_ok());
}
}