upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/label.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-03-05 14:19:49 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-03-05 14:23:07 +0000
commit37244449d6d0d58bb639f181bd15092de1acaaee (patch)
tree7de03867a1a9578e32fdbdbb2be63e863cea57a4 /src/bin/ngit/sub_commands/label.rs
parent609f3c3db02d437222e2c8e171189179d06c3e9c (diff)
feat(cover-note): add kind-1624 cover notes for PRs, patches, and issues
Implements experimental kind-1624 cover note events: - KIND_COVER_NOTE constant and process_cover_note() in git_events.rs; replaceable semantics (latest created_at, hex-id tiebreak), author or maintainer only - kind-1624 events fetched alongside labels in the fetch pipeline; cover_notes count added to FetchReport display - ngit pr/issue view: cover note displayed in place of description with a clear 'Cover Note:' header; maintainer-authored notes identify the author; original description shown only with --comments; cover_note object included in --json output - ngit pr set-cover-note / ngit issue set-cover-note: publish a kind-1624 event; nostr: mentions in --body converted to q/p tags via tags_from_content (same rules as issue --body) - Fix pre-existing clippy::too_many_lines on repo/mod.rs show_info
Diffstat (limited to 'src/bin/ngit/sub_commands/label.rs')
-rw-r--r--src/bin/ngit/sub_commands/label.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/bin/ngit/sub_commands/label.rs b/src/bin/ngit/sub_commands/label.rs
index 634e0b5..f6714ae 100644
--- a/src/bin/ngit/sub_commands/label.rs
+++ b/src/bin/ngit/sub_commands/label.rs
@@ -3,14 +3,13 @@ use ngit::{
3 client::{Params, get_issues_from_cache, get_proposals_and_revisions_from_cache, send_events}, 3 client::{Params, get_issues_from_cache, get_proposals_and_revisions_from_cache, send_events},
4 git_events::{KIND_LABEL, get_labels}, 4 git_events::{KIND_LABEL, get_labels},
5}; 5};
6use nostr::{EventBuilder, Tag, TagStandard}; 6use nostr::{EventBuilder, Tag, TagStandard, nips::nip19::Nip19};
7use nostr_sdk::{EventId, FromBech32}; 7use nostr_sdk::{EventId, FromBech32};
8use nostr::nips::nip19::Nip19;
9 8
10use crate::{ 9use crate::{
11 client::{ 10 client::{
12 Client, Connect, fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, 11 Client, Connect, fetching_with_report, get_events_from_local_cache,
13 save_event_in_local_cache, 12 get_repo_ref_from_cache, save_event_in_local_cache,
14 }, 13 },
15 git::{Repo, RepoActions}, 14 git::{Repo, RepoActions},
16 login, 15 login,
@@ -90,19 +89,13 @@ async fn publish_label_event(
90 89
91 // Permission check: only the author or a maintainer may label. 90 // Permission check: only the author or a maintainer may label.
92 if target.pubkey != user_pubkey && !repo_ref.maintainers.contains(&user_pubkey) { 91 if target.pubkey != user_pubkey && !repo_ref.maintainers.contains(&user_pubkey) {
93 bail!( 92 bail!("only the {target_kind} author or a repository maintainer can label a {target_kind}");
94 "only the {target_kind} author or a repository maintainer can label a {target_kind}"
95 );
96 } 93 }
97 94
98 // Fetch existing label events so we can warn about duplicates. 95 // Fetch existing label events so we can warn about duplicates.
99 let existing_label_events = get_events_from_local_cache( 96 let existing_label_events = get_events_from_local_cache(
100 git_repo_path, 97 git_repo_path,
101 vec![ 98 vec![nostr::Filter::default().event(event_id).kind(KIND_LABEL)],
102 nostr::Filter::default()
103 .event(event_id)
104 .kind(KIND_LABEL),
105 ],
106 ) 99 )
107 .await?; 100 .await?;
108 101
@@ -117,10 +110,7 @@ async fn publish_label_event(
117 .collect(); 110 .collect();
118 111
119 if new_labels.is_empty() { 112 if new_labels.is_empty() {
120 let already: Vec<String> = labels 113 let already: Vec<String> = labels.iter().map(|l| format!("#{}", l.trim())).collect();
121 .iter()
122 .map(|l| format!("#{}", l.trim()))
123 .collect();
124 println!( 114 println!(
125 "{target_kind} already has label{}: {}", 115 "{target_kind} already has label{}: {}",
126 if already.len() == 1 { "" } else { "s" }, 116 if already.len() == 1 { "" } else { "s" },