diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-12 16:21:38 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-12 16:21:38 +0000 |
| commit | 90fb2bbb72be8a371faa5f2adce728a5401b73fb (patch) | |
| tree | 503c5ef975fecc662110984713d7aa208b189e61 /src/bin/ngit/sub_commands/apply.rs | |
| parent | 1be46b4fd7a78ce418765ef5467823b7ea5e60eb (diff) | |
style: apply cargo clippy and fmt fixes
Reorganize imports and fix formatting issues flagged by clippy and rustfmt.
Diffstat (limited to 'src/bin/ngit/sub_commands/apply.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/apply.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/bin/ngit/sub_commands/apply.rs b/src/bin/ngit/sub_commands/apply.rs index fd9eae3..4ed6caa 100644 --- a/src/bin/ngit/sub_commands/apply.rs +++ b/src/bin/ngit/sub_commands/apply.rs | |||
| @@ -4,14 +4,18 @@ use std::{ | |||
| 4 | }; | 4 | }; |
| 5 | 5 | ||
| 6 | use anyhow::{Context, Result, bail}; | 6 | use anyhow::{Context, Result, bail}; |
| 7 | use ngit::client::get_all_proposal_patch_pr_pr_update_events_from_cache; | 7 | use ngit::{ |
| 8 | use ngit::git_events::get_pr_tip_event_or_most_recent_patch_with_ancestors; | 8 | client::get_all_proposal_patch_pr_pr_update_events_from_cache, |
| 9 | git_events::get_pr_tip_event_or_most_recent_patch_with_ancestors, | ||
| 10 | }; | ||
| 9 | use nostr::nips::nip19::Nip19; | 11 | use nostr::nips::nip19::Nip19; |
| 10 | use nostr_sdk::{EventId, FromBech32}; | 12 | use nostr_sdk::{EventId, FromBech32}; |
| 11 | 13 | ||
| 12 | use crate::client::{Client, Connect, fetching_with_report, get_repo_ref_from_cache}; | 14 | use crate::{ |
| 13 | use crate::git::{Repo, RepoActions}; | 15 | client::{Client, Connect, fetching_with_report, get_repo_ref_from_cache}, |
| 14 | use crate::repo_ref::get_repo_coordinates_when_remote_unknown; | 16 | git::{Repo, RepoActions}, |
| 17 | repo_ref::get_repo_coordinates_when_remote_unknown, | ||
| 18 | }; | ||
| 15 | 19 | ||
| 16 | fn run_git_fetch(remote_name: &str) -> Result<()> { | 20 | fn run_git_fetch(remote_name: &str) -> Result<()> { |
| 17 | println!("fetching from {remote_name}..."); | 21 | println!("fetching from {remote_name}..."); |
| @@ -55,11 +59,8 @@ pub async fn launch(id: &str, stdout: bool) -> Result<()> { | |||
| 55 | let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; | 59 | let repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &repo_coordinates).await?; |
| 56 | 60 | ||
| 57 | let proposals_and_revisions: Vec<nostr::Event> = | 61 | let proposals_and_revisions: Vec<nostr::Event> = |
| 58 | ngit::client::get_proposals_and_revisions_from_cache( | 62 | ngit::client::get_proposals_and_revisions_from_cache(git_repo_path, repo_ref.coordinates()) |
| 59 | git_repo_path, | 63 | .await?; |
| 60 | repo_ref.coordinates(), | ||
| 61 | ) | ||
| 62 | .await?; | ||
| 63 | 64 | ||
| 64 | let proposal = proposals_and_revisions | 65 | let proposal = proposals_and_revisions |
| 65 | .iter() | 66 | .iter() |
| @@ -79,10 +80,13 @@ pub async fn launch(id: &str, stdout: bool) -> Result<()> { | |||
| 79 | let patches = get_pr_tip_event_or_most_recent_patch_with_ancestors(commits_events.clone()) | 80 | let patches = get_pr_tip_event_or_most_recent_patch_with_ancestors(commits_events.clone()) |
| 80 | .context("failed to find any PR or patch events on this proposal")?; | 81 | .context("failed to find any PR or patch events on this proposal")?; |
| 81 | 82 | ||
| 82 | if patches | 83 | if patches.iter().any(|e| { |
| 83 | .iter() | 84 | [ |
| 84 | .any(|e| [ngit::git_events::KIND_PULL_REQUEST, ngit::git_events::KIND_PULL_REQUEST_UPDATE].contains(&e.kind)) | 85 | ngit::git_events::KIND_PULL_REQUEST, |
| 85 | { | 86 | ngit::git_events::KIND_PULL_REQUEST_UPDATE, |
| 87 | ] | ||
| 88 | .contains(&e.kind) | ||
| 89 | }) { | ||
| 86 | bail!( | 90 | bail!( |
| 87 | "this proposal uses PR format (not patches). Use `ngit checkout {}` instead.", | 91 | "this proposal uses PR format (not patches). Use `ngit checkout {}` instead.", |
| 88 | event_id.to_hex() | 92 | event_id.to_hex() |