Skip to content
Draft
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
38 changes: 38 additions & 0 deletions crates/buzz-cli/src/commands/patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,38 @@ pub async fn cmd_list_patches(
Ok(())
}

/// Read patch status events (kind:1630-1633) for a repo — the read side of sign-off.
/// Mirrors `cmd_list_patches` but selects status kinds instead of the patch kind, so
/// operator sign-off (a signed `merged` status event) is queryable, not write-only.
pub async fn cmd_list_status(
client: &BuzzClient,
repo_owner: &str,
repo_id: &str,
patch: Option<&str>,
limit: Option<u32>,
) -> Result<(), CliError> {
validate_hex64(repo_owner)?;
validate_repo_id(repo_id)?;

let a_value = format!("30617:{repo_owner}:{repo_id}");
let mut filter = serde_json::json!({
"kinds": [1630, 1631, 1632, 1633],
"#a": [a_value]
});

if let Some(root) = patch {
validate_hex64(root)?;
filter["#e"] = serde_json::json!([root]);
}
if let Some(n) = limit {
filter["limit"] = serde_json::json!(n);
}

let resp = client.query(&filter).await?;
println!("{resp}");
Ok(())
}

#[allow(clippy::too_many_arguments)]
pub async fn cmd_patch_status(
client: &BuzzClient,
Expand Down Expand Up @@ -244,6 +276,12 @@ pub async fn dispatch(cmd: crate::PatchesCmd, client: &BuzzClient) -> Result<(),
author,
limit,
} => cmd_list_patches(client, &repo_owner, &repo_id, author.as_deref(), limit).await,
PatchesCmd::StatusList {
repo_owner,
repo_id,
patch,
limit,
} => cmd_list_status(client, &repo_owner, &repo_id, patch.as_deref(), limit).await,
PatchesCmd::Status {
root,
status,
Expand Down
19 changes: 17 additions & 2 deletions crates/buzz-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,21 @@ pub enum PatchesCmd {
#[arg(long)]
limit: Option<u32>,
},
/// Read patch status events (NIP-34 kind:1630-1633) for a repo — the read side of sign-off
StatusList {
/// Repo owner pubkey (64-char hex)
#[arg(long)]
repo_owner: String,
/// Repo identifier (d-tag)
#[arg(long)]
repo_id: String,
/// Only status events referencing this patch root event id
#[arg(long)]
patch: Option<String>,
/// Maximum number of results
#[arg(long)]
limit: Option<u32>,
},
/// Set status on a patch (open/merged/closed/draft — NIP-34 kind:1630-1633)
Status {
/// Root patch event id (first patch of the series/revision)
Expand Down Expand Up @@ -1968,7 +1983,7 @@ mod tests {
);
assert_eq!(
names(&cmd, "patches"),
vec!["get", "list", "send", "status"]
vec!["get", "list", "send", "status", "status-list"]
);
assert_eq!(
names(&cmd, "issues"),
Expand Down Expand Up @@ -2005,7 +2020,7 @@ mod tests {
("media", 1),
("messages", 8),
("pack", 2),
("patches", 4),
("patches", 5),
("pr", 5),
("reactions", 3),
("repos", 4),
Expand Down