diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/git/mod.rs | 2 | ||||
| -rw-r--r-- | src/lib/git_events.rs | 19 | ||||
| -rw-r--r-- | src/lib/login/user.rs | 9 |
3 files changed, 19 insertions, 11 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index 0615213..7a7ad5d 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs | |||
| @@ -850,7 +850,7 @@ fn git_sig_to_tag_vec(sig: &git2::Signature) -> Vec<String> { | |||
| 850 | fn extract_sig_from_patch_tags<'a>(tags: &'a Tags, tag_name: &str) -> Result<git2::Signature<'a>> { | 850 | fn extract_sig_from_patch_tags<'a>(tags: &'a Tags, tag_name: &str) -> Result<git2::Signature<'a>> { |
| 851 | let v = tags | 851 | let v = tags |
| 852 | .iter() | 852 | .iter() |
| 853 | .find(|t| t.as_slice()[0].eq(tag_name)) | 853 | .find(|t| !t.as_slice().is_empty() && t.as_slice()[0].eq(tag_name)) |
| 854 | .context(format!("tag '{tag_name}' not present in patch"))? | 854 | .context(format!("tag '{tag_name}' not present in patch"))? |
| 855 | .as_slice(); | 855 | .as_slice(); |
| 856 | if v.len() != 5 { | 856 | if v.len() != 5 { |
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 | ||
| 61 | pub fn event_is_patch_set_root(event: &Event) -> bool { | 61 | pub 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 | ||
| 65 | pub fn event_is_revision_root(event: &Event) -> bool { | 69 | pub 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 | ||
| 73 | pub fn patch_supports_commit_ids(event: &Event) -> bool { | 77 | pub 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 | ||
| 483 | pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> { | 490 | pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> { |
diff --git a/src/lib/login/user.rs b/src/lib/login/user.rs index c13cdf5..de4a2d9 100644 --- a/src/lib/login/user.rs +++ b/src/lib/login/user.rs | |||
| @@ -187,10 +187,11 @@ pub fn extract_user_relays(public_key: &nostr::PublicKey, events: &[nostr::Event | |||
| 187 | .tags | 187 | .tags |
| 188 | .iter() | 188 | .iter() |
| 189 | .filter(|t| { | 189 | .filter(|t| { |
| 190 | t.kind() | 190 | t.as_slice().len() > 1 |
| 191 | .eq(&nostr::TagKind::SingleLetter(SingleLetterTag::lowercase( | 191 | && t.kind() |
| 192 | Alphabet::R, | 192 | .eq(&nostr::TagKind::SingleLetter(SingleLetterTag::lowercase( |
| 193 | ))) | 193 | Alphabet::R, |
| 194 | ))) | ||
| 194 | }) | 195 | }) |
| 195 | .map(|t| UserRelayRef { | 196 | .map(|t| UserRelayRef { |
| 196 | url: t.as_slice()[1].clone(), | 197 | url: t.as_slice()[1].clone(), |