From ad215002e271eed33409aee6361e6630223d5f28 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Mon, 4 Aug 2025 09:10:03 +0000
Subject: [PATCH] chore: backward compatibility with `ngit` revision patch
hashtag
Signed-off-by: Awiteb
---
src/cli/commands/patch/mod.rs | 4 ++++
src/nostr_utils/traits.rs | 17 ++++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/cli/commands/patch/mod.rs b/src/cli/commands/patch/mod.rs
index 4ac5401..2cd5660 100644
--- a/src/cli/commands/patch/mod.rs
+++ b/src/cli/commands/patch/mod.rs
@@ -72,6 +72,10 @@ static PATCH_VERSION_NUMBER_RE: LazyLock = LazyLock::new(|| {
pub const ROOT_HASHTAG_CONTENT: &str = "root";
/// Content of the hashtag representing the root revision patch.
pub const REVISION_ROOT_HASHTAG_CONTENT: &str = "root-revision";
+/// The content of the hashtag used by `ngit-cli` to represent a root revision
+/// patch before the commit 6ae42e67d9da36f6c2e1356acba30a3a62112bc7. This was a
+/// typo.
+pub const LEGACY_NGIT_REVISION_ROOT_HASHTAG_CONTENT: &str = "revision-root";
#[derive(Subcommand, Debug)]
pub enum PatchSubcommands {
diff --git a/src/nostr_utils/traits.rs b/src/nostr_utils/traits.rs
index 59d0647..d91a68b 100644
--- a/src/nostr_utils/traits.rs
+++ b/src/nostr_utils/traits.rs
@@ -31,7 +31,11 @@ use nostr::{
use nostr_keyring::KeyringError;
use crate::cli::issue::ISSUE_ALT_PREFIX;
-use crate::cli::patch::{REVISION_ROOT_HASHTAG_CONTENT, ROOT_HASHTAG_CONTENT};
+use crate::cli::patch::{
+ LEGACY_NGIT_REVISION_ROOT_HASHTAG_CONTENT,
+ REVISION_ROOT_HASHTAG_CONTENT,
+ ROOT_HASHTAG_CONTENT,
+};
use crate::error::{N34Error, N34Result};
@@ -254,10 +258,13 @@ impl Event {
#[inline]
pub fn is_revision_patch(&self) -> bool {
self.kind == Kind::GitPatch
- && self
- .tags
- .filter(TagKind::t())
- .any(|t| t.content() == Some(REVISION_ROOT_HASHTAG_CONTENT))
+ && self.tags.filter(TagKind::t()).any(|t| {
+ [
+ Some(REVISION_ROOT_HASHTAG_CONTENT),
+ Some(LEGACY_NGIT_REVISION_ROOT_HASHTAG_CONTENT),
+ ]
+ .contains(&t.content())
+ })
}
/// Gets the root patch ID from a patch-revision event by finding the `e`