From 494cced9cbccc08a623f88a1283494448cbdfee1 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Wed, 4 Jun 2025 22:05:21 +0000 Subject: [PATCH] feat: Add `alt` tag to the git issue Signed-off-by: Awiteb --- src/cli/commands/issue/mod.rs | 3 +++ src/cli/commands/mod.rs | 10 +++++----- src/main.rs | 6 +++--- src/nostr_utils/traits.rs | 14 +++++++++++--- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/cli/commands/issue/mod.rs b/src/cli/commands/issue/mod.rs index c1bd6f3..fa6f463 100644 --- a/src/cli/commands/issue/mod.rs +++ b/src/cli/commands/issue/mod.rs @@ -23,6 +23,9 @@ use self::new::NewArgs; use super::{CliOptions, CommandRunner}; use crate::error::N34Result; +/// Prefix used for git issue alt. +pub const ISSUE_ALT_PREFIX: &str = "git issue: "; + #[derive(Subcommand, Debug)] pub enum IssueSubcommands { /// Create a new repository issue diff --git a/src/cli/commands/mod.rs b/src/cli/commands/mod.rs index c8ec244..0042c6a 100644 --- a/src/cli/commands/mod.rs +++ b/src/cli/commands/mod.rs @@ -15,15 +15,15 @@ // along with this program. If not, see . /// `issue` subcommands -mod issue; +pub mod issue; /// `patch` subcommands -mod patch; +pub mod patch; /// 'reply` command -mod reply; +pub mod reply; /// `repo` subcommands -mod repo; +pub mod repo; /// `sets` subcommands -mod sets; +pub mod sets; use std::fmt; use std::path::PathBuf; diff --git a/src/main.rs b/src/main.rs index 1d0c1e3..2f5bdb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,11 +15,11 @@ // along with this program. If not, see . /// Command line interface module -mod cli; +pub mod cli; /// N34 errors -mod error; +pub mod error; /// Nostr utils module -mod nostr_utils; +pub mod nostr_utils; use std::{ process::ExitCode, diff --git a/src/nostr_utils/traits.rs b/src/nostr_utils/traits.rs index 04789f5..777dcd3 100644 --- a/src/nostr_utils/traits.rs +++ b/src/nostr_utils/traits.rs @@ -28,6 +28,7 @@ use nostr::{ types::{RelayUrl, Url}, }; +use crate::cli::issue::ISSUE_ALT_PREFIX; use crate::error::{N34Error, N34Result}; @@ -115,13 +116,20 @@ impl EventBuilder { subject: Option, labels: Vec, ) -> N34Result { - EventBuilder::git_issue(GitIssue { + let mut event_builder = EventBuilder::git_issue(GitIssue { repository, content, - subject, + subject: subject.clone(), labels: labels.into_iter().map(|l| l.trim().to_owned()).collect(), }) - .map_err(N34Error::from) + .map_err(N34Error::from)?; + + if let Some(issue_subject) = subject { + event_builder = + event_builder.tag(Tag::alt(format!("{ISSUE_ALT_PREFIX}{issue_subject}"))) + } + + Ok(event_builder) } }