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 --- flake.lock | 24 +++++++++--------- 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 +++++++++++++++++++-------------------- src/lib/git_events.rs | 4 +-- 6 files changed, 59 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index 94315c0..a01b7d4 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1726463316, - "narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=", + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", "type": "github" }, "original": { @@ -36,11 +36,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1718428119, - "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "lastModified": 1728538411, + "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221", "type": "github" }, "original": { @@ -62,11 +62,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1726626348, - "narHash": "sha256-sYV7e1B1yLcxo8/h+/hTwzZYmaju2oObNiy5iRI0C30=", + "lastModified": 1734316514, + "narHash": "sha256-0aLx44yMblcOGpfFXKCzp2GhU5JaE6OTvdU+JYrXiUc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "6fd52ad8bd88f39efb2c999cc971921c2fb9f3a2", + "rev": "83ee8ff74d6294a7657320f16814754c4594127b", "type": "github" }, "original": { 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"); } } }; diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 17fae8c..d8564ae 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs @@ -619,11 +619,11 @@ fn get_event_parent_id(event: &nostr::Event) -> Result { pub fn is_event_proposal_root_for_branch( e: &Event, branch_name_or_refstr: &str, - logged_in_user: &Option, + logged_in_user: Option<&PublicKey>, ) -> Result { let branch_name = branch_name_or_refstr.replace("refs/heads/", ""); Ok(event_to_cover_letter(e).is_ok_and(|cl| { - (logged_in_user.is_some_and(|public_key| e.pubkey.eq(&public_key)) + (logged_in_user.is_some_and(|public_key| e.pubkey.eq(public_key)) && (branch_name.eq(&format!("pr/{}", cl.branch_name)) || cl.branch_name.eq(&branch_name))) || cl.get_branch_name().is_ok_and(|s| s.eq(&branch_name)) -- cgit v1.2.3