Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 5, 2022
1 parent 5c05198 commit 535e967
Show file tree
Hide file tree
Showing 110 changed files with 369 additions and 287 deletions.
3 changes: 2 additions & 1 deletion cargo-smart-release/src/changelog/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod repository_url {
use crate::changelog::write::RepositoryUrl;
use git_repository as git;

use crate::changelog::write::RepositoryUrl;

#[test]
fn github_https_url() {
for input in [
Expand Down
6 changes: 4 additions & 2 deletions git-command/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ pub struct Prepare {
}

mod prepare {
use crate::Prepare;
use git_testtools::bstr::ByteSlice;
use std::process::{Command, Stdio};

use git_testtools::bstr::ByteSlice;

use crate::Prepare;

/// Builder
impl Prepare {
/// If called, the command will not be executed directly, but with `sh`.
Expand Down
3 changes: 1 addition & 2 deletions git-config-value/src/boolean.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::ffi::OsString;
use std::{borrow::Cow, convert::TryFrom, fmt::Display};
use std::{borrow::Cow, convert::TryFrom, ffi::OsString, fmt::Display};

use bstr::{BStr, BString, ByteSlice};

Expand Down
6 changes: 4 additions & 2 deletions git-config-value/tests/value/boolean.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::b;
use git_config_value::Boolean;
use std::convert::TryFrom;

use git_config_value::Boolean;

use crate::b;

#[test]
fn from_str_false() -> crate::Result {
assert!(!Boolean::try_from(b("no"))?.0);
Expand Down
3 changes: 2 additions & 1 deletion git-config-value/tests/value/color.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod name {
use git_config_value::color::Name;
use std::str::FromStr;

use git_config_value::color::Name;

#[test]
fn non_bright() {
assert_eq!(Name::from_str("normal"), Ok(Name::Normal));
Expand Down
4 changes: 2 additions & 2 deletions git-config-value/tests/value/integer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::convert::TryFrom;

use git_config_value::{integer::Suffix, Integer};

use crate::b;
use git_config_value::integer::Suffix;
use git_config_value::Integer;

#[test]
fn from_str_no_suffix() {
Expand Down
3 changes: 2 additions & 1 deletion git-config-value/tests/value/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bstr::{BStr, ByteSlice};
use std::borrow::Cow;

use bstr::{BStr, ByteSlice};

type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;
fn b(s: &str) -> &bstr::BStr {
s.into()
Expand Down
3 changes: 2 additions & 1 deletion git-config-value/tests/value/path.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
mod interpolate {
use git_config_value::path;
use std::{
borrow::Cow,
path::{Path, PathBuf},
};

use git_config_value::path;

use crate::{b, cow_str};

#[test]
Expand Down
3 changes: 1 addition & 2 deletions git-config/src/file/access/comfort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::{borrow::Cow, convert::TryFrom};

use bstr::BStr;

use crate::parse::section;
use crate::{file::MetadataFilter, lookup, value, File};
use crate::{file::MetadataFilter, lookup, parse::section, value, File};

/// Comfortable API for accessing values
impl<'event> File<'event> {
Expand Down
3 changes: 1 addition & 2 deletions git-config/src/file/access/raw.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::convert::TryInto;
use std::{borrow::Cow, collections::HashMap};
use std::{borrow::Cow, collections::HashMap, convert::TryInto};

use bstr::BStr;
use smallvec::ToSmallVec;
Expand Down
4 changes: 1 addition & 3 deletions git-credentials/src/helper/cascade.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::helper::Cascade;
use crate::protocol::Context;
use crate::{helper, protocol, Program};
use crate::{helper, helper::Cascade, protocol, protocol::Context, Program};

impl Default for Cascade {
fn default() -> Self {
Expand Down
4 changes: 2 additions & 2 deletions git-credentials/src/helper/invoke.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::helper::{Action, NextAction};
use crate::helper::{Context, Error, Outcome, Result};
use std::io::Read;

use crate::helper::{Action, Context, Error, NextAction, Outcome, Result};

impl Action {
/// Send ourselves to the given `write` which is expected to be credentials-helper compatible
pub fn send(&self, mut write: impl std::io::Write) -> std::io::Result<()> {
Expand Down
7 changes: 4 additions & 3 deletions git-credentials/src/helper/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::protocol::Context;
use crate::{protocol, Program};
use bstr::{BStr, BString};
use std::convert::TryFrom;

use bstr::{BStr, BString};

use crate::{protocol, protocol::Context, Program};

/// A list of helper programs to run in order to obtain credentials.
#[allow(dead_code)]
#[derive(Debug)]
Expand Down
14 changes: 8 additions & 6 deletions git-credentials/src/program/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{convert::TryFrom, ffi::OsString};

use bstr::BString;
use std::convert::TryFrom;
use std::ffi::OsString;

/// The action passed to the credential helper implementation in [`main()`][crate::program::main()].
#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -60,10 +60,12 @@ pub enum Error {
}

pub(crate) mod function {
use crate::program::main::{Action, Error};
use crate::protocol::Context;
use std::convert::TryInto;
use std::ffi::OsString;
use std::{convert::TryInto, ffi::OsString};

use crate::{
program::main::{Action, Error},
protocol::Context,
};

/// Invoke a custom credentials helper which receives program `args`, with the first argument being the
/// action to perform (as opposed to the program name).
Expand Down
6 changes: 4 additions & 2 deletions git-credentials/src/program/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{helper, Program};
use bstr::{BString, ByteSlice, ByteVec};
use std::process::{Command, Stdio};

use bstr::{BString, ByteSlice, ByteVec};

use crate::{helper, Program};

/// The kind of helper program to use.
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Kind {
Expand Down
7 changes: 4 additions & 3 deletions git-credentials/src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ pub enum Error {
}

mod access {
use crate::protocol::Context;
use bstr::BString;

use crate::protocol::Context;

impl Context {
/// Convert all relevant fields into a URL for consumption.
pub fn to_url(&self) -> Option<BString> {
Expand Down Expand Up @@ -44,10 +45,10 @@ mod access {
}

mod mutate {
use crate::protocol;
use crate::protocol::Context;
use bstr::ByteSlice;

use crate::{protocol, protocol::Context};

/// In-place mutation
impl Context {
/// Destructure the url at our `url` field into parts like protocol, host, username and path and store
Expand Down
15 changes: 8 additions & 7 deletions git-credentials/src/protocol/context/serde.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::protocol::context::Error;
use bstr::BStr;

use crate::protocol::context::Error;

mod write {
use crate::protocol::context::serde::validate;
use crate::protocol::Context;
use bstr::{BStr, BString};

use crate::protocol::{context::serde::validate, Context};

impl Context {
/// Write ourselves to `out` such that [`from_bytes()`][Self::from_bytes()] can decode it losslessly.
pub fn write_to(&self, mut out: impl std::io::Write) -> std::io::Result<()> {
Expand Down Expand Up @@ -49,12 +50,12 @@ mod write {

///
pub mod decode {
use crate::protocol::context;
use crate::protocol::context::serde::validate;
use crate::protocol::Context;
use bstr::{BString, ByteSlice};
use std::convert::TryFrom;

use bstr::{BString, ByteSlice};

use crate::protocol::{context, context::serde::validate, Context};

/// The error returned by [`from_bytes()`][Context::from_bytes()].
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
Expand Down
3 changes: 2 additions & 1 deletion git-credentials/src/protocol/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::helper;
use bstr::BString;

use crate::helper;

/// The outcome of the credentials top-level functions to obtain a complete identity.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Outcome {
Expand Down
13 changes: 8 additions & 5 deletions git-credentials/tests/helper/cascade.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
mod invoke {
use std::convert::TryInto;

use bstr::{ByteSlice, ByteVec};
use git_credentials::helper::Action;
use git_credentials::helper::Cascade;
use git_credentials::protocol::Context;
use git_credentials::{program, protocol, Program};
use git_credentials::{
helper::{Action, Cascade},
program, protocol,
protocol::Context,
Program,
};
use git_sec::identity::Account;
use git_testtools::fixture_path;
use std::convert::TryInto;

#[test]
fn credentials_are_filled_in_one_by_one_and_stop_when_complete() {
Expand Down
6 changes: 3 additions & 3 deletions git-credentials/tests/helper/invoke.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bstr::{BString, ByteVec};
use git_credentials::protocol::Context;
use git_credentials::{helper, Program};
use git_credentials::{helper, protocol::Context, Program};
use git_testtools::fixture_path;

#[test]
Expand Down Expand Up @@ -45,9 +44,10 @@ fn store_and_reject() {
}

mod program {
use crate::helper::invoke::script_helper;
use git_credentials::{helper, program::Kind, Program};

use crate::helper::invoke::script_helper;

#[test]
fn builtin() {
assert!(
Expand Down
3 changes: 1 addition & 2 deletions git-credentials/tests/helper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ mod context;
mod invoke;

mod invoke_outcome_to_helper_result {
use git_credentials::protocol::helper_outcome_to_result;
use git_credentials::{helper, protocol};
use git_credentials::{helper, protocol, protocol::helper_outcome_to_result};

#[test]
fn missing_username_or_password_causes_failure_with_get_action() {
Expand Down
3 changes: 1 addition & 2 deletions git-credentials/tests/program/from_custom_definition.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use git_credentials::program::Kind;
use git_credentials::Program;
use git_credentials::{program::Kind, Program};

#[test]
fn script() {
Expand Down
26 changes: 15 additions & 11 deletions git-date/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ pub enum Error {
}

pub(crate) mod function {
use crate::parse::{relative, Error};
use crate::time::format::{DEFAULT, ISO8601, ISO8601_STRICT, RFC2822, SHORT};
use crate::time::Sign;
use crate::Time;
use std::convert::TryInto;
use std::str::FromStr;
use std::time::SystemTime;
use std::{convert::TryInto, str::FromStr, time::SystemTime};

use time::{Date, OffsetDateTime};

use crate::{
parse::{relative, Error},
time::{
format::{DEFAULT, ISO8601, ISO8601_STRICT, RFC2822, SHORT},
Sign,
},
Time,
};

#[allow(missing_docs)]
pub fn parse(input: &str, now: Option<SystemTime>) -> Result<Time, Error> {
// TODO: actual implementation, this is just to not constantly fail
Expand Down Expand Up @@ -82,12 +86,12 @@ pub(crate) mod function {
}

mod relative {
use crate::parse::Error;
use std::convert::TryInto;
use std::str::FromStr;
use std::time::SystemTime;
use std::{convert::TryInto, str::FromStr, time::SystemTime};

use time::{Duration, OffsetDateTime};

use crate::parse::Error;

fn parse_inner(input: &str) -> Option<Duration> {
let mut split = input.split_whitespace();
let multiplier = i64::from_str(split.next()?).ok()?;
Expand Down
10 changes: 5 additions & 5 deletions git-date/src/time/format.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::time::Format;
use crate::Time;
use time::format_description::FormatItem;
use time::macros::format_description;
use time::{format_description::FormatItem, macros::format_description};

use crate::{time::Format, Time};

/// E.g. `2018-12-24`
pub const SHORT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day]");
Expand Down Expand Up @@ -31,9 +30,10 @@ pub const DEFAULT: &[FormatItem<'_>] = format_description!(
);

mod format_impls {
use crate::time::Format;
use time::format_description::FormatItem;

use crate::time::Format;

impl<'a> From<&'a [FormatItem<'a>]> for Format<'a> {
fn from(f: &'a [FormatItem<'a>]) -> Self {
Format::Custom(f)
Expand Down
7 changes: 3 additions & 4 deletions git-date/src/time/init.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::time::Sign;
use crate::Time;
use std::convert::TryInto;
use std::ops::Sub;
use std::{convert::TryInto, ops::Sub};

use crate::{time::Sign, Time};

/// Instantiation
impl Time {
Expand Down
3 changes: 1 addition & 2 deletions git-date/src/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ mod sign {
}

mod impls {
use crate::time::Sign;
use crate::Time;
use crate::{time::Sign, Time};

impl Default for Time {
fn default() -> Self {
Expand Down
4 changes: 2 additions & 2 deletions git-date/src/time/write.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::time::Sign;
use crate::Time;
use bstr::BString;

use crate::{time::Sign, Time};

/// Serialization with standard `git` format
impl Time {
/// Serialize this instance into memory, similar to what [`write_to()`][Self::write_to()] would do with arbitrary `Write` implementations.
Expand Down
Loading

0 comments on commit 535e967

Please sign in to comment.