feat: Add alt tag to the git issue

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-06-04 22:05:21 +00:00
parent 16e6300c81
commit 494cced9cb
4 changed files with 22 additions and 11 deletions

View File

@@ -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

View File

@@ -15,15 +15,15 @@
// along with this program. If not, see <https://gnu.org/licenses/gpl-3.0.html>.
/// `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;

View File

@@ -15,11 +15,11 @@
// along with this program. If not, see <https://gnu.org/licenses/gpl-3.0.html>.
/// 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,

View File

@@ -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<String>,
labels: Vec<String>,
) -> N34Result<EventBuilder> {
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)
}
}