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 +++++------ 5 files changed, 44 insertions(+), 57 deletions(-) (limited to 'src/bin/git_remote_nostr') 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(); -- cgit v1.2.3