From 2874ba8457b2af4b7ee9e6bb708cc3695975c3d6 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Mon, 30 Jun 2025 11:11:25 +0000
Subject: [PATCH] remove: Remove `--euc` flag from `patch send` command and use
the repo euc
Signed-off-by: Awiteb
---
CHANGELOG.md | 1 +
src/cli/commands/patch/send.rs | 13 +++++--------
src/nostr_utils/traits.rs | 6 ++++++
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 561d2cc..19b6fc5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove the `--repo` option and make the repo an argument - by Awiteb
- Remove the `--to` flag from `reply` command and make it an argument - by Awiteb
+- Remove `--euc` flag from `patch send` command and use the repo euc - by Awiteb
## [0.2.0] - 2025-06-01
diff --git a/src/cli/commands/patch/send.rs b/src/cli/commands/patch/send.rs
index ea6eb6c..666ce09 100644
--- a/src/cli/commands/patch/send.rs
+++ b/src/cli/commands/patch/send.rs
@@ -58,12 +58,6 @@ pub struct SendArgs {
/// `nostr:npub1...`.
#[arg(value_name = "PATCH-PATH", required = true, value_parser = parse_patch_path)]
patches: Vec,
- /// The earliest unique commit ID in the repository.
- ///
- /// Can be obtained by running `git rev-parse master` (replace 'master' with
- /// your base branch name).
- #[arg(long, value_name = "COMMIT-ID")]
- euc: Sha1,
/// Original patch ID if this is a revision of it
#[arg(long, value_name = "EVENT-ID")]
original_patch: Option,
@@ -90,6 +84,7 @@ impl CommandRunner for SendArgs {
.add_relays(&utils::add_read_relays(relays_list.as_ref()))
.await;
let repos = client.fetch_repos(&repo_coordinates).await?;
+ let euc = repos.extract_euc();
let maintainers = repos.extract_maintainers();
client.add_relays(&repos.extract_relays()).await;
@@ -99,7 +94,7 @@ impl CommandRunner for SendArgs {
self.original_patch.as_ref().map(|e| e.event_id),
repos.extract_relays().first().cloned(),
repo_coordinates,
- &self.euc,
+ euc,
user_pubk,
)
.await?;
@@ -224,7 +219,6 @@ async fn make_patch(
let mut safe_dedup_tags = Tags::new();
safe_dedup_tags.push(Tag::alt(format!("{PATCH_ALT_PREFIX}{}", patch.subject)));
safe_dedup_tags.push(Tag::description(patch.subject));
- safe_dedup_tags.push(Tag::reference(euc.to_string()));
safe_dedup_tags.extend(content_details.into_tags());
safe_dedup_tags.extend(
repo_coordinates
@@ -236,6 +230,9 @@ async fn make_patch(
.iter()
.map(|c| Tag::public_key(c.public_key)),
);
+ if let Some(euc) = euc {
+ safe_dedup_tags.push(Tag::reference(euc.to_string()));
+ }
safe_dedup_tags.dedup();
let mut event_builder = EventBuilder::new(Kind::GitPatch, patch.inner).tags(safe_dedup_tags);
diff --git a/src/nostr_utils/traits.rs b/src/nostr_utils/traits.rs
index 1241e11..a0cb517 100644
--- a/src/nostr_utils/traits.rs
+++ b/src/nostr_utils/traits.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see .
use convert_case::{Case, Casing};
+use nostr::hashes::sha1::Hash as Sha1Hash;
use nostr::{
event::{Event, EventBuilder, EventId, Kind, Tag, TagKind, TagStandard, Tags},
key::PublicKey,
@@ -215,6 +216,11 @@ impl Vec {
pub fn extract_maintainers(&self) -> Vec {
self.iter().flat_map(|r| r.maintainers.clone()).collect()
}
+
+ /// Gets the first EUC hash from the reposotoies if it exists.
+ pub fn extract_euc(&self) -> Option<&Sha1Hash> {
+ self.iter().find_map(|r| r.euc.as_ref())
+ }
}
/// Utility functions for working with patch events