Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Mar 13, 2023
1 parent cc0f506 commit 3836cc0
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 60 deletions.
5 changes: 2 additions & 3 deletions gix-features/src/progress.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! Various `prodash` types along with various utilities for comfort.
use std::io;

#[cfg(feature = "progress-unit-bytes")]
pub use bytesize;
pub use prodash::{
self,
messages::MessageLevel,
progress::{Discard, DoOrDiscard, Either, Id, Step, StepShared, Task, ThroughputOnDrop, Value, UNKNOWN},
unit, Progress, Unit,
};

#[cfg(feature = "progress-unit-bytes")]
pub use bytesize;
/// A stub for the portions of the `bytesize` crate that we use internally in `gitoxide`.
#[cfg(not(feature = "progress-unit-bytes"))]
pub mod bytesize {
Expand Down
2 changes: 1 addition & 1 deletion gix-pack/src/data/output/count/objects/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pub trait InsertImmutable {
}

mod trait_impls {
use gix_hash::ObjectId;
use std::cell::RefCell;

use gix_hash::ObjectId;
use gix_hashtable::HashSet;

use super::InsertImmutable;
Expand Down
3 changes: 1 addition & 2 deletions gix-packetline/src/read/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use bstr::ByteSlice;
use futures_io::AsyncRead;
use futures_lite::AsyncReadExt;

use crate::read::ProgressAction;
use crate::{
decode,
read::{ExhaustiveOutcome, WithSidebands},
read::{ExhaustiveOutcome, ProgressAction, WithSidebands},
PacketLineRef, StreamingPeekableIter, MAX_LINE_LEN, U16_HEX_BYTES,
};

Expand Down
3 changes: 1 addition & 2 deletions gix-packetline/src/read/blocking_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::io;

use bstr::ByteSlice;

use crate::read::ProgressAction;
use crate::{
decode,
read::{ExhaustiveOutcome, WithSidebands},
read::{ExhaustiveOutcome, ProgressAction, WithSidebands},
PacketLineRef, StreamingPeekableIter, MAX_LINE_LEN, U16_HEX_BYTES,
};

Expand Down
3 changes: 1 addition & 2 deletions gix-packetline/src/read/sidebands/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::{
use futures_io::{AsyncBufRead, AsyncRead};
use futures_lite::ready;

use crate::read::ProgressAction;
use crate::{decode, BandRef, PacketLineRef, StreamingPeekableIter, TextRef, U16_HEX_BYTES};
use crate::{decode, read::ProgressAction, BandRef, PacketLineRef, StreamingPeekableIter, TextRef, U16_HEX_BYTES};

type ReadLineResult<'a> = Option<std::io::Result<Result<PacketLineRef<'a>, decode::Error>>>;
/// An implementor of [`AsyncBufRead`] yielding packet lines on each call to [`read_line()`][AsyncBufRead::read_line()].
Expand Down
3 changes: 1 addition & 2 deletions gix-packetline/src/read/sidebands/blocking_io.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{io, io::BufRead};

use crate::read::ProgressAction;
use crate::{BandRef, PacketLineRef, StreamingPeekableIter, TextRef, U16_HEX_BYTES};
use crate::{read::ProgressAction, BandRef, PacketLineRef, StreamingPeekableIter, TextRef, U16_HEX_BYTES};

/// An implementor of [`BufRead`][io::BufRead] yielding packet lines on each call to [`read_line()`][io::BufRead::read_line()].
/// It's also possible to hide the underlying packet lines using the [`Read`][io::Read] implementation which is useful
Expand Down
3 changes: 1 addition & 2 deletions gix-packetline/tests/read/sideband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use bstr::{BString, ByteSlice};
#[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
use futures_lite::io::AsyncReadExt;
use gix_odb::pack;
use gix_packetline::read::ProgressAction;
use gix_packetline::PacketLineRef;
use gix_packetline::{read::ProgressAction, PacketLineRef};

use crate::read::streaming_peek_iter::fixture_bytes;

Expand Down
14 changes: 6 additions & 8 deletions gix-protocol/tests/fetch/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ mod v1 {
}

mod arguments {
use crate::fetch::response::id;
use crate::fetch::transport;
use bstr::ByteSlice;
use gix_protocol::{fetch, Command};
use gix_transport::client::Capabilities;
use gix_transport::Protocol;
use gix_transport::{client::Capabilities, Protocol};

use crate::fetch::{response::id, transport};

#[maybe_async::test(feature = "blocking-client", async(feature = "async-client", async_std::test))]
async fn all() -> crate::Result {
Expand Down Expand Up @@ -360,12 +359,11 @@ mod v2 {
}

mod arguments {
use crate::fetch::response::id;
use crate::fetch::transport;
use bstr::ByteSlice;
use gix_protocol::{fetch, Command};
use gix_transport::client::Capabilities;
use gix_transport::Protocol;
use gix_transport::{client::Capabilities, Protocol};

use crate::fetch::{response::id, transport};

#[maybe_async::test(feature = "blocking-client", async(feature = "async-client", async_std::test))]
async fn all() -> crate::Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ fn main() {

#[cfg(feature = "signals")]
fn main() -> std::io::Result<()> {
use gix_tempfile::{AutoRemove, ContainingDirectory};
use std::path::PathBuf;

use gix_tempfile::{AutoRemove, ContainingDirectory};

gix_tempfile::signal::setup(Default::default());
let filepath = PathBuf::new().join("writable-tempfile.ext");
let markerpath = PathBuf::new().join("marker.ext");
Expand Down
3 changes: 2 additions & 1 deletion gix-tempfile/examples/delete-tempfiles-on-sigterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ fn main() {

#[cfg(feature = "signals")]
fn main() -> std::io::Result<()> {
use gix_tempfile::{AutoRemove, ContainingDirectory};
use std::{
io::{stdout, Write},
path::PathBuf,
};

use gix_tempfile::{AutoRemove, ContainingDirectory};

gix_tempfile::signal::setup(Default::default());
let filepath = PathBuf::new().join("tempfile.ext");
let _tempfile = gix_tempfile::mark_at(&filepath, ContainingDirectory::Exists, AutoRemove::Tempfile)?;
Expand Down
3 changes: 2 additions & 1 deletion gix-tempfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ type HashMap<K, V> = dashmap::DashMap<K, V>;

#[cfg(not(feature = "hp-hashmap"))]
mod hashmap {
use parking_lot::Mutex;
use std::collections::HashMap;

use parking_lot::Mutex;

// TODO(performance): use the `gix-hashtable` slot-map once available. It seems quite fast already though, so experiment.
pub struct Concurrent<K, V> {
inner: Mutex<HashMap<K, V>>,
Expand Down
3 changes: 2 additions & 1 deletion gix-tempfile/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ pub fn cleanup_tempfiles_signal_safe() {
let current_pid = std::process::id();
#[cfg(feature = "hp-hashmap")]
{
use crate::NEXT_MAP_INDEX;
use std::sync::atomic::Ordering;

use crate::NEXT_MAP_INDEX;

let one_past_last_index = NEXT_MAP_INDEX.load(Ordering::SeqCst);
for idx in 0..one_past_last_index {
if let Some(entry) = REGISTRY.try_entry(idx) {
Expand Down
3 changes: 2 additions & 1 deletion gix-tempfile/src/signal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::REGISTRY;
use once_cell::sync::Lazy;

use crate::REGISTRY;

/// Initialize signal handlers and other state to keep track of tempfiles, and **must be called before the first tempfile is created**,
/// allowing to set the `mode` in which signal handlers are installed.
///
Expand Down
3 changes: 1 addition & 2 deletions gix-tempfile/tests/registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! These must be run in their own module to avoid interfering with other tests.
use std::io::Write;
use std::path::Path;
use std::{io::Write, path::Path};

use gix_tempfile::{AutoRemove, ContainingDirectory};

Expand Down
3 changes: 1 addition & 2 deletions gix-transport/src/client/async_io/bufread_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::{

use async_trait::async_trait;
use futures_io::{AsyncBufRead, AsyncRead};
use gix_packetline::read::ProgressAction;
use gix_packetline::PacketLineRef;
use gix_packetline::{read::ProgressAction, PacketLineRef};

use crate::{
client::{Error, MessageKind},
Expand Down
3 changes: 1 addition & 2 deletions gix-transport/src/client/blocking_io/bufread_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::{
ops::{Deref, DerefMut},
};

use gix_packetline::read::ProgressAction;
use gix_packetline::PacketLineRef;
use gix_packetline::{read::ProgressAction, PacketLineRef};

use crate::{
client::{Error, MessageKind},
Expand Down
6 changes: 4 additions & 2 deletions gix/src/config/tree/sections/gitoxide.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::config;
use crate::config::tree::{keys, Gitoxide, Key, Section};
use crate::{
config,
config::tree::{keys, Gitoxide, Key, Section},
};

impl Gitoxide {
/// The `gitoxide.allow` section.
Expand Down
9 changes: 5 additions & 4 deletions gix/src/remote/connection/fetch/receive_pack.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::sync::atomic::{AtomicBool, Ordering};

use gix_odb::FindExt;
use gix_protocol::fetch::Arguments;
use gix_protocol::transport::client::Transport;
use gix_protocol::transport::packetline::read::ProgressAction;
use gix_protocol::{
fetch::Arguments,
transport::{client::Transport, packetline::read::ProgressAction},
};

use crate::config::tree::Clone;
use crate::{
config::tree::Clone,
remote,
remote::{
connection::fetch::config,
Expand Down
12 changes: 7 additions & 5 deletions gix/src/repository/shallow.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::bstr::ByteSlice;
use crate::config::tree::{gitoxide, Key};
use crate::Repository;
use std::borrow::Cow;
use std::path::PathBuf;
use std::{borrow::Cow, path::PathBuf};

use crate::{
bstr::ByteSlice,
config::tree::{gitoxide, Key},
Repository,
};

impl Repository {
/// Return `true` if the repository is a shallow clone, i.e. contains history only up to a certain depth.
Expand Down
6 changes: 4 additions & 2 deletions gix/src/shallow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ pub type Commits = gix_features::fs::SharedSnapshot<Vec<gix_hash::ObjectId>>;
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
pub mod write {
pub(crate) mod function {
use crate::shallow::{write::Error, Commits};
use gix_protocol::fetch::response::ShallowUpdate;
use std::io::Write;

use gix_protocol::fetch::response::ShallowUpdate;

use crate::shallow::{write::Error, Commits};

/// Write the previously obtained (possibly non-existing) `shallow_commits` to the shallow `file`
/// after applying all `updates`.
///
Expand Down
22 changes: 14 additions & 8 deletions gix/tests/clone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ use crate::{remote, util::restricted};

#[cfg(feature = "blocking-network-client")]
mod blocking_io {
use gix::bstr::BString;
use gix::config::tree::{Clone, Core, Init, Key};
use gix::remote::Direction;
use gix_object::bstr::ByteSlice;
use gix_ref::TargetRef;
use std::sync::atomic::AtomicBool;

use crate::{remote, util::restricted};
use gix::{
bstr::BString,
config::tree::{Clone, Core, Init, Key},
remote::{
fetch::{Shallow, SpecIndex},
Direction,
},
};
use gix_object::bstr::ByteSlice;
use gix_ref::TargetRef;

use crate::util::hex_to_id;
use gix::remote::fetch::{Shallow, SpecIndex};
use crate::{
remote,
util::{hex_to_id, restricted},
};

#[test]
fn fetch_shallow_no_checkout_then_unshallow() -> crate::Result {
Expand Down
3 changes: 1 addition & 2 deletions gix/tests/remote/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ mod shallow {
mod blocking_and_async_io {
use std::sync::atomic::AtomicBool;

use gix::remote::fetch::Status;
use gix::remote::{fetch, Direction::Fetch};
use gix::remote::{fetch, fetch::Status, Direction::Fetch};
use gix_features::progress;
use gix_protocol::maybe_async;

Expand Down
3 changes: 2 additions & 1 deletion gix/tests/repository/shallow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ fn yes() -> crate::Result {
}

mod traverse {
use crate::util::{hex_to_id, named_subrepo_opts};
use gix_traverse::commit::Sorting;

use crate::util::{hex_to_id, named_subrepo_opts};

#[test]
fn boundary_is_detected_triggering_no_error() -> crate::Result {
for name in ["shallow.git", "shallow"] {
Expand Down
7 changes: 4 additions & 3 deletions src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ pub mod config {

#[cfg(feature = "gitoxide-core-blocking-client")]
pub mod fetch {
use gix::remote::fetch::Shallow;
use std::num::NonZeroU32;

use gix::remote::fetch::Shallow;

#[derive(Debug, clap::Parser)]
pub struct Platform {
/// Don't change the local repository, but otherwise try to be as accurate as possible.
Expand Down Expand Up @@ -209,9 +210,9 @@ pub mod fetch {

#[cfg(feature = "gitoxide-core-blocking-client")]
pub mod clone {
use std::{ffi::OsString, num::NonZeroU32, path::PathBuf};

use gix::remote::fetch::Shallow;
use std::num::NonZeroU32;
use std::{ffi::OsString, path::PathBuf};

#[derive(Debug, clap::Parser)]
pub struct Platform {
Expand Down

0 comments on commit 3836cc0

Please sign in to comment.