upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib/git_events.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/git_events.rs')
-rw-r--r--src/lib/git_events.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs
index 10194bb..17fae8c 100644
--- a/src/lib/git_events.rs
+++ b/src/lib/git_events.rs
@@ -18,7 +18,7 @@ pub fn tag_value(event: &Event, tag_name: &str) -> Result<String> {
18 Ok(event 18 Ok(event
19 .tags 19 .tags
20 .iter() 20 .iter()
21 .find(|t| t.as_slice()[0].eq(tag_name)) 21 .find(|t| !t.as_slice().is_empty() && t.as_slice()[0].eq(tag_name))
22 .context(format!("tag '{tag_name}'not present"))? 22 .context(format!("tag '{tag_name}'not present"))?
23 .as_slice()[1] 23 .as_slice()[1]
24 .clone()) 24 .clone())
@@ -59,7 +59,11 @@ pub fn status_kinds() -> Vec<Kind> {
59} 59}
60 60
61pub fn event_is_patch_set_root(event: &Event) -> bool { 61pub fn event_is_patch_set_root(event: &Event) -> bool {
62 event.kind.eq(&Kind::GitPatch) && event.tags.iter().any(|t| t.as_slice()[1].eq("root")) 62 event.kind.eq(&Kind::GitPatch)
63 && event
64 .tags
65 .iter()
66 .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("root"))
63} 67}
64 68
65pub fn event_is_revision_root(event: &Event) -> bool { 69pub fn event_is_revision_root(event: &Event) -> bool {
@@ -67,7 +71,7 @@ pub fn event_is_revision_root(event: &Event) -> bool {
67 && event 71 && event
68 .tags 72 .tags
69 .iter() 73 .iter()
70 .any(|t| t.as_slice()[1].eq("revision-root")) 74 .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("revision-root"))
71} 75}
72 76
73pub fn patch_supports_commit_ids(event: &Event) -> bool { 77pub fn patch_supports_commit_ids(event: &Event) -> bool {
@@ -75,7 +79,7 @@ pub fn patch_supports_commit_ids(event: &Event) -> bool {
75 && event 79 && event
76 .tags 80 .tags
77 .iter() 81 .iter()
78 .any(|t| t.as_slice()[0].eq("commit-pgp-sig")) 82 .any(|t| !t.as_slice().is_empty() && t.as_slice()[0].eq("commit-pgp-sig"))
79} 83}
80 84
81#[allow(clippy::too_many_arguments)] 85#[allow(clippy::too_many_arguments)]
@@ -473,11 +477,14 @@ pub fn event_is_cover_letter(event: &nostr::Event) -> bool {
473 // [PATCH v1 0/n ] or 477 // [PATCH v1 0/n ] or
474 // [PATCH subsystem v2 0/n ] 478 // [PATCH subsystem v2 0/n ]
475 event.kind.eq(&Kind::GitPatch) 479 event.kind.eq(&Kind::GitPatch)
476 && event.tags.iter().any(|t| t.as_slice()[1].eq("root"))
477 && event 480 && event
478 .tags 481 .tags
479 .iter() 482 .iter()
480 .any(|t| t.as_slice()[1].eq("cover-letter")) 483 .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("root"))
484 && event
485 .tags
486 .iter()
487 .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("cover-letter"))
481} 488}
482 489
483pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> { 490pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> {