diff options
Diffstat (limited to 'src/lib/git_events.rs')
| -rw-r--r-- | src/lib/git_events.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index d818f4c..2adc205 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs | |||
| @@ -19,9 +19,9 @@ pub fn tag_value(event: &Event, tag_name: &str) -> Result<String> { | |||
| 19 | Ok(event | 19 | Ok(event |
| 20 | .tags | 20 | .tags |
| 21 | .iter() | 21 | .iter() |
| 22 | .find(|t| t.as_vec()[0].eq(tag_name)) | 22 | .find(|t| t.as_slice()[0].eq(tag_name)) |
| 23 | .context(format!("tag '{tag_name}'not present"))? | 23 | .context(format!("tag '{tag_name}'not present"))? |
| 24 | .as_vec()[1] | 24 | .as_slice()[1] |
| 25 | .clone()) | 25 | .clone()) |
| 26 | } | 26 | } |
| 27 | 27 | ||
| @@ -40,11 +40,11 @@ pub fn get_commit_id_from_patch(event: &Event) -> Result<String> { | |||
| 40 | pub fn get_event_root(event: &nostr::Event) -> Result<EventId> { | 40 | pub fn get_event_root(event: &nostr::Event) -> Result<EventId> { |
| 41 | Ok(EventId::parse( | 41 | Ok(EventId::parse( |
| 42 | event | 42 | event |
| 43 | .tags() | 43 | .tags |
| 44 | .iter() | 44 | .iter() |
| 45 | .find(|t| t.is_root()) | 45 | .find(|t| t.is_root()) |
| 46 | .context("no thread root in event")? | 46 | .context("no thread root in event")? |
| 47 | .as_vec() | 47 | .as_slice() |
| 48 | .get(1) | 48 | .get(1) |
| 49 | .unwrap(), | 49 | .unwrap(), |
| 50 | )?) | 50 | )?) |
| @@ -60,23 +60,23 @@ pub fn status_kinds() -> Vec<Kind> { | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | pub fn event_is_patch_set_root(event: &Event) -> bool { | 62 | pub fn event_is_patch_set_root(event: &Event) -> bool { |
| 63 | event.kind.eq(&Kind::GitPatch) && event.tags().iter().any(|t| t.as_vec()[1].eq("root")) | 63 | event.kind.eq(&Kind::GitPatch) && event.tags.iter().any(|t| t.as_slice()[1].eq("root")) |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | pub fn event_is_revision_root(event: &Event) -> bool { | 66 | pub fn event_is_revision_root(event: &Event) -> bool { |
| 67 | event.kind.eq(&Kind::GitPatch) | 67 | event.kind.eq(&Kind::GitPatch) |
| 68 | && event | 68 | && event |
| 69 | .tags() | 69 | .tags |
| 70 | .iter() | 70 | .iter() |
| 71 | .any(|t| t.as_vec()[1].eq("revision-root")) | 71 | .any(|t| t.as_slice()[1].eq("revision-root")) |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | pub fn patch_supports_commit_ids(event: &Event) -> bool { | 74 | pub fn patch_supports_commit_ids(event: &Event) -> bool { |
| 75 | event.kind.eq(&Kind::GitPatch) | 75 | event.kind.eq(&Kind::GitPatch) |
| 76 | && event | 76 | && event |
| 77 | .tags() | 77 | .tags |
| 78 | .iter() | 78 | .iter() |
| 79 | .any(|t| t.as_vec()[0].eq("commit-pgp-sig")) | 79 | .any(|t| t.as_slice()[0].eq("commit-pgp-sig")) |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | #[allow(clippy::too_many_arguments)] | 82 | #[allow(clippy::too_many_arguments)] |
| @@ -399,7 +399,7 @@ pub async fn generate_cover_letter_and_patch_events( | |||
| 399 | events.first().map(|event| event.id), | 399 | events.first().map(|event| event.id), |
| 400 | signer, | 400 | signer, |
| 401 | repo_ref, | 401 | repo_ref, |
| 402 | events.last().map(nostr::Event::id), | 402 | events.last().map(|e| e.id), |
| 403 | if events.is_empty() && commits.len().eq(&1) { | 403 | if events.is_empty() && commits.len().eq(&1) { |
| 404 | None | 404 | None |
| 405 | } else { | 405 | } else { |
| @@ -461,11 +461,11 @@ pub fn event_is_cover_letter(event: &nostr::Event) -> bool { | |||
| 461 | // [PATCH v1 0/n ] or | 461 | // [PATCH v1 0/n ] or |
| 462 | // [PATCH subsystem v2 0/n ] | 462 | // [PATCH subsystem v2 0/n ] |
| 463 | event.kind.eq(&Kind::GitPatch) | 463 | event.kind.eq(&Kind::GitPatch) |
| 464 | && event.tags().iter().any(|t| t.as_vec()[1].eq("root")) | 464 | && event.tags.iter().any(|t| t.as_slice()[1].eq("root")) |
| 465 | && event | 465 | && event |
| 466 | .tags() | 466 | .tags |
| 467 | .iter() | 467 | .iter() |
| 468 | .any(|t| t.as_vec()[1].eq("cover-letter")) | 468 | .any(|t| t.as_slice()[1].eq("cover-letter")) |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> { | 471 | pub fn commit_msg_from_patch(patch: &nostr::Event) -> Result<String> { |
| @@ -529,7 +529,7 @@ pub fn event_to_cover_letter(event: &nostr::Event) -> Result<CoverLetter> { | |||
| 529 | .collect(); | 529 | .collect(); |
| 530 | s | 530 | s |
| 531 | }, | 531 | }, |
| 532 | event_id: Some(event.id()), | 532 | event_id: Some(event.id), |
| 533 | }) | 533 | }) |
| 534 | } | 534 | } |
| 535 | 535 | ||
| @@ -580,17 +580,17 @@ fn get_event_parent_id(event: &nostr::Event) -> Result<String> { | |||
| 580 | Ok(if let Some(reply_tag) = event | 580 | Ok(if let Some(reply_tag) = event |
| 581 | .tags | 581 | .tags |
| 582 | .iter() | 582 | .iter() |
| 583 | .find(|t| t.as_vec().len().gt(&3) && t.as_vec()[3].eq("reply")) | 583 | .find(|t| t.as_slice().len().gt(&3) && t.as_slice()[3].eq("reply")) |
| 584 | { | 584 | { |
| 585 | reply_tag | 585 | reply_tag |
| 586 | } else { | 586 | } else { |
| 587 | event | 587 | event |
| 588 | .tags | 588 | .tags |
| 589 | .iter() | 589 | .iter() |
| 590 | .find(|t| t.as_vec().len().gt(&3) && t.as_vec()[3].eq("root")) | 590 | .find(|t| t.as_slice().len().gt(&3) && t.as_slice()[3].eq("root")) |
| 591 | .context("no reply or root e tag present".to_string())? | 591 | .context("no reply or root e tag present".to_string())? |
| 592 | } | 592 | } |
| 593 | .as_vec()[1] | 593 | .as_slice()[1] |
| 594 | .clone()) | 594 | .clone()) |
| 595 | } | 595 | } |
| 596 | 596 | ||
| @@ -601,7 +601,7 @@ pub fn is_event_proposal_root_for_branch( | |||
| 601 | ) -> Result<bool> { | 601 | ) -> Result<bool> { |
| 602 | let branch_name = branch_name_or_refstr.replace("refs/heads/", ""); | 602 | let branch_name = branch_name_or_refstr.replace("refs/heads/", ""); |
| 603 | Ok(event_to_cover_letter(e).is_ok_and(|cl| { | 603 | Ok(event_to_cover_letter(e).is_ok_and(|cl| { |
| 604 | (logged_in_user.is_some_and(|public_key| e.author().eq(&public_key)) | 604 | (logged_in_user.is_some_and(|public_key| e.pubkey.eq(&public_key)) |
| 605 | && (branch_name.eq(&format!("pr/{}", cl.branch_name)) | 605 | && (branch_name.eq(&format!("pr/{}", cl.branch_name)) |
| 606 | || cl.branch_name.eq(&branch_name))) | 606 | || cl.branch_name.eq(&branch_name))) |
| 607 | || cl.get_branch_name().is_ok_and(|s| s.eq(&branch_name)) | 607 | || cl.get_branch_name().is_ok_and(|s| s.eq(&branch_name)) |