diff --git a/git-attributes/src/lib.rs b/git-attributes/src/lib.rs index 26276a82c59..691ed4a5463 100644 --- a/git-attributes/src/lib.rs +++ b/git-attributes/src/lib.rs @@ -1,10 +1,10 @@ #![forbid(unsafe_code)] #![deny(rust_2018_idioms)] -use bstr::{BStr, BString}; -use compact_str::CompactStr; use std::path::PathBuf; +use bstr::{BStr, BString}; +use compact_str::CompactStr; pub use git_glob as glob; /// The state an attribute can be in, referencing the value. diff --git a/git-attributes/src/match_group.rs b/git-attributes/src/match_group.rs index 8fd5b045999..de3b6d56880 100644 --- a/git-attributes/src/match_group.rs +++ b/git-attributes/src/match_group.rs @@ -1,8 +1,12 @@ -use crate::{Assignment, MatchGroup, PatternList, PatternMapping, State, StateRef}; +use std::{ + ffi::OsString, + io::Read, + path::{Path, PathBuf}, +}; + use bstr::{BStr, BString, ByteSlice, ByteVec}; -use std::ffi::OsString; -use std::io::Read; -use std::path::{Path, PathBuf}; + +use crate::{Assignment, MatchGroup, PatternList, PatternMapping, State, StateRef}; impl<'a> From> for State { fn from(s: StateRef<'a>) -> Self { diff --git a/git-attributes/tests/match_group/mod.rs b/git-attributes/tests/match_group/mod.rs index a8b661eb1a5..f70b448c233 100644 --- a/git-attributes/tests/match_group/mod.rs +++ b/git-attributes/tests/match_group/mod.rs @@ -1,8 +1,9 @@ mod ignore { + use std::io::Read; + use bstr::{BStr, ByteSlice}; use git_attributes::{Ignore, Match, MatchGroup}; use git_glob::pattern::Case; - use std::io::Read; struct Expectations<'a> { lines: bstr::Lines<'a>, diff --git a/git-credentials/src/helper.rs b/git-credentials/src/helper.rs index 32a10c90960..2240a82dba0 100644 --- a/git-credentials/src/helper.rs +++ b/git-credentials/src/helper.rs @@ -181,9 +181,10 @@ mod tests { type Result = std::result::Result<(), Box>; mod encode_message { - use super::*; use bstr::ByteSlice; + use super::*; + #[test] fn from_url() -> super::Result { let mut out = Vec::new(); @@ -193,9 +194,10 @@ mod tests { } mod invalid { - use super::*; use std::io; + use super::*; + #[test] fn contains_null() { assert_eq!( diff --git a/git-glob/src/pattern.rs b/git-glob/src/pattern.rs index 78c771e91c9..fa874b22613 100644 --- a/git-glob/src/pattern.rs +++ b/git-glob/src/pattern.rs @@ -1,6 +1,7 @@ +use std::fmt; + use bitflags::bitflags; use bstr::{BStr, ByteSlice}; -use std::fmt; use crate::{pattern, wildmatch, Pattern}; diff --git a/git-glob/tests/pattern/mod.rs b/git-glob/tests/pattern/mod.rs index 1a66b98fa8d..ef91f08ba5a 100644 --- a/git-glob/tests/pattern/mod.rs +++ b/git-glob/tests/pattern/mod.rs @@ -1,5 +1,4 @@ -use git_glob::pattern::Mode; -use git_glob::Pattern; +use git_glob::{pattern::Mode, Pattern}; #[test] fn display() { diff --git a/git-glob/tests/wildmatch/mod.rs b/git-glob/tests/wildmatch/mod.rs index 5b0962f7533..97471a13a00 100644 --- a/git-glob/tests/wildmatch/mod.rs +++ b/git-glob/tests/wildmatch/mod.rs @@ -1,9 +1,9 @@ -use bstr::ByteSlice; use std::{ fmt::{Debug, Display, Formatter}, panic::catch_unwind, }; +use bstr::ByteSlice; use git_glob::{pattern::Case, wildmatch, Pattern}; #[test] diff --git a/git-lock/src/lib.rs b/git-lock/src/lib.rs index f67a6aafbfc..e8daa23cf53 100644 --- a/git-lock/src/lib.rs +++ b/git-lock/src/lib.rs @@ -17,9 +17,8 @@ use std::path::PathBuf; -use git_tempfile::handle::{Closed, Writable}; - pub use git_tempfile as tempfile; +use git_tempfile::handle::{Closed, Writable}; const DOT_LOCK_SUFFIX: &str = ".lock"; diff --git a/git-path/src/convert.rs b/git-path/src/convert.rs index 5c2853aae45..7a49284734f 100644 --- a/git-path/src/convert.rs +++ b/git-path/src/convert.rs @@ -1,10 +1,11 @@ -use bstr::{BStr, BString}; use std::{ borrow::Cow, ffi::OsStr, path::{Path, PathBuf}, }; +use bstr::{BStr, BString}; + #[derive(Debug)] /// The error type returned by [`into_bstr()`] and others may suffer from failed conversions from or to bytes. pub struct Utf8Error; diff --git a/git-path/src/spec.rs b/git-path/src/spec.rs index 4c41e40fb28..ff878bde141 100644 --- a/git-path/src/spec.rs +++ b/git-path/src/spec.rs @@ -1,7 +1,9 @@ -use crate::Spec; -use bstr::{BStr, ByteSlice, ByteVec}; use std::ffi::OsStr; +use bstr::{BStr, ByteSlice, ByteVec}; + +use crate::Spec; + impl std::convert::TryFrom<&OsStr> for Spec { type Error = crate::Utf8Error; diff --git a/git-repository/src/config.rs b/git-repository/src/config.rs index 3c262e7e943..f272d072543 100644 --- a/git-repository/src/config.rs +++ b/git-repository/src/config.rs @@ -1,5 +1,4 @@ -use crate::bstr::BString; -use crate::permission::EnvVarResourcePermission; +use crate::{bstr::BString, permission::EnvVarResourcePermission}; #[derive(Debug, thiserror::Error)] pub enum Error { @@ -47,8 +46,7 @@ pub(crate) struct Cache { } mod cache { - use std::convert::TryFrom; - use std::path::PathBuf; + use std::{convert::TryFrom, path::PathBuf}; use git_config::{ file::GitConfig, @@ -56,8 +54,7 @@ mod cache { }; use super::{Cache, Error}; - use crate::bstr::ByteSlice; - use crate::permission::EnvVarResourcePermission; + use crate::{bstr::ByteSlice, permission::EnvVarResourcePermission}; impl Cache { pub fn new( diff --git a/git-repository/src/lib.rs b/git-repository/src/lib.rs index caba6dec2ac..e5e2959c960 100644 --- a/git-repository/src/lib.rs +++ b/git-repository/src/lib.rs @@ -244,8 +244,7 @@ pub fn open(directory: impl Into) -> Result; @@ -299,9 +298,10 @@ pub mod rev_parse { /// pub mod init { - use crate::ThreadSafeRepository; use std::path::Path; + use crate::ThreadSafeRepository; + /// The error returned by [`crate::init()`]. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] @@ -362,9 +362,10 @@ pub mod state { /// pub mod discover { - use crate::{path, ThreadSafeRepository}; use std::path::Path; + use crate::{path, ThreadSafeRepository}; + /// The error returned by [`crate::discover()`]. #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] diff --git a/git-repository/src/open.rs b/git-repository/src/open.rs index 69f4276c6f8..8ac9140a694 100644 --- a/git-repository/src/open.rs +++ b/git-repository/src/open.rs @@ -1,9 +1,10 @@ use std::path::PathBuf; -use crate::Permissions; use git_features::threading::OwnShared; use git_sec::Trust; +use crate::Permissions; + /// A way to configure the usage of replacement objects, see `git replace`. pub enum ReplacementObjects { /// Allow replacement objects and configure the ref prefix the standard environment variable `GIT_REPLACE_REF_BASE`, diff --git a/git-repository/src/path/discover.rs b/git-repository/src/path/discover.rs index 087c7273c98..fdf82ad2bb4 100644 --- a/git-repository/src/path/discover.rs +++ b/git-repository/src/path/discover.rs @@ -41,13 +41,14 @@ impl Default for Options { } pub(crate) mod function { - use super::{Error, Options}; - use git_sec::Trust; use std::{ borrow::Cow, path::{Component, Path}, }; + use git_sec::Trust; + + use super::{Error, Options}; use crate::path; /// Find the location of the git repository directly in `directory` or in any of its parent directories and provide diff --git a/git-repository/src/path/mod.rs b/git-repository/src/path/mod.rs index 3668fa3dd07..ae58987f0d7 100644 --- a/git-repository/src/path/mod.rs +++ b/git-repository/src/path/mod.rs @@ -1,10 +1,10 @@ use std::path::PathBuf; -use crate::{Kind, Path}; - #[cfg(all(feature = "unstable", feature = "git-path"))] pub use git_path::*; +use crate::{Kind, Path}; + /// pub mod create; /// diff --git a/git-repository/src/repository/permissions.rs b/git-repository/src/repository/permissions.rs index 5f0713abbec..365250c35fe 100644 --- a/git-repository/src/repository/permissions.rs +++ b/git-repository/src/repository/permissions.rs @@ -1,6 +1,6 @@ +use git_sec::{permission::Resource, Access, Trust}; + use crate::permission::EnvVarResourcePermission; -use git_sec::permission::Resource; -use git_sec::{Access, Trust}; /// Permissions associated with various resources of a git repository pub struct Permissions { diff --git a/git-repository/src/worktree.rs b/git-repository/src/worktree.rs index 421cea89e21..5bcf25ac065 100644 --- a/git-repository/src/worktree.rs +++ b/git-repository/src/worktree.rs @@ -1,7 +1,8 @@ -use crate::Repository; #[cfg(all(feature = "unstable", feature = "git-worktree"))] pub use git_worktree::*; +use crate::Repository; + /// #[cfg(feature = "git-index")] pub mod open_index { diff --git a/git-repository/tests/commit/mod.rs b/git-repository/tests/commit/mod.rs index 1f4e1e27a13..0330c177618 100644 --- a/git-repository/tests/commit/mod.rs +++ b/git-repository/tests/commit/mod.rs @@ -1,7 +1,8 @@ mod describe { - use crate::named_repo; use git_repository::commit::describe::SelectRef::{AllRefs, AllTags, AnnotatedTags}; + use crate::named_repo; + #[test] fn tags_are_sorted_by_date_and_lexigraphically() { let repo = named_repo("make_commit_describe_multiple_tags.sh").unwrap(); diff --git a/git-repository/tests/repository/state.rs b/git-repository/tests/repository/state.rs index be1127a8245..98a9cf65ba6 100644 --- a/git-repository/tests/repository/state.rs +++ b/git-repository/tests/repository/state.rs @@ -1,6 +1,7 @@ -use crate::{named_repo, Result}; use git_repository as git; +use crate::{named_repo, Result}; + #[test] fn apply_mailbox() -> Result { let repo = named_repo("make_am_repo.sh")?; diff --git a/git-sec/src/lib.rs b/git-sec/src/lib.rs index bea8a7d8e6e..82a0b5dd6b4 100644 --- a/git-sec/src/lib.rs +++ b/git-sec/src/lib.rs @@ -1,9 +1,11 @@ #![deny(unsafe_code, rust_2018_idioms, missing_docs)] //! A shared trust model for `gitoxide` crates. -use std::fmt::{Debug, Display, Formatter}; -use std::marker::PhantomData; -use std::ops::Deref; +use std::{ + fmt::{Debug, Display, Formatter}, + marker::PhantomData, + ops::Deref, +}; /// A way to specify how 'safe' we feel about a resource, typically about a git repository. #[derive(Copy, Clone, Ord, PartialOrd, PartialEq, Eq, Debug, Hash)] @@ -75,9 +77,10 @@ pub mod trust { /// pub mod permission { - use crate::Access; use std::fmt::{Debug, Display}; + use crate::Access; + /// A marker trait to signal tags for permissions. pub trait Tag: Debug + Clone {} diff --git a/git-transport/src/client/mod.rs b/git-transport/src/client/mod.rs index 1df469d8656..bb50ca4e185 100644 --- a/git-transport/src/client/mod.rs +++ b/git-transport/src/client/mod.rs @@ -26,9 +26,8 @@ pub mod capabilities; pub use capabilities::Capabilities; mod non_io_types; -pub use non_io_types::{Error, MessageKind, WriteMode}; - pub use git_sec::identity::Account; +pub use non_io_types::{Error, MessageKind, WriteMode}; /// #[cfg(any(feature = "blocking-client", feature = "async-client"))] diff --git a/git-worktree/src/fs/cache/mod.rs b/git-worktree/src/fs/cache/mod.rs index bd098ad4d48..c2d68ed8f47 100644 --- a/git-worktree/src/fs/cache/mod.rs +++ b/git-worktree/src/fs/cache/mod.rs @@ -1,9 +1,10 @@ -use super::Cache; -use crate::fs; -use crate::fs::PathOidMapping; +use std::path::{Path, PathBuf}; + use bstr::{BStr, ByteSlice}; use git_hash::oid; -use std::path::{Path, PathBuf}; + +use super::Cache; +use crate::{fs, fs::PathOidMapping}; #[derive(Clone)] pub enum State { diff --git a/git-worktree/src/fs/cache/platform.rs b/git-worktree/src/fs/cache/platform.rs index 4ee5cfa13b5..49ef3ae6af9 100644 --- a/git-worktree/src/fs/cache/platform.rs +++ b/git-worktree/src/fs/cache/platform.rs @@ -1,9 +1,15 @@ -use crate::fs; -use crate::fs::cache::{Platform, State}; -use crate::fs::PathOidMapping; +use std::path::Path; + use bstr::ByteSlice; use git_hash::oid; -use std::path::Path; + +use crate::{ + fs, + fs::{ + cache::{Platform, State}, + PathOidMapping, + }, +}; impl<'a, 'paths> Platform<'a, 'paths> { /// The full path to `relative` will be returned for use on the file system. diff --git a/git-worktree/src/fs/cache/state.rs b/git-worktree/src/fs/cache/state.rs index 273c3dacb3a..c99c84efed1 100644 --- a/git-worktree/src/fs/cache/state.rs +++ b/git-worktree/src/fs/cache/state.rs @@ -1,9 +1,10 @@ -use crate::fs::cache::State; -use crate::fs::PathOidMapping; +use std::path::Path; + use bstr::{BStr, BString, ByteSlice}; use git_glob::pattern::Case; use git_hash::oid; -use std::path::Path; + +use crate::fs::{cache::State, PathOidMapping}; type AttributeMatchGroup = git_attributes::MatchGroup; type IgnoreMatchGroup = git_attributes::MatchGroup; diff --git a/git-worktree/src/fs/capabilities.rs b/git-worktree/src/fs/capabilities.rs index 5c2a6e08c92..64daab9cea3 100644 --- a/git-worktree/src/fs/capabilities.rs +++ b/git-worktree/src/fs/capabilities.rs @@ -1,6 +1,7 @@ -use crate::fs::Capabilities; use std::path::Path; +use crate::fs::Capabilities; + #[cfg(windows)] impl Default for Capabilities { fn default() -> Self { diff --git a/git-worktree/src/fs/mod.rs b/git-worktree/src/fs/mod.rs index 4092f56f71b..cb490365969 100644 --- a/git-worktree/src/fs/mod.rs +++ b/git-worktree/src/fs/mod.rs @@ -1,6 +1,7 @@ -use bstr::BStr; use std::path::PathBuf; +use bstr::BStr; + /// Common knowledge about the worktree that is needed across most interactions with the work tree #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] diff --git a/git-worktree/src/fs/stack.rs b/git-worktree/src/fs/stack.rs index 6ccf84769a2..090b660798b 100644 --- a/git-worktree/src/fs/stack.rs +++ b/git-worktree/src/fs/stack.rs @@ -1,6 +1,7 @@ -use crate::fs::Stack; use std::path::{Path, PathBuf}; +use crate::fs::Stack; + impl Stack { pub fn root(&self) -> &Path { &self.root diff --git a/git-worktree/tests/worktree/fs/cache.rs b/git-worktree/tests/worktree/fs/cache.rs index bb92087715f..4ed44643ce8 100644 --- a/git-worktree/tests/worktree/fs/cache.rs +++ b/git-worktree/tests/worktree/fs/cache.rs @@ -117,13 +117,12 @@ mod create_directory { #[allow(unused)] mod ignore_and_attributes { - use bstr::{BStr, ByteSlice}; use std::path::Path; + use bstr::{BStr, ByteSlice}; use git_glob::pattern::Case; use git_index::entry::Mode; - use git_odb::pack::bundle::write::Options; - use git_odb::FindExt; + use git_odb::{pack::bundle::write::Options, FindExt}; use git_testtools::hex_to_id; use git_worktree::fs; use tempfile::{tempdir, TempDir}; diff --git a/git-worktree/tests/worktree/fs/stack/mod.rs b/git-worktree/tests/worktree/fs/stack/mod.rs index 2be7f9b519d..41e3406cead 100644 --- a/git-worktree/tests/worktree/fs/stack/mod.rs +++ b/git-worktree/tests/worktree/fs/stack/mod.rs @@ -1,6 +1,7 @@ -use git_worktree::fs::Stack; use std::path::{Path, PathBuf}; +use git_worktree::fs::Stack; + #[derive(Debug, Default, Eq, PartialEq)] struct Record { push_dir: usize, diff --git a/gitoxide-core/src/repository/exclude.rs b/gitoxide-core/src/repository/exclude.rs index a3b5e4c2bcd..ab20cf01b08 100644 --- a/gitoxide-core/src/repository/exclude.rs +++ b/gitoxide-core/src/repository/exclude.rs @@ -1,14 +1,16 @@ -use anyhow::{bail, Context}; use std::io; -use crate::OutputFormat; +use anyhow::{bail, Context}; use git_repository as git; use git_repository::prelude::FindExt; +use crate::OutputFormat; + pub mod query { - use crate::OutputFormat; use std::ffi::OsString; + use crate::OutputFormat; + pub struct Options { pub format: OutputFormat, pub overrides: Vec, diff --git a/src/plumbing/options.rs b/src/plumbing/options.rs index 0807c9f0ed2..751114244d0 100644 --- a/src/plumbing/options.rs +++ b/src/plumbing/options.rs @@ -378,9 +378,10 @@ pub mod repo { } pub mod exclude { - use git_repository as git; use std::ffi::OsString; + use git_repository as git; + #[derive(Debug, clap::Subcommand)] pub enum Subcommands { /// Check if path-specs are excluded and print the result similar to `git check-ignore`. diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index 04dc7928193..8c44cdc3da6 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -1,8 +1,8 @@ -use std::io::Read; -use std::time::Duration; use std::{ collections::BTreeMap, + io::Read, path::{Path, PathBuf}, + time::Duration, }; pub use bstr;