diff --git a/git-attributes/src/match_group.rs b/git-attributes/src/match_group.rs index 7732762d0a..57193c4b6d 100644 --- a/git-attributes/src/match_group.rs +++ b/git-attributes/src/match_group.rs @@ -1,11 +1,13 @@ -use crate::{Assignment, MatchGroup, PatternList, PatternMapping}; -use bstr::{BStr, BString, ByteSlice, ByteVec}; use std::{ ffi::OsString, io::Read, path::{Path, PathBuf}, }; +use bstr::{BStr, BString, ByteSlice, ByteVec}; + +use crate::{Assignment, MatchGroup, PatternList, PatternMapping}; + fn into_owned_assignments<'a>( attrs: impl Iterator, crate::name::Error>>, ) -> Result, crate::name::Error> { diff --git a/git-attributes/src/name.rs b/git-attributes/src/name.rs index bc213f88ed..03064dbda9 100644 --- a/git-attributes/src/name.rs +++ b/git-attributes/src/name.rs @@ -1,6 +1,7 @@ -use crate::{Name, NameRef}; use bstr::BString; +use crate::{Name, NameRef}; + impl<'a> NameRef<'a> { /// Turn this ref into its owned counterpart. pub fn to_owned(self) -> Name { diff --git a/git-attributes/src/parse/attribute.rs b/git-attributes/src/parse/attribute.rs index 148eb76053..deb39cd527 100644 --- a/git-attributes/src/parse/attribute.rs +++ b/git-attributes/src/parse/attribute.rs @@ -1,7 +1,9 @@ -use crate::{name, AssignmentRef, Name, NameRef, StateRef}; -use bstr::{BStr, ByteSlice}; use std::borrow::Cow; +use bstr::{BStr, ByteSlice}; + +use crate::{name, AssignmentRef, Name, NameRef, StateRef}; + /// The kind of attribute that was parsed. #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] #[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] diff --git a/git-attributes/src/state.rs b/git-attributes/src/state.rs index 3ae275492e..02dc8ee0da 100644 --- a/git-attributes/src/state.rs +++ b/git-attributes/src/state.rs @@ -1,6 +1,7 @@ -use crate::{State, StateRef}; use bstr::ByteSlice; +use crate::{State, StateRef}; + impl<'a> StateRef<'a> { /// Turn ourselves into our owned counterpart. pub fn to_owned(self) -> State { diff --git a/git-date/src/time.rs b/git-date/src/time.rs index 285953ed56..71c8154864 100644 --- a/git-date/src/time.rs +++ b/git-date/src/time.rs @@ -1,6 +1,7 @@ -use bstr::BString; use std::{convert::TryInto, io, ops::Sub}; +use bstr::BString; + use crate::Time; /// Indicates if a number is positive or negative for use in [`Time`]. diff --git a/git-discover/src/upwards.rs b/git-discover/src/upwards.rs index 044ffc749c..c844e745dc 100644 --- a/git-discover/src/upwards.rs +++ b/git-discover/src/upwards.rs @@ -117,9 +117,10 @@ mod parse_ceiling_dirs { #[test] #[cfg(unix)] fn from_environment_format() -> std::io::Result<()> { - use super::*; use std::{fs, os::unix::fs::symlink}; + use super::*; + // Setup filesystem let dir = tempfile::tempdir().expect("success creating temp dir"); let direct_path = dir.path().join("direct"); diff --git a/git-features/src/fs.rs b/git-features/src/fs.rs index e9c8a69eaa..134b142571 100644 --- a/git-features/src/fs.rs +++ b/git-features/src/fs.rs @@ -72,9 +72,10 @@ pub fn open_options_no_follow() -> std::fs::OpenOptions { } mod snapshot { - use crate::threading::{get_mut, get_ref, MutableOnDemand, OwnShared}; use std::ops::Deref; + use crate::threading::{get_mut, get_ref, MutableOnDemand, OwnShared}; + /// A structure holding enough information to reload a value if its on-disk representation changes as determined by its modified time. #[derive(Debug)] pub struct Snapshot { diff --git a/git-index/src/write.rs b/git-index/src/write.rs index 50def2768e..73592dd654 100644 --- a/git-index/src/write.rs +++ b/git-index/src/write.rs @@ -1,10 +1,12 @@ -use crate::{extension, State, Version}; -use bstr::ByteVec; use std::{ collections::{hash_map, HashMap}, ops::Range, }; +use bstr::ByteVec; + +use crate::{extension, State, Version}; + impl State { pub fn write_to(&self, options: Options) -> Vec { let mut writer = Writer::new(self, options); diff --git a/git-odb/src/store_impls/dynamic/find.rs b/git-odb/src/store_impls/dynamic/find.rs index c8414cad8a..79bfcfa31d 100644 --- a/git-odb/src/store_impls/dynamic/find.rs +++ b/git-odb/src/store_impls/dynamic/find.rs @@ -1,5 +1,4 @@ -use std::collections::HashSet; -use std::{convert::TryInto, ops::Deref}; +use std::{collections::HashSet, convert::TryInto, ops::Deref}; use git_hash::{oid, ObjectId}; use git_pack::{cache::DecodeEntry, data::entry::Location}; diff --git a/git-odb/src/store_impls/dynamic/handle.rs b/git-odb/src/store_impls/dynamic/handle.rs index 46b4697e03..ee70a8e197 100644 --- a/git-odb/src/store_impls/dynamic/handle.rs +++ b/git-odb/src/store_impls/dynamic/handle.rs @@ -69,8 +69,7 @@ pub struct IndexForObjectInPack { } pub(crate) mod index_lookup { - use std::collections::HashSet; - use std::sync::Arc; + use std::{collections::HashSet, sync::Arc}; use git_hash::oid; diff --git a/git-odb/src/store_impls/loose/find.rs b/git-odb/src/store_impls/loose/find.rs index 88896529ef..989140cf84 100644 --- a/git-odb/src/store_impls/loose/find.rs +++ b/git-odb/src/store_impls/loose/find.rs @@ -1,5 +1,4 @@ -use std::collections::HashSet; -use std::{cmp::Ordering, fs, io::Read, path::PathBuf}; +use std::{cmp::Ordering, collections::HashSet, fs, io::Read, path::PathBuf}; use git_features::zlib; diff --git a/git-odb/tests/odb/store/dynamic.rs b/git-odb/tests/odb/store/dynamic.rs index dc43a56d08..c2a293aab2 100644 --- a/git-odb/tests/odb/store/dynamic.rs +++ b/git-odb/tests/odb/store/dynamic.rs @@ -553,9 +553,10 @@ mod disambiguate_prefix { } mod lookup_prefix { + use std::collections::HashSet; + use git_testtools::hex_to_id; use maplit::hashset; - use std::collections::HashSet; use crate::store::dynamic::{assert_all_indices_loaded, db_with_all_object_sources}; diff --git a/git-odb/tests/odb/store/loose.rs b/git-odb/tests/odb/store/loose.rs index 735a941be4..2290c83a44 100644 --- a/git-odb/tests/odb/store/loose.rs +++ b/git-odb/tests/odb/store/loose.rs @@ -85,9 +85,10 @@ mod contains { } mod lookup_prefix { + use std::collections::HashSet; + use git_testtools::{fixture_path, hex_to_id}; use maplit::hashset; - use std::collections::HashSet; use crate::store::loose::ldb; diff --git a/git-pack/src/index/access.rs b/git-pack/src/index/access.rs index 8edc58900a..3a41cf350c 100644 --- a/git-pack/src/index/access.rs +++ b/git-pack/src/index/access.rs @@ -1,5 +1,4 @@ -use std::mem::size_of; -use std::ops::Range; +use std::{mem::size_of, ops::Range}; use crate::{ data, diff --git a/git-pack/src/multi_index/access.rs b/git-pack/src/multi_index/access.rs index 89de9a59f0..d0bc291626 100644 --- a/git-pack/src/multi_index/access.rs +++ b/git-pack/src/multi_index/access.rs @@ -1,5 +1,7 @@ -use std::ops::Range; -use std::path::{Path, PathBuf}; +use std::{ + ops::Range, + path::{Path, PathBuf}, +}; use crate::{ data, diff --git a/git-pathspec/src/parse.rs b/git-pathspec/src/parse.rs index 469b26ea92..4b3be8ccda 100644 --- a/git-pathspec/src/parse.rs +++ b/git-pathspec/src/parse.rs @@ -1,7 +1,9 @@ -use crate::{MagicSignature, MatchMode, Pattern}; -use bstr::{BStr, BString, ByteSlice, ByteVec}; use std::borrow::Cow; +use bstr::{BStr, BString, ByteSlice, ByteVec}; + +use crate::{MagicSignature, MatchMode, Pattern}; + /// The error returned by [parse()][crate::parse()]. #[derive(thiserror::Error, Debug)] #[allow(missing_docs)] diff --git a/git-pathspec/tests/pathspec.rs b/git-pathspec/tests/pathspec.rs index 784562e357..60fe6f5188 100644 --- a/git-pathspec/tests/pathspec.rs +++ b/git-pathspec/tests/pathspec.rs @@ -1,11 +1,12 @@ pub use git_testtools::Result; mod parse { + use std::collections::HashMap; + use bstr::{BStr, BString, ByteSlice}; use git_attributes::State; use git_pathspec::{MagicSignature, MatchMode, Pattern}; use once_cell::sync::Lazy; - use std::collections::HashMap; #[derive(Debug, Clone, PartialEq, Eq)] struct PatternForTesting { @@ -59,12 +60,13 @@ mod parse { } mod succeed { + use git_attributes::State; + use git_pathspec::{MagicSignature, MatchMode}; + use crate::parse::{ check_valid_inputs, pat, pat_with_attrs, pat_with_path, pat_with_path_and_sig, pat_with_search_mode, pat_with_sig, }; - use git_attributes::State; - use git_pathspec::{MagicSignature, MatchMode}; #[test] fn there_is_no_pathspec_pathspec() { @@ -256,9 +258,10 @@ mod parse { } mod fail { - use crate::parse::check_against_baseline; use git_pathspec::parse::Error; + use crate::parse::check_against_baseline; + #[test] fn empty_input() { let input = ""; diff --git a/git-ref/src/store/file/transaction/prepare.rs b/git-ref/src/store/file/transaction/prepare.rs index 31d42efe0d..d0b7b950b4 100644 --- a/git-ref/src/store/file/transaction/prepare.rs +++ b/git-ref/src/store/file/transaction/prepare.rs @@ -432,7 +432,6 @@ mod error { } } -use crate::packed::transaction::buffer_into_transaction; pub use error::Error; -use crate::transaction::PreviousValue; +use crate::{packed::transaction::buffer_into_transaction, transaction::PreviousValue}; diff --git a/git-repository/src/config/cache.rs b/git-repository/src/config/cache.rs index 502b198ec2..53a69ae7ee 100644 --- a/git-repository/src/config/cache.rs +++ b/git-repository/src/config/cache.rs @@ -3,8 +3,7 @@ use std::{convert::TryFrom, path::PathBuf}; use git_config::{Boolean, Integer}; use super::{Cache, Error}; -use crate::revision::spec::parse::ObjectKindHint; -use crate::{bstr::ByteSlice, repository, repository::identity}; +use crate::{bstr::ByteSlice, repository, repository::identity, revision::spec::parse::ObjectKindHint}; /// A utility to deal with the cyclic dependency between the ref store and the configuration. The ref-store needs the /// object hash kind, and the configuration needs the current branch name to resolve conditional includes with `onbranch`. diff --git a/git-repository/src/config/mod.rs b/git-repository/src/config/mod.rs index 1b60e8ee02..2dea9c5add 100644 --- a/git-repository/src/config/mod.rs +++ b/git-repository/src/config/mod.rs @@ -1,8 +1,7 @@ pub use git_config::*; use git_features::threading::OnceCell; -use crate::revision::spec; -use crate::{bstr::BString, permission, repository::identity, Repository}; +use crate::{bstr::BString, permission, repository::identity, revision::spec, Repository}; pub(crate) mod cache; mod snapshot; diff --git a/git-repository/src/head.rs b/git-repository/src/head.rs index 9c12af0f76..d96284af7e 100644 --- a/git-repository/src/head.rs +++ b/git-repository/src/head.rs @@ -83,11 +83,14 @@ impl<'repo> Head<'repo> { } /// pub mod log { - use crate::bstr::{BString, ByteSlice}; - use git_hash::ObjectId; use std::convert::TryInto; - use crate::Head; + use git_hash::ObjectId; + + use crate::{ + bstr::{BString, ByteSlice}, + Head, + }; impl<'repo> Head<'repo> { /// Return a platform for obtaining iterators on the reference log associated with the `HEAD` reference. diff --git a/git-repository/src/repository/location.rs b/git-repository/src/repository/location.rs index 7bf58d030e..8fca3d9eca 100644 --- a/git-repository/src/repository/location.rs +++ b/git-repository/src/repository/location.rs @@ -1,6 +1,7 @@ -use git_path::realpath::MAX_SYMLINKS; use std::path::PathBuf; +use git_path::realpath::MAX_SYMLINKS; + impl crate::Repository { /// Return the path to the repository itself, containing objects, references, configuration, and more. /// diff --git a/git-repository/src/repository/revision.rs b/git-repository/src/repository/revision.rs index 8c0d03a588..1da05e9728 100644 --- a/git-repository/src/repository/revision.rs +++ b/git-repository/src/repository/revision.rs @@ -1,5 +1,4 @@ -use crate::bstr::BStr; -use crate::revision; +use crate::{bstr::BStr, revision}; /// Methods for resolving revisions by spec or working with the commit graph. impl crate::Repository { diff --git a/git-repository/src/revision/spec/mod.rs b/git-repository/src/revision/spec/mod.rs index 5a86d65803..f2f80903d0 100644 --- a/git-repository/src/revision/spec/mod.rs +++ b/git-repository/src/revision/spec/mod.rs @@ -1,13 +1,13 @@ -use crate::ext::ReferenceExt; -use crate::{revision::Spec, Id, Reference}; +use crate::{ext::ReferenceExt, revision::Spec, Id, Reference}; /// pub mod parse; mod impls { - use crate::revision::Spec; use std::ops::{Deref, DerefMut}; + use crate::revision::Spec; + impl<'repo> Deref for Spec<'repo> { type Target = git_revision::Spec; diff --git a/git-repository/src/revision/spec/parse/delegate/mod.rs b/git-repository/src/revision/spec/parse/delegate/mod.rs index 12a61d4e2a..15d908aa71 100644 --- a/git-repository/src/revision/spec/parse/delegate/mod.rs +++ b/git-repository/src/revision/spec/parse/delegate/mod.rs @@ -1,11 +1,17 @@ -use super::{Delegate, Error, ObjectKindHint}; -use crate::ext::{ObjectIdExt, ReferenceExt}; -use crate::Repository; +use std::collections::HashSet; + use git_hash::ObjectId; -use git_revision::spec::parse; -use git_revision::spec::parse::delegate::{self}; +use git_revision::spec::{ + parse, + parse::delegate::{self}, +}; use smallvec::SmallVec; -use std::collections::HashSet; + +use super::{Delegate, Error, ObjectKindHint}; +use crate::{ + ext::{ObjectIdExt, ReferenceExt}, + Repository, +}; type Replacements = SmallVec<[(ObjectId, ObjectId); 1]>; diff --git a/git-repository/src/revision/spec/parse/delegate/navigate.rs b/git-repository/src/revision/spec/parse/delegate/navigate.rs index 075f751a8f..707b1d4f9a 100644 --- a/git-repository/src/revision/spec/parse/delegate/navigate.rs +++ b/git-repository/src/revision/spec/parse/delegate/navigate.rs @@ -1,14 +1,21 @@ -use crate::bstr::{BStr, ByteSlice}; -use crate::ext::ObjectIdExt; -use crate::object; -use crate::revision::spec::parse::delegate::{handle_errors_and_replacements, peel}; -use crate::revision::spec::parse::Delegate; -use crate::revision::spec::parse::{delegate::Replacements, Error}; +use std::collections::HashSet; + use git_hash::ObjectId; -use git_revision::spec::parse::delegate; -use git_revision::spec::parse::delegate::{PeelTo, Traversal}; +use git_revision::spec::parse::{ + delegate, + delegate::{PeelTo, Traversal}, +}; use git_traverse::commit::Sorting; -use std::collections::HashSet; + +use crate::{ + bstr::{BStr, ByteSlice}, + ext::ObjectIdExt, + object, + revision::spec::parse::{ + delegate::{handle_errors_and_replacements, peel, Replacements}, + Delegate, Error, + }, +}; impl<'repo> delegate::Navigate for Delegate<'repo> { fn traverse(&mut self, kind: Traversal) -> Option<()> { diff --git a/git-repository/src/revision/spec/parse/delegate/revision.rs b/git-repository/src/revision/spec/parse/delegate/revision.rs index 2cee2d4ec1..455258224c 100644 --- a/git-repository/src/revision/spec/parse/delegate/revision.rs +++ b/git-repository/src/revision/spec/parse/delegate/revision.rs @@ -1,12 +1,18 @@ -use crate::bstr::{BStr, BString, ByteSlice}; -use crate::ext::ReferenceExt; -use crate::object; -use crate::revision::spec::parse::{Delegate, Error, RefsHint}; -use git_hash::ObjectId; -use git_revision::spec::parse::delegate; -use git_revision::spec::parse::delegate::{ReflogLookup, SiblingBranch}; use std::collections::HashSet; +use git_hash::ObjectId; +use git_revision::spec::parse::{ + delegate, + delegate::{ReflogLookup, SiblingBranch}, +}; + +use crate::{ + bstr::{BStr, BString, ByteSlice}, + ext::ReferenceExt, + object, + revision::spec::parse::{Delegate, Error, RefsHint}, +}; + impl<'repo> delegate::Revision for Delegate<'repo> { fn find_ref(&mut self, name: &BStr) -> Option<()> { self.unset_disambiguate_call(); diff --git a/git-repository/src/revision/spec/parse/error.rs b/git-repository/src/revision/spec/parse/error.rs index d5d43a5473..d40ec7dc63 100644 --- a/git-repository/src/revision/spec/parse/error.rs +++ b/git-repository/src/revision/spec/parse/error.rs @@ -1,10 +1,10 @@ -use super::Error; -use crate::bstr::BString; -use crate::ext::ObjectIdExt; -use crate::{bstr, Repository}; -use git_hash::ObjectId; use std::collections::HashSet; +use git_hash::ObjectId; + +use super::Error; +use crate::{bstr, bstr::BString, ext::ObjectIdExt, Repository}; + /// Additional information about candidates that caused ambiguity. #[derive(Debug)] pub enum CandidateInfo { diff --git a/git-repository/src/revision/spec/parse/mod.rs b/git-repository/src/revision/spec/parse/mod.rs index 129c7af391..7740a60021 100644 --- a/git-repository/src/revision/spec/parse/mod.rs +++ b/git-repository/src/revision/spec/parse/mod.rs @@ -1,9 +1,9 @@ -use crate::bstr::BStr; -use crate::revision::Spec; -use crate::Repository; +use std::collections::HashSet; + use git_hash::ObjectId; use git_revision::spec::parse; -use std::collections::HashSet; + +use crate::{bstr::BStr, revision::Spec, Repository}; mod types; pub use types::{Error, ObjectKindHint, Options, RefsHint}; diff --git a/git-repository/src/revision/spec/parse/types.rs b/git-repository/src/revision/spec/parse/types.rs index 557fa0849a..0a1b6b2192 100644 --- a/git-repository/src/revision/spec/parse/types.rs +++ b/git-repository/src/revision/spec/parse/types.rs @@ -1,5 +1,4 @@ -use crate::bstr::BString; -use crate::{object, reference}; +use crate::{bstr::BString, object, reference}; /// A hint to know what to do if refs and object names are equal. #[derive(Debug, Copy, Clone, PartialEq, Eq)] diff --git a/git-repository/src/revision/walk.rs b/git-repository/src/revision/walk.rs index 14061d9337..24b91209d0 100644 --- a/git-repository/src/revision/walk.rs +++ b/git-repository/src/revision/walk.rs @@ -71,8 +71,7 @@ impl<'repo> Platform<'repo> { } pub(crate) mod iter { - use crate::ext::ObjectIdExt; - use crate::Id; + use crate::{ext::ObjectIdExt, Id}; /// The iterator returned by [`crate::revision::walk::Platform::all()`]. pub struct Walk<'repo> { diff --git a/git-repository/tests/revision/spec/from_bytes/ambiguous.rs b/git-repository/tests/revision/spec/from_bytes/ambiguous.rs index d9739ba509..c123676fe8 100644 --- a/git-repository/tests/revision/spec/from_bytes/ambiguous.rs +++ b/git-repository/tests/revision/spec/from_bytes/ambiguous.rs @@ -1,12 +1,17 @@ +use git_repository::{ + prelude::{ObjectIdExt, RevSpecExt}, + revision::{ + spec::parse::{Options, RefsHint}, + Spec, + }, +}; +use git_testtools::hex_to_id; + use super::repo; use crate::revision::spec::from_bytes::{ parse_spec, parse_spec_better_than_baseline, parse_spec_no_baseline, parse_spec_no_baseline_opts, parse_spec_opts, rev_parse, }; -use git_repository::prelude::{ObjectIdExt, RevSpecExt}; -use git_repository::revision::spec::parse::{Options, RefsHint}; -use git_repository::revision::Spec; -use git_testtools::hex_to_id; #[test] fn prefix() { diff --git a/git-repository/tests/revision/spec/from_bytes/mod.rs b/git-repository/tests/revision/spec/from_bytes/mod.rs index 3529d064bc..abfaeadc2f 100644 --- a/git-repository/tests/revision/spec/from_bytes/mod.rs +++ b/git-repository/tests/revision/spec/from_bytes/mod.rs @@ -1,5 +1,4 @@ -use git_repository::prelude::ObjectIdExt; -use git_repository::revision::Spec; +use git_repository::{prelude::ObjectIdExt, revision::Spec}; use git_testtools::hex_to_id; mod util; @@ -12,11 +11,11 @@ mod reflog; mod traverse; mod peel { - use crate::revision::spec::from_bytes::{parse_spec, repo}; - use git_repository::prelude::ObjectIdExt; - use git_repository::revision::Spec; + use git_repository::{prelude::ObjectIdExt, revision::Spec}; use git_testtools::hex_to_id; + use crate::revision::spec::from_bytes::{parse_spec, repo}; + #[test] fn peel_to_object() { let repo = &repo("complex_graph").unwrap(); @@ -32,9 +31,10 @@ mod peel { } mod sibling_branch { - use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo}; use git_repository::revision::spec::parse::Error; + use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo}; + #[test] fn is_planned_and_delayed_until_remotes_are_sorted() { let repo = repo("complex_graph").unwrap(); @@ -51,11 +51,11 @@ mod sibling_branch { } mod index { - use crate::revision::spec::from_bytes::{parse_spec, repo}; - use git_repository::prelude::ObjectIdExt; - use git_repository::revision::Spec; + use git_repository::{prelude::ObjectIdExt, revision::Spec}; use git_testtools::hex_to_id; + use crate::revision::spec::from_bytes::{parse_spec, repo}; + #[test] fn at_stage() { let repo = repo("complex_graph").unwrap(); diff --git a/git-repository/tests/revision/spec/from_bytes/reflog.rs b/git-repository/tests/revision/spec/from_bytes/reflog.rs index 39c8aa3a5b..a9aa27fd2d 100644 --- a/git-repository/tests/revision/spec/from_bytes/reflog.rs +++ b/git-repository/tests/revision/spec/from_bytes/reflog.rs @@ -1,9 +1,11 @@ -use crate::revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}; -use git_repository::prelude::ObjectIdExt; -use git_repository::revision::spec::parse::Error; -use git_repository::revision::Spec; +use git_repository::{ + prelude::ObjectIdExt, + revision::{spec::parse::Error, Spec}, +}; use git_testtools::hex_to_id; +use crate::revision::spec::from_bytes::{parse_spec, parse_spec_no_baseline, repo}; + #[test] fn nth_prior_checkout() { let repo = repo("complex_graph").unwrap(); diff --git a/git-repository/tests/revision/spec/from_bytes/regex.rs b/git-repository/tests/revision/spec/from_bytes/regex.rs index 25d232f767..6a823f23b5 100644 --- a/git-repository/tests/revision/spec/from_bytes/regex.rs +++ b/git-repository/tests/revision/spec/from_bytes/regex.rs @@ -1,11 +1,13 @@ -use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo}; use git_repository::prelude::ObjectIdExt; use git_testtools::hex_to_id; +use crate::revision::spec::from_bytes::{parse_spec_no_baseline, repo}; + mod with_known_revision { + use git_repository::revision::Spec; + use super::*; use crate::revision::spec::from_bytes::parse_spec; - use git_repository::revision::Spec; #[test] #[cfg(not(feature = "regex"))] @@ -53,9 +55,10 @@ mod with_known_revision { } mod find_youngest_matching_commit { + use git_repository::revision::Spec; + use super::*; use crate::revision::spec::from_bytes::parse_spec; - use git_repository::revision::Spec; #[test] #[cfg(not(feature = "regex"))] diff --git a/git-repository/tests/revision/spec/from_bytes/traverse.rs b/git-repository/tests/revision/spec/from_bytes/traverse.rs index 6fcb5f0679..6ae8b295c2 100644 --- a/git-repository/tests/revision/spec/from_bytes/traverse.rs +++ b/git-repository/tests/revision/spec/from_bytes/traverse.rs @@ -1,8 +1,8 @@ -use crate::revision::spec::from_bytes::{parse_spec, repo}; -use git_repository::prelude::ObjectIdExt; -use git_repository::revision::Spec; +use git_repository::{prelude::ObjectIdExt, revision::Spec}; use git_testtools::hex_to_id; +use crate::revision::spec::from_bytes::{parse_spec, repo}; + #[test] fn complex() -> crate::Result { let repo = &repo("complex_graph")?; diff --git a/git-repository/tests/revision/spec/from_bytes/util.rs b/git-repository/tests/revision/spec/from_bytes/util.rs index 741bd826ff..a72299c798 100644 --- a/git-repository/tests/revision/spec/from_bytes/util.rs +++ b/git-repository/tests/revision/spec/from_bytes/util.rs @@ -1,12 +1,10 @@ -use git_object::bstr; -use git_object::bstr::BStr; +use std::{collections::HashMap, path::PathBuf, str::FromStr}; + +use git_object::{bstr, bstr::BStr}; use git_ref::bstr::{BString, ByteSlice}; use git_repository as git; use git_revision::spec::Kind; use git_testtools::once_cell::sync::Lazy; -use std::collections::HashMap; -use std::path::PathBuf; -use std::str::FromStr; const FIXTURE_NAME: &str = "make_rev_spec_parse_repos.sh"; static BASELINE: Lazy>>> = Lazy::new(|| { diff --git a/git-revision/src/spec/mod.rs b/git-revision/src/spec/mod.rs index 53eca59827..ba24c75c03 100644 --- a/git-revision/src/spec/mod.rs +++ b/git-revision/src/spec/mod.rs @@ -40,9 +40,10 @@ impl Spec { } mod _impls { - use crate::Spec; use std::fmt::{Display, Formatter}; + use crate::Spec; + impl Display for Spec { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { diff --git a/git-revision/src/spec/parse/function.rs b/git-revision/src/spec/parse/function.rs index 8d99f504f6..df7aab1c9f 100644 --- a/git-revision/src/spec/parse/function.rs +++ b/git-revision/src/spec/parse/function.rs @@ -62,9 +62,10 @@ pub fn parse(mut input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error } mod intercept { - use crate::spec::parse::{delegate, Delegate}; use bstr::{BStr, BString}; + use crate::spec::parse::{delegate, Delegate}; + #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] pub(crate) enum PrefixHintOwned { MustBeCommit, diff --git a/git-revision/tests/spec/parse/kind.rs b/git-revision/tests/spec/parse/kind.rs index a594619aa0..bb3c30c3e2 100644 --- a/git-revision/tests/spec/parse/kind.rs +++ b/git-revision/tests/spec/parse/kind.rs @@ -29,8 +29,7 @@ fn delegate_can_refuse_spec_kinds() { mod include_parents { use git_revision::spec; - use crate::spec::parse::kind::prefix; - use crate::spec::parse::{parse, try_parse, Call}; + use crate::spec::parse::{kind::prefix, parse, try_parse, Call}; #[test] fn trailing_caret_at_symbol() { @@ -65,8 +64,7 @@ mod include_parents { mod exclude_parents { use git_revision::spec; - use crate::spec::parse::kind::prefix; - use crate::spec::parse::{parse, try_parse, Call}; + use crate::spec::parse::{kind::prefix, parse, try_parse, Call}; #[test] fn trailing_caret_exclamation_mark() { diff --git a/git-traverse/src/commit.rs b/git-traverse/src/commit.rs index f0860193c3..c2bce39cc2 100644 --- a/git-traverse/src/commit.rs +++ b/git-traverse/src/commit.rs @@ -46,8 +46,7 @@ impl Default for Sorting { /// pub mod ancestors { - use std::iter::FromIterator; - use std::{borrow::BorrowMut, collections::VecDeque}; + use std::{borrow::BorrowMut, collections::VecDeque, iter::FromIterator}; use git_hash::{oid, ObjectId}; use git_object::CommitRefIter; diff --git a/gitoxide-core/src/repository/revision/explain.rs b/gitoxide-core/src/repository/revision/explain.rs index 1d80ea5d99..c9d80f0ca0 100644 --- a/gitoxide-core/src/repository/revision/explain.rs +++ b/gitoxide-core/src/repository/revision/explain.rs @@ -1,9 +1,9 @@ use anyhow::bail; use git::{ bstr::{BStr, BString, ByteSlice}, - revision::{ - plumbing::spec, - plumbing::spec::parse::{ + revision::plumbing::{ + spec, + spec::parse::{ delegate, delegate::{PeelTo, ReflogLookup, SiblingBranch, Traversal}, Delegate, diff --git a/gitoxide-core/src/repository/revision/mod.rs b/gitoxide-core/src/repository/revision/mod.rs index 5ee8940c93..5f693bbc8c 100644 --- a/gitoxide-core/src/repository/revision/mod.rs +++ b/gitoxide-core/src/repository/revision/mod.rs @@ -5,10 +5,11 @@ pub mod parse; pub use parse::function::parse; mod previous_branches { - use crate::OutputFormat; use anyhow::Context; use git_repository as git; + use crate::OutputFormat; + pub fn function(repo: git::Repository, mut out: impl std::io::Write, format: OutputFormat) -> anyhow::Result<()> { let branches = repo .head()? diff --git a/gitoxide-core/src/repository/revision/parse.rs b/gitoxide-core/src/repository/revision/parse.rs index bd0d89e91f..3683f358ca 100644 --- a/gitoxide-core/src/repository/revision/parse.rs +++ b/gitoxide-core/src/repository/revision/parse.rs @@ -5,10 +5,12 @@ pub struct Options { } pub(crate) mod function { + use std::ffi::OsString; + + use git_repository as git; + use super::Options; use crate::OutputFormat; - use git_repository as git; - use std::ffi::OsString; pub fn parse( mut repo: git::Repository, diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index a6260a9dd0..ba0a85f88d 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -1,9 +1,9 @@ //! Utilities for testing `gitoxide` crates, many of which might be useful for testing programs that use `git` in general. #![deny(missing_docs)] -use std::ffi::OsString; use std::{ collections::BTreeMap, convert::Infallible, + ffi::OsString, io::Read, path::{Path, PathBuf}, time::Duration,