History

make fmt

Sebastian Thiel committed 4 years ago

Commit aa9fdb01 parent 20e188f23 files · +88 −66Browse files

Unified · Split

23 files
  1. git-config/src/file/access/mutate.rs +1 −2
  2. git-config/src/file/access/raw.rs +1 −2
  3. git-config/src/file/access/write.rs +2 −1
  4. git-config/src/file/impls.rs +1 −2
  5. git-config/src/file/init/from_env.rs +6 −2
  6. git-config/src/file/init/resolve_includes.rs +7 −3
  7. git-config/src/file/mutable/mod.rs +4 −4
  8. git-config/src/file/mutable/section.rs +4 −2
  9. git-config/src/file/mutable/value.rs +8 −3
  10. git-config/src/fs.rs +4 −2
  11. git-config/src/parse/section/header.rs +7 −4
  12. git-config/src/parse/tests.rs +3 −3
  13. git-config/tests/file/access/mutate.rs +3 −4
  14. git-config/tests/file/init/from_env.rs +4 −3
  15. git-config/tests/file/init/from_paths/includes/conditional/gitdir/util.rs +4 −2
  16. git-config/tests/file/init/from_paths/includes/conditional/mod.rs +2 −4
  17. git-config/tests/file/init/from_paths/includes/unconditional.rs +2 −4
  18. git-config/tests/file/mutable/multi_value.rs +2 −4
  19. git-config/tests/file/mutable/section.rs +8 −4
  20. git-config/tests/file/mutable/value.rs +2 −1
  21. git-config/tests/parse/from_bytes.rs +2 −1
  22. git-config/tests/parse/mod.rs +1 −2
  23. git-config/tests/parse/section.rs +10 −7
git-config/src/file/access/mutate.rs+1−2
@@ -1,8 +1,7 @@
11 use std::borrow::Cow;
22
3−use crate::file::rename_section;
43 use crate::{
5− file::{MutableSection, SectionBody},
4+ file::{rename_section, MutableSection, SectionBody},
65 lookup,
76 parse::section,
87 File,
git-config/src/file/access/raw.rs+1−2
@@ -2,9 +2,8 @@ use std::{borrow::Cow, collections::HashMap}; · 1 unmodified line
22
33 use bstr::BStr;
44
5−use crate::file::mutable::value::EntryData;
65 use crate::{
7− file::{Index, MutableMultiValue, MutableSection, MutableValue, Size},
6+ file::{mutable::value::EntryData, Index, MutableMultiValue, MutableSection, MutableValue, Size},
87 lookup,
98 parse::{section, Event},
109 File,
git-config/src/file/access/write.rs+2−1
@@ -1,6 +1,7 @@
1−use crate::File;
21 use bstr::BString;
32
3+use crate::File;
4+
45 impl File<'_> {
56 /// Serialize this type into a `BString` for convenience.
67 ///
git-config/src/file/impls.rs+1−2
@@ -1,5 +1,4 @@
1−use std::str::FromStr;
2−use std::{convert::TryFrom, fmt::Display};
1+use std::{convert::TryFrom, fmt::Display, str::FromStr};
32
43 use bstr::{BStr, BString};
54
git-config/src/file/init/from_env.rs+6−2
@@ -2,8 +2,12 @@ use std::{borrow::Cow, path::PathBuf}; · 1 unmodified line
22
33 use bstr::BString;
44
5−use crate::file::from_paths;
6−use crate::{file::init::resolve_includes, parse::section, path::interpolate, File};
5+use crate::{
6+ file::{from_paths, init::resolve_includes},
7+ parse::section,
8+ path::interpolate,
9+ File,
10+};
711
812 /// Represents the errors that may occur when calling [`File::from_env`][crate::File::from_env()].
913 #[derive(Debug, thiserror::Error)]
git-config/src/file/init/resolve_includes.rs+7−3
@@ -6,9 +6,13 @@ use std::{ · 5 unmodified lines
66 use bstr::{BStr, BString, ByteSlice, ByteVec};
77 use git_ref::Category;
88
9−use crate::file::init::from_paths;
10−use crate::file::init::from_paths::Options;
11−use crate::{file::SectionBodyId, File};
9+use crate::{
10+ file::{
11+ init::{from_paths, from_paths::Options},
12+ SectionBodyId,
13+ },
14+ File,
15+};
1216
1317 pub(crate) fn resolve_includes(
1418 conf: &mut File<'static>,
git-config/src/file/mutable/mod.rs+4−4
@@ -1,9 +1,9 @@
1−use crate::file::SectionBody;
2−use crate::parse::Event;
3−use bstr::{BStr, BString};
4−use bstr::{ByteSlice, ByteVec};
51 use std::borrow::Cow;
62
3+use bstr::{BStr, BString, ByteSlice, ByteVec};
4+
5+use crate::{file::SectionBody, parse::Event};
6+
77 fn escape_value(value: &BStr) -> BString {
88 let starts_with_whitespace = value.get(0).map_or(false, |b| b.is_ascii_whitespace());
99 let ends_with_whitespace = value
git-config/src/file/mutable/section.rs+4−2
@@ -6,9 +6,11 @@ use std::{ · 5 unmodified lines
66
77 use bstr::{BStr, BString, ByteVec};
88
9−use crate::file::mutable::{escape_value, Whitespace};
109 use crate::{
11− file::{Index, Size},
10+ file::{
11+ mutable::{escape_value, Whitespace},
12+ Index, Size,
13+ },
1214 lookup, parse,
1315 parse::{section::Key, Event},
1416 value::{normalize, normalize_bstr, normalize_bstring},
git-config/src/file/mutable/value.rs+8−3
@@ -2,10 +2,15 @@ use std::{borrow::Cow, collections::HashMap, ops::DerefMut}; · 1 unmodified line
22
33 use bstr::{BStr, BString, ByteVec};
44
5−use crate::file::mutable::section::{MutableSection, SectionBody};
6−use crate::file::mutable::{escape_value, Whitespace};
75 use crate::{
8− file::{Index, SectionBodyId, Size},
6+ file::{
7+ mutable::{
8+ escape_value,
9+ section::{MutableSection, SectionBody},
10+ Whitespace,
11+ },
12+ Index, SectionBodyId, Size,
13+ },
914 lookup,
1015 parse::{section, Event},
1116 value::{normalize_bstr, normalize_bstring},
git-config/src/fs.rs+4−2
@@ -10,8 +10,10 @@ use std::{ · 9 unmodified lines
1010
1111 use bstr::BStr;
1212
13−use crate::file::{from_env, from_paths};
14−use crate::{lookup, File};
13+use crate::{
14+ file::{from_env, from_paths},
15+ lookup, File,
16+};
1517
1618 // TODO: how does this relate to `File::from_env_paths()`?
1719 #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
git-config/src/parse/section/header.rs+7−4
@@ -1,8 +1,11 @@
1−use crate::parse::section::{into_cow_bstr, Header, Name};
2−use crate::parse::Event;
1+use std::{borrow::Cow, fmt::Display};
2+
33 use bstr::{BStr, BString, ByteSlice, ByteVec};
4−use std::borrow::Cow;
5−use std::fmt::Display;
4+
5+use crate::parse::{
6+ section::{into_cow_bstr, Header, Name},
7+ Event,
8+};
69
710 /// The error returned by [`Header::new(…)`][super::Header::new()].
811 #[derive(Debug, PartialOrd, PartialEq, thiserror::Error)]
git-config/src/parse/tests.rs+3−3
@@ -2,9 +2,10 @@ mod section { · 1 unmodified line
22
33 mod header {
44 mod write_to {
5− use crate::parse::section;
65 use std::borrow::Cow;
76
7+ use crate::parse::section;
8+
89 fn header(name: &str, subsection: impl Into<Option<(&'static str, &'static str)>>) -> section::Header<'_> {
910 let name = section::Name(Cow::Borrowed(name.into()));
1011 if let Some((separator, subsection_name)) = subsection.into() {
@@ -51,8 +52,7 @@ pub(crate) mod util { · 40 unmodified lines
5152 //! This module is only included for tests, and contains common unit test helper
5253 //! functions.
5354
54− use std::borrow::Cow;
55− use std::convert::TryFrom;
55+ use std::{borrow::Cow, convert::TryFrom};
5656
5757 use crate::parse::{section, Comment, Event};
5858
git-config/tests/file/access/mutate.rs+3−4
@@ -1,8 +1,7 @@
11 mod rename_section {
2− use git_config::file::rename_section;
3− use git_config::parse::section;
4− use std::borrow::Cow;
5− use std::convert::TryFrom;
2+ use std::{borrow::Cow, convert::TryFrom};
3+
4+ use git_config::{file::rename_section, parse::section};
65
76 #[test]
87 fn section_renaming_validates_new_name() {
git-config/tests/file/init/from_env.rs+4−3
@@ -1,8 +1,9 @@
11 use std::{borrow::Cow, env, fs};
22
3−use git_config::file::from_paths::Options;
4−use git_config::file::{from_env, from_paths};
5−use git_config::File;
3+use git_config::{
4+ file::{from_env, from_paths, from_paths::Options},
5+ File,
6+};
67 use serial_test::serial;
78 use tempfile::tempdir;
89
git-config/tests/file/init/from_paths/includes/conditional/gitdir/util.rs+4−2
@@ -8,8 +8,10 @@ use std::{ · 7 unmodified lines
88
99 use bstr::{BString, ByteSlice};
1010
11−use crate::file::cow_str;
12−use crate::file::init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir};
11+use crate::file::{
12+ cow_str,
13+ init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir},
14+};
1315
1416 #[derive(Debug)]
1517 pub struct GitEnv {
git-config/tests/file/init/from_paths/includes/conditional/mod.rs+2−4
@@ -1,11 +1,9 @@
11 use std::{fs, path::Path};
22
3−use git_config::file::from_paths;
4−use git_config::{path, File};
3+use git_config::{file::from_paths, path, File};
54 use tempfile::tempdir;
65
7−use crate::file::cow_str;
8−use crate::file::init::from_paths::escape_backslashes;
6+use crate::file::{cow_str, init::from_paths::escape_backslashes};
97
108 mod gitdir;
119 mod onbranch;
git-config/tests/file/init/from_paths/includes/unconditional.rs+2−4
@@ -1,11 +1,9 @@
11 use std::fs;
22
3−use git_config::file::from_paths;
4−use git_config::File;
3+use git_config::{file::from_paths, File};
54 use tempfile::tempdir;
65
7−use crate::file::cow_str;
8−use crate::file::init::from_paths::escape_backslashes;
6+use crate::file::{cow_str, init::from_paths::escape_backslashes};
97
108 #[test]
119 fn multiple() -> crate::Result {
git-config/tests/file/mutable/multi_value.rs+2−4
@@ -1,6 +1,5 @@
11 mod get {
2− use crate::file::cow_str;
3− use crate::file::mutable::multi_value::init_config;
2+ use crate::file::{cow_str, mutable::multi_value::init_config};
43
54 #[test]
65 fn single_lines() -> crate::Result {
@@ -50,8 +49,7 @@ mod access { · 43 unmodified lines
5049 }
5150
5251 mod set {
53− use crate::file::cow_str;
54− use crate::file::mutable::multi_value::init_config;
52+ use crate::file::{cow_str, mutable::multi_value::init_config};
5553
5654 #[test]
5755 fn values_are_escaped() -> crate::Result {
git-config/tests/file/mutable/section.rs+8−4
@@ -1,8 +1,10 @@
11 mod push {
2− use crate::file::cow_str;
3− use git_config::parse::section::Key;
42 use std::convert::TryFrom;
53
4+ use git_config::parse::section::Key;
5+
6+ use crate::file::cow_str;
7+
68 #[test]
79 fn whitespace_is_derived_from_whitespace_before_first_value() -> crate::Result {
810 for (input, expected_pre_key, expected_sep) in [
@@ -58,10 +60,12 @@ mod push { · 49 unmodified lines
5860 }
5961
6062 mod set_leading_whitespace {
61− use crate::file::cow_str;
62− use git_config::parse::section::Key;
6363 use std::convert::TryFrom;
6464
65+ use git_config::parse::section::Key;
66+
67+ use crate::file::cow_str;
68+
6569 #[test]
6670 fn any_whitespace_is_ok() -> crate::Result {
6771 let mut config = git_config::File::default();
git-config/tests/file/mutable/value.rs+2−1
@@ -1,7 +1,8 @@
11 mod get {
2− use crate::file::mutable::value::init_config;
32 use bstr::BString;
43
4+ use crate::file::mutable::value::init_config;
5+
56 fn config_get(input: &str) -> BString {
67 let mut file: git_config::File = input.parse().unwrap();
78 file.raw_value_mut("a", None, "k").unwrap().get().unwrap().into_owned()
git-config/tests/parse/from_bytes.rs+2−1
@@ -1,6 +1,7 @@
1−use super::*;
21 use git_config::parse::Events;
32
3+use super::*;
4+
45 #[test]
56 #[rustfmt::skip]
67 fn complex() {
git-config/tests/parse/mod.rs+1−2
@@ -1,5 +1,4 @@
1−use std::borrow::Cow;
2−use std::convert::TryFrom;
1+use std::{borrow::Cow, convert::TryFrom};
32
43 use git_config::parse::{Event, Events, Section};
54
git-config/tests/parse/section.rs+10−7
@@ -1,16 +1,17 @@
1−use git_config::parse::section;
2−use git_config::parse::Event;
31 use std::borrow::Cow;
42
3+use git_config::parse::{section, Event};
4+
55 pub fn header_event(name: &'static str, subsection: impl Into<Option<&'static str>>) -> Event<'static> {
66 Event::SectionHeader(section::Header::new(name, subsection.into().map(Cow::Borrowed)).unwrap())
77 }
88
99 mod header {
1010 mod write_to {
11− use git_config::parse::section;
1211 use std::borrow::Cow;
1312
13+ use git_config::parse::section;
14+
1415 #[test]
1516 fn subsection_backslashes_and_quotes_are_escaped() -> crate::Result {
1617 assert_eq!(
@@ -34,9 +35,10 @@ mod header { · 17 unmodified lines
3435 }
3536 }
3637 mod new {
37− use git_config::parse::section;
3838 use std::borrow::Cow;
3939
40+ use git_config::parse::section;
41+
4042 #[test]
4143 fn names_must_be_mostly_ascii() {
4244 for name in ["🤗", "x.y", "x y", "x\ny"] {
@@ -61,9 +63,10 @@ mod header { · 18 unmodified lines
6163 }
6264 }
6365 mod name {
64− use git_config::parse::section::Name;
6566 use std::convert::TryFrom;
6667
68+ use git_config::parse::section::Name;
69+
6770 #[test]
6871 fn alphanum_and_dash_are_valid() {
6972 assert!(Name::try_from("1a").is_ok());
@@ -80,9 +83,9 @@ mod name { · 10 unmodified lines
8083 }
8184
8285 mod key {
86+ use std::{cmp::Ordering, convert::TryFrom};
87+
8388 use git_config::parse::section::Key;
84− use std::cmp::Ordering;
85− use std::convert::TryFrom;
8689
8790 fn key(k: &str) -> Key<'_> {
8891 Key::try_from(k).unwrap()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t