From 5fe839e2bf8ceb2931c1984efb2d956980431203 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 16 Dec 2024 07:58:54 +0000 Subject: chore: nix flake update update nix dependancies to latest version using default update options fix warning related to idomatic patterns --- src/bin/git_remote_nostr/fetch.rs | 17 ++++++++----- src/bin/git_remote_nostr/push.rs | 13 +++++----- src/bin/git_remote_nostr/utils.rs | 2 +- src/bin/ngit/sub_commands/init.rs | 53 +++++++++++++++++++-------------------- 4 files changed, 45 insertions(+), 40 deletions(-) (limited to 'src/bin') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 90387f3..458c6d8 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -141,9 +141,11 @@ async fn fetch_proposals( let current_user = get_curent_user(git_repo)?; for refstr in proposal_refs.keys() { - if let Some((_, (_, patches))) = - find_proposal_and_patches_by_branch_name(refstr, &open_proposals, ¤t_user) - { + if let Some((_, (_, patches))) = find_proposal_and_patches_by_branch_name( + refstr, + &open_proposals, + current_user.as_ref(), + ) { if let Err(error) = make_commits_for_proposal(git_repo, repo_ref, patches) { term.write_line( format!("WARNING: failed to create branch for {refstr}, error: {error}",) @@ -234,7 +236,7 @@ pub fn fetch_from_git_server( fn report_on_transfer_progress( progress_stats: &Progress<'_>, start_time: &Instant, - end_time: &Option, + end_time: Option<&Instant>, ) -> Vec { let mut report = vec![]; let total = progress_stats.total_objects() as f64; @@ -378,8 +380,11 @@ impl<'a> FetchReporter<'a> { self.start_time = Some(Instant::now()); } let existing_lines = self.just_count_transfer_progress(); - let updated = - report_on_transfer_progress(progress_stats, &self.start_time.unwrap(), &self.end_time); + let updated = report_on_transfer_progress( + progress_stats, + &self.start_time.unwrap(), + self.end_time.as_ref(), + ); if self.transfer_progress_msgs.len() <= updated.len() { if self.end_time.is_none() && updated.first().is_some_and(|f| f.contains("100%")) { self.end_time = Some(Instant::now()); diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 48122e3..f2ac169 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -299,7 +299,7 @@ async fn process_proposal_refspecs( let tip_of_pushed_branch = git_repo.get_commit_or_tip_of_reference(from)?; if let Some((_, (proposal, patches))) = - find_proposal_and_patches_by_branch_name(to, &all_proposals, ¤t_user) + find_proposal_and_patches_by_branch_name(to, &all_proposals, current_user.as_ref()) { if [repo_ref.maintainers.clone(), vec![proposal.pubkey]] .concat() @@ -576,7 +576,7 @@ fn report_on_transfer_progress( total: usize, bytes: usize, start_time: &Instant, - end_time: &Option, + end_time: Option<&Instant>, ) -> Option { if total == 0 { return None; @@ -688,7 +688,7 @@ impl<'a> PushReporter<'a> { total, bytes, &self.start_time.unwrap(), - &self.end_time, + self.end_time.as_ref(), ) { let existing_lines = self.count_all_existing_lines(); if report.contains("100%") { @@ -1215,11 +1215,12 @@ async fn create_merge_events( signer, repo_ref, &proposal, - &if let Some(revision_id) = revision_id { + if let Some(revision_id) = revision_id { Some(get_event_from_cache_by_id(git_repo, revision_id).await?) } else { None - }, + } + .as_ref(), if let Some((commit, _)) = merged_patches .iter() .find(|(_, m)| **m == MergedPRCommitType::MergeCommit) @@ -1263,7 +1264,7 @@ async fn create_merge_status( signer: &Arc, repo_ref: &RepoRef, proposal: &Event, - revision: &Option, + revision: Option<&Event>, merge_commits: Vec, merged_patches: Vec, applied: bool, diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 5efb6e0..8e89652 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -188,7 +188,7 @@ pub async fn get_all_proposals( pub fn find_proposal_and_patches_by_branch_name<'a>( refstr: &'a str, open_proposals: &'a HashMap)>, - current_user: &Option, + current_user: Option<&PublicKey>, ) -> Option<(&'a EventId, &'a (Event, Vec))> { open_proposals.iter().find(|(_, (proposal, _))| { is_event_proposal_root_for_branch(proposal, refstr, current_user).unwrap_or(false) diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 1695e4c..0894f41 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -364,34 +364,33 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { args.web.clone() }; - let earliest_unique_commit = match &args.earliest_unique_commit { - Some(t) => t.clone(), - None => { - let mut earliest_unique_commit = if let Some(repo_ref) = &repo_ref { - repo_ref.root_commit.clone() - } else { - root_commit.to_string() - }; - println!( - "the earliest unique commit helps with discoverability. It defaults to the root commit. Only change this if your repo has completely forked off an has formed its own identity." - ); - loop { - earliest_unique_commit = Interactor::default().input( - PromptInputParms::default() - .with_prompt("earliest unique commit (to help with discoverability)") - .with_default(earliest_unique_commit.clone()), - )?; - if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) { - if exists { - break earliest_unique_commit; - } - println!("commit does not exist on current repository"); - } else { - println!("commit id not formatted correctly"); - } - if earliest_unique_commit.len().ne(&40) { - println!("commit id must be 40 characters long"); + let earliest_unique_commit = if let Some(t) = &args.earliest_unique_commit { + t.clone() + } else { + let mut earliest_unique_commit = if let Some(repo_ref) = &repo_ref { + repo_ref.root_commit.clone() + } else { + root_commit.to_string() + }; + println!( + "the earliest unique commit helps with discoverability. It defaults to the root commit. Only change this if your repo has completely forked off an has formed its own identity." + ); + loop { + earliest_unique_commit = Interactor::default().input( + PromptInputParms::default() + .with_prompt("earliest unique commit (to help with discoverability)") + .with_default(earliest_unique_commit.clone()), + )?; + if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) { + if exists { + break earliest_unique_commit; } + println!("commit does not exist on current repository"); + } else { + println!("commit id not formatted correctly"); + } + if earliest_unique_commit.len().ne(&40) { + println!("commit id must be 40 characters long"); } } }; -- cgit v1.2.3