From 4ee83e2fe5335a8afd78439c35f029c4a472e797 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 16 Dec 2024 09:00:46 +0000 Subject: chore: bump nix flake rust nightly `fmt` overlay update the rust nightly `fmt` overlay which needs to be pinned to a specific version (this case by date) update formatting in main files via `cargo fmt` --- src/bin/git_remote_nostr/fetch.rs | 10 +++--- src/bin/git_remote_nostr/list.rs | 6 ++-- src/bin/git_remote_nostr/main.rs | 6 ++-- src/bin/git_remote_nostr/push.rs | 62 ++++++++++++++------------------ src/bin/git_remote_nostr/utils.rs | 17 ++++----- src/bin/ngit/cli.rs | 2 +- src/bin/ngit/sub_commands/export_keys.rs | 2 +- src/bin/ngit/sub_commands/init.rs | 12 +++---- src/bin/ngit/sub_commands/list.rs | 19 +++++----- src/bin/ngit/sub_commands/login.rs | 4 +-- src/bin/ngit/sub_commands/logout.rs | 2 +- src/bin/ngit/sub_commands/send.rs | 17 +++++---- 12 files changed, 71 insertions(+), 88 deletions(-) (limited to 'src/bin') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 458c6d8..7012955 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -6,15 +6,15 @@ use std::{ time::Instant, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use auth_git2::GitAuthenticator; use git2::{Progress, Repository}; use ngit::{ cli_interactor::count_lines_per_msg_vec, git::{ + Repo, RepoActions, nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol}, utils::check_ssh_keys, - Repo, RepoActions, }, git_events::tag_value, login::get_curent_user, @@ -24,9 +24,9 @@ use nostr::nips::nip19; use nostr_sdk::{Event, ToBech32}; use crate::utils::{ - fetch_or_list_error_is_not_authentication_failure, find_proposal_and_patches_by_branch_name, - get_oids_from_fetch_batch, get_open_proposals, get_read_protocols_to_try, join_with_and, - set_protocol_preference, Direction, + Direction, fetch_or_list_error_is_not_authentication_failure, + find_proposal_and_patches_by_branch_name, get_oids_from_fetch_batch, get_open_proposals, + get_read_protocols_to_try, join_with_and, set_protocol_preference, }; pub async fn run_fetch( diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs index 9171544..bba15aa 100644 --- a/src/bin/git_remote_nostr/list.rs +++ b/src/bin/git_remote_nostr/list.rs @@ -1,7 +1,7 @@ use core::str; use std::collections::HashMap; -use anyhow::{anyhow, Context, Result}; +use anyhow::{Context, Result, anyhow}; use auth_git2::GitAuthenticator; use client::get_state_from_cache; use git::RepoActions; @@ -22,9 +22,9 @@ use crate::{ fetch::{fetch_from_git_server, make_commits_for_proposal}, git::Repo, utils::{ - fetch_or_list_error_is_not_authentication_failure, get_open_proposals, + Direction, fetch_or_list_error_is_not_authentication_failure, get_open_proposals, get_read_protocols_to_try, get_short_git_server_name, join_with_and, - set_protocol_preference, Direction, + set_protocol_preference, }, }; diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index 1a21341..e6f7af3 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -11,9 +11,9 @@ use std::{ path::{Path, PathBuf}, }; -use anyhow::{bail, Context, Result}; -use client::{consolidate_fetch_reports, get_repo_ref_from_cache, Connect}; -use git::{nostr_url::NostrUrlDecoded, RepoActions}; +use anyhow::{Context, Result, bail}; +use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache}; +use git::{RepoActions, nostr_url::NostrUrlDecoded}; use ngit::{client, git, login::existing::load_existing_login}; use nostr::nips::nip01::Coordinate; use utils::read_line; diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index f2ac169..e8e1587 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -6,17 +6,17 @@ use std::{ time::Instant, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use auth_git2::GitAuthenticator; use client::{ - get_events_from_local_cache, get_state_from_cache, send_events, sign_event, STATE_KIND, + STATE_KIND, get_events_from_local_cache, get_state_from_cache, send_events, sign_event, }; use console::Term; -use git::{sha1_to_oid, RepoActions}; -use git2::{Oid, Repository}; +use git::{RepoActions, sha1_to_oid}; use git_events::{ generate_cover_letter_and_patch_events, generate_patch_event, get_commit_id_from_patch, }; +use git2::{Oid, Repository}; use ngit::{ cli_interactor::count_lines_per_msg_vec, client::{self, get_event_from_cache_by_id}, @@ -32,8 +32,8 @@ use ngit::{ }; use nostr::nips::nip10::Marker; use nostr_sdk::{ - hashes::sha1::Hash as Sha1Hash, Event, EventBuilder, EventId, Kind, NostrSigner, PublicKey, - RelayUrl, Tag, + Event, EventBuilder, EventId, Kind, NostrSigner, PublicKey, RelayUrl, Tag, + hashes::sha1::Hash as Sha1Hash, }; use repo_ref::RepoRef; use repo_state::RepoState; @@ -43,9 +43,10 @@ use crate::{ git::Repo, list::list_from_remotes, utils::{ - find_proposal_and_patches_by_branch_name, get_all_proposals, get_remote_name_by_url, - get_short_git_server_name, get_write_protocols_to_try, join_with_and, - push_error_is_not_authentication_failure, read_line, set_protocol_preference, Direction, + Direction, find_proposal_and_patches_by_branch_name, get_all_proposals, + get_remote_name_by_url, get_short_git_server_name, get_write_protocols_to_try, + join_with_and, push_error_is_not_authentication_failure, read_line, + set_protocol_preference, }, }; @@ -1023,13 +1024,10 @@ async fn get_merged_status_events( let (ahead, _) = git_repo.get_commits_ahead_behind(&tip_of_remote_branch, &tip_of_pushed_branch)?; - let commit_events = get_events_from_local_cache( - git_repo.get_path()?, - vec![ - nostr::Filter::default().kind(nostr::Kind::GitPatch), - // TODO: limit by repo_ref - ], - ) + let commit_events = get_events_from_local_cache(git_repo.get_path()?, vec![ + nostr::Filter::default().kind(nostr::Kind::GitPatch), + // TODO: limit by repo_ref + ]) .await?; let merged_proposals_info = @@ -1106,12 +1104,9 @@ async fn get_merged_proposals_info( proposals.entry(proposal_id).or_default(); // ignore revisions without all the merged commits if entry_revision_id == &revision_id { - merged_patches.insert( - *commit_hash, - MergedPRCommitType::PatchCommit { - event_id: patch_event.id, - }, - ); + merged_patches.insert(*commit_hash, MergedPRCommitType::PatchCommit { + event_id: patch_event.id, + }); } } } @@ -1136,12 +1131,9 @@ async fn get_merged_proposals_info( proposals.entry(proposal_id).or_default(); // ignore revisions without all the applied commits if entry_revision_id == &revision_id { - merged_patches.insert( - *commit_hash, - MergedPRCommitType::PatchApplied { - event_id: patch_event.id, - }, - ); + merged_patches.insert(*commit_hash, MergedPRCommitType::PatchApplied { + event_id: patch_event.id, + }); } } } @@ -1379,10 +1371,9 @@ async fn get_proposal_and_revision_root_from_patch( .clone(), )?; - get_events_from_local_cache( - git_repo.get_path()?, - vec![nostr::Filter::default().id(proposal_or_revision_id)], - ) + get_events_from_local_cache(git_repo.get_path()?, vec![ + nostr::Filter::default().id(proposal_or_revision_id), + ]) .await? .first() .unwrap() @@ -1538,10 +1529,9 @@ impl BuildRepoState for RepoState { ) -> Result { let mut tags = vec![Tag::identifier(identifier.clone())]; for (name, value) in &state { - tags.push(Tag::custom( - nostr_sdk::TagKind::Custom(name.into()), - vec![value.clone()], - )); + tags.push(Tag::custom(nostr_sdk::TagKind::Custom(name.into()), vec![ + value.clone(), + ])); } let event = sign_event(EventBuilder::new(STATE_KIND, "").tags(tags), signer).await?; Ok(RepoState { diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 8e89652..15ebb10 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -6,7 +6,7 @@ use std::{ str::FromStr, }; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use git2::Repository; use ngit::{ client::{ @@ -14,8 +14,8 @@ use ngit::{ get_proposals_and_revisions_from_cache, }, git::{ - nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol}, Repo, RepoActions, + nostr_url::{CloneUrl, NostrUrlDecoded, ServerProtocol}, }, git_events::{ event_is_revision_root, get_most_recent_patch_with_ancestors, @@ -108,14 +108,11 @@ pub async fn get_open_proposals( .collect(); let statuses: Vec = { - let mut statuses = get_events_from_local_cache( - git_repo_path, - vec![ - nostr::Filter::default() - .kinds(status_kinds().clone()) - .events(proposals.iter().map(|e| e.id)), - ], - ) + let mut statuses = get_events_from_local_cache(git_repo_path, vec![ + nostr::Filter::default() + .kinds(status_kinds().clone()) + .events(proposals.iter().map(|e| e.id)), + ]) .await?; statuses.sort_by_key(|e| e.created_at); statuses.reverse(); diff --git a/src/bin/ngit/cli.rs b/src/bin/ngit/cli.rs index 1737a9f..60bc5d2 100644 --- a/src/bin/ngit/cli.rs +++ b/src/bin/ngit/cli.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::{Parser, Subcommand}; use ngit::login::SignerInfo; diff --git a/src/bin/ngit/sub_commands/export_keys.rs b/src/bin/ngit/sub_commands/export_keys.rs index 54a716f..45b1b89 100644 --- a/src/bin/ngit/sub_commands/export_keys.rs +++ b/src/bin/ngit/sub_commands/export_keys.rs @@ -2,9 +2,9 @@ use anyhow::{Context, Result}; use ngit::{ cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms}, login::{ + SignerInfo, SignerInfoSource, existing::{get_signer_info, load_existing_login}, fresh::generate_qr, - SignerInfo, SignerInfoSource, }, }; diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 0894f41..80e182b 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -3,18 +3,18 @@ use std::collections::HashMap; use anyhow::{Context, Result}; use console::Style; use ngit::{cli_interactor::PromptConfirmParms, git::nostr_url::NostrUrlDecoded}; -use nostr::{nips::nip01::Coordinate, FromBech32, PublicKey, ToBech32}; +use nostr::{FromBech32, PublicKey, ToBech32, nips::nip01::Coordinate}; use nostr_sdk::{Kind, RelayUrl}; use crate::{ - cli::{extract_signer_cli_arguments, Cli}, + cli::{Cli, extract_signer_cli_arguments}, cli_interactor::{Interactor, InteractorPrompt, PromptInputParms}, - client::{fetching_with_report, get_repo_ref_from_cache, send_events, Client, Connect}, - git::{nostr_url::convert_clone_url_to_https, Repo, RepoActions}, + client::{Client, Connect, fetching_with_report, get_repo_ref_from_cache, send_events}, + git::{Repo, RepoActions, nostr_url::convert_clone_url_to_https}, login, repo_ref::{ - extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, - try_and_get_repo_coordinates_when_remote_unknown, RepoRef, + RepoRef, extract_pks, get_repo_config_from_yaml, save_repo_config_to_yaml, + try_and_get_repo_coordinates_when_remote_unknown, }, }; diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs index ee015ef..9b84c1b 100644 --- a/src/bin/ngit/sub_commands/list.rs +++ b/src/bin/ngit/sub_commands/list.rs @@ -1,6 +1,6 @@ use std::{io::Write, ops::Add}; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use ngit::{ client::{get_all_proposal_patch_events_from_cache, get_proposals_and_revisions_from_cache}, git_events::{ @@ -12,9 +12,9 @@ use nostr_sdk::Kind; use crate::{ cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms, PromptConfirmParms}, client::{ - fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, Client, Connect, + Client, Connect, fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, }, - git::{str_to_sha1, Repo, RepoActions}, + git::{Repo, RepoActions, str_to_sha1}, git_events::{ commit_msg_from_patch_oneliner, event_is_revision_root, event_to_cover_letter, patch_supports_commit_ids, @@ -47,14 +47,11 @@ pub async fn launch() -> Result<()> { } let statuses: Vec = { - let mut statuses = get_events_from_local_cache( - git_repo_path, - vec![ - nostr::Filter::default() - .kinds(status_kinds().clone()) - .events(proposals_and_revisions.iter().map(|e| e.id)), - ], - ) + let mut statuses = get_events_from_local_cache(git_repo_path, vec![ + nostr::Filter::default() + .kinds(status_kinds().clone()) + .events(proposals_and_revisions.iter().map(|e| e.id)), + ]) .await?; statuses.sort_by_key(|e| e.created_at); statuses.reverse(); diff --git a/src/bin/ngit/sub_commands/login.rs b/src/bin/ngit/sub_commands/login.rs index ccbdf01..06236ec 100644 --- a/src/bin/ngit/sub_commands/login.rs +++ b/src/bin/ngit/sub_commands/login.rs @@ -3,11 +3,11 @@ use clap; use ngit::{ cli_interactor::{Interactor, InteractorPrompt, PromptChoiceParms}, git::{get_git_config_item, remove_git_config_item}, - login::{existing::load_existing_login, SignerInfoSource}, + login::{SignerInfoSource, existing::load_existing_login}, }; use crate::{ - cli::{extract_signer_cli_arguments, Cli}, + cli::{Cli, extract_signer_cli_arguments}, client::{Client, Connect}, git::Repo, login::fresh::fresh_login_or_signup, diff --git a/src/bin/ngit/sub_commands/logout.rs b/src/bin/ngit/sub_commands/logout.rs index f3f9620..2df96c8 100644 --- a/src/bin/ngit/sub_commands/logout.rs +++ b/src/bin/ngit/sub_commands/logout.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result}; use ngit::{ git::remove_git_config_item, - login::{existing::load_existing_login, SignerInfoSource}, + login::{SignerInfoSource, existing::load_existing_login}, }; use crate::{ diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index c6c75c9..7c898bc 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs @@ -1,23 +1,23 @@ use std::path::Path; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use console::Style; use ngit::{client::send_events, git_events::generate_cover_letter_and_patch_events}; use nostr::{ - nips::{nip10::Marker, nip19::Nip19Event}, ToBech32, + nips::{nip10::Marker, nip19::Nip19Event}, }; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use crate::{ - cli::{extract_signer_cli_arguments, Cli}, + cli::{Cli, extract_signer_cli_arguments}, cli_interactor::{ Interactor, InteractorPrompt, PromptConfirmParms, PromptInputParms, PromptMultiChoiceParms, }, client::{ - fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, Client, Connect, + Client, Connect, fetching_with_report, get_events_from_local_cache, get_repo_ref_from_cache, }, - git::{identify_ahead_behind, Repo, RepoActions}, + git::{Repo, RepoActions, identify_ahead_behind}, git_events::{event_is_patch_set_root, event_tag_from_nip19_or_hex}, login, repo_ref::get_repo_coordinates_when_remote_unknown, @@ -369,10 +369,9 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to( public_key: _, uppercase: false, }) => { - let events = get_events_from_local_cache( - git_repo_path, - vec![nostr::Filter::new().id(*event_id)], - ) + let events = get_events_from_local_cache(git_repo_path, vec![ + nostr::Filter::new().id(*event_id), + ]) .await?; if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { -- cgit v1.2.3