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 @@
1use std::borrow::Cow;1use std::borrow::Cow;
2 2
3use crate::file::rename_section;
4use crate::{3use crate::{
5 file::{MutableSection, SectionBody},4 file::{rename_section, MutableSection, SectionBody},
6 lookup,5 lookup,
7 parse::section,6 parse::section,
8 File,7 File,
git-config/src/file/access/raw.rs+1−2
@@ -2,9 +2,8 @@ use std::{borrow::Cow, collections::HashMap}; · 1 unmodified line
2 2
3use bstr::BStr;3use bstr::BStr;
4 4
5use crate::file::mutable::value::EntryData;
6use crate::{5use crate::{
7 file::{Index, MutableMultiValue, MutableSection, MutableValue, Size},6 file::{mutable::value::EntryData, Index, MutableMultiValue, MutableSection, MutableValue, Size},
8 lookup,7 lookup,
9 parse::{section, Event},8 parse::{section, Event},
10 File,9 File,
git-config/src/file/access/write.rs+2−1
@@ -1,6 +1,7 @@
1use crate::File;
2use bstr::BString;1use bstr::BString;
3 2
3use crate::File;
4
4impl File<'_> {5impl File<'_> {
5 /// Serialize this type into a `BString` for convenience.6 /// Serialize this type into a `BString` for convenience.
6 ///7 ///
git-config/src/file/impls.rs+1−2
@@ -1,5 +1,4 @@
1use std::str::FromStr;1use std::{convert::TryFrom, fmt::Display, str::FromStr};
2use std::{convert::TryFrom, fmt::Display};
3 2
4use bstr::{BStr, BString};3use bstr::{BStr, BString};
5 4
git-config/src/file/init/from_env.rs+6−2
@@ -2,8 +2,12 @@ use std::{borrow::Cow, path::PathBuf}; · 1 unmodified line
2 2
3use bstr::BString;3use bstr::BString;
4 4
5use crate::file::from_paths;5use crate::{
6use crate::{file::init::resolve_includes, parse::section, path::interpolate, File};6 file::{from_paths, init::resolve_includes},
7 parse::section,
8 path::interpolate,
9 File,
10};
7 11
8/// Represents the errors that may occur when calling [`File::from_env`][crate::File::from_env()].12/// Represents the errors that may occur when calling [`File::from_env`][crate::File::from_env()].
9#[derive(Debug, thiserror::Error)]13#[derive(Debug, thiserror::Error)]
git-config/src/file/init/resolve_includes.rs+7−3
@@ -6,9 +6,13 @@ use std::{ · 5 unmodified lines
6use bstr::{BStr, BString, ByteSlice, ByteVec};6use bstr::{BStr, BString, ByteSlice, ByteVec};
7use git_ref::Category;7use git_ref::Category;
8 8
9use crate::file::init::from_paths;9use crate::{
10use crate::file::init::from_paths::Options;10 file::{
11use crate::{file::SectionBodyId, File};11 init::{from_paths, from_paths::Options},
12 SectionBodyId,
13 },
14 File,
15};
12 16
13pub(crate) fn resolve_includes(17pub(crate) fn resolve_includes(
14 conf: &mut File<'static>,18 conf: &mut File<'static>,
git-config/src/file/mutable/mod.rs+4−4
@@ -1,9 +1,9 @@
1use crate::file::SectionBody;
2use crate::parse::Event;
3use bstr::{BStr, BString};
4use bstr::{ByteSlice, ByteVec};
5use std::borrow::Cow;1use std::borrow::Cow;
6 2
3use bstr::{BStr, BString, ByteSlice, ByteVec};
4
5use crate::{file::SectionBody, parse::Event};
6
7fn escape_value(value: &BStr) -> BString {7fn escape_value(value: &BStr) -> BString {
8 let starts_with_whitespace = value.get(0).map_or(false, |b| b.is_ascii_whitespace());8 let starts_with_whitespace = value.get(0).map_or(false, |b| b.is_ascii_whitespace());
9 let ends_with_whitespace = value9 let ends_with_whitespace = value
git-config/src/file/mutable/section.rs+4−2
@@ -6,9 +6,11 @@ use std::{ · 5 unmodified lines
6 6
7use bstr::{BStr, BString, ByteVec};7use bstr::{BStr, BString, ByteVec};
8 8
9use crate::file::mutable::{escape_value, Whitespace};
10use crate::{9use crate::{
11 file::{Index, Size},10 file::{
11 mutable::{escape_value, Whitespace},
12 Index, Size,
13 },
12 lookup, parse,14 lookup, parse,
13 parse::{section::Key, Event},15 parse::{section::Key, Event},
14 value::{normalize, normalize_bstr, normalize_bstring},16 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
2 2
3use bstr::{BStr, BString, ByteVec};3use bstr::{BStr, BString, ByteVec};
4 4
5use crate::file::mutable::section::{MutableSection, SectionBody};
6use crate::file::mutable::{escape_value, Whitespace};
7use crate::{5use 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 },
9 lookup,14 lookup,
10 parse::{section, Event},15 parse::{section, Event},
11 value::{normalize_bstr, normalize_bstring},16 value::{normalize_bstr, normalize_bstring},
git-config/src/fs.rs+4−2
@@ -10,8 +10,10 @@ use std::{ · 9 unmodified lines
10 10
11use bstr::BStr;11use bstr::BStr;
12 12
13use crate::file::{from_env, from_paths};13use crate::{
14use crate::{lookup, File};14 file::{from_env, from_paths},
15 lookup, File,
16};
15 17
16// TODO: how does this relate to `File::from_env_paths()`?18// TODO: how does this relate to `File::from_env_paths()`?
17#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]19#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
git-config/src/parse/section/header.rs+7−4
@@ -1,8 +1,11 @@
1use crate::parse::section::{into_cow_bstr, Header, Name};1use std::{borrow::Cow, fmt::Display};
2use crate::parse::Event;2
3use bstr::{BStr, BString, ByteSlice, ByteVec};3use bstr::{BStr, BString, ByteSlice, ByteVec};
4use std::borrow::Cow;4
5use std::fmt::Display;5use crate::parse::{
6 section::{into_cow_bstr, Header, Name},
7 Event,
8};
6 9
7/// The error returned by [`Header::new(…)`][super::Header::new()].10/// The error returned by [`Header::new(…)`][super::Header::new()].
8#[derive(Debug, PartialOrd, PartialEq, thiserror::Error)]11#[derive(Debug, PartialOrd, PartialEq, thiserror::Error)]
git-config/src/parse/tests.rs+3−3
@@ -2,9 +2,10 @@ mod section { · 1 unmodified line
2 2
3 mod header {3 mod header {
4 mod write_to {4 mod write_to {
5 use crate::parse::section;
6 use std::borrow::Cow;5 use std::borrow::Cow;
7 6
7 use crate::parse::section;
8
8 fn header(name: &str, subsection: impl Into<Option<(&'static str, &'static str)>>) -> section::Header<'_> {9 fn header(name: &str, subsection: impl Into<Option<(&'static str, &'static str)>>) -> section::Header<'_> {
9 let name = section::Name(Cow::Borrowed(name.into()));10 let name = section::Name(Cow::Borrowed(name.into()));
10 if let Some((separator, subsection_name)) = subsection.into() {11 if let Some((separator, subsection_name)) = subsection.into() {
@@ -51,8 +52,7 @@ pub(crate) mod util { · 40 unmodified lines
51 //! This module is only included for tests, and contains common unit test helper52 //! This module is only included for tests, and contains common unit test helper
52 //! functions.53 //! functions.
53 54
54 use std::borrow::Cow;55 use std::{borrow::Cow, convert::TryFrom};
55 use std::convert::TryFrom;
56 56
57 use crate::parse::{section, Comment, Event};57 use crate::parse::{section, Comment, Event};
58 58
git-config/tests/file/access/mutate.rs+3−4
@@ -1,8 +1,7 @@
1mod rename_section {1mod rename_section {
2 use git_config::file::rename_section;2 use std::{borrow::Cow, convert::TryFrom};
3 use git_config::parse::section;3
4 use std::borrow::Cow;4 use git_config::{file::rename_section, parse::section};
5 use std::convert::TryFrom;
6 5
7 #[test]6 #[test]
8 fn section_renaming_validates_new_name() {7 fn section_renaming_validates_new_name() {
git-config/tests/file/init/from_env.rs+4−3
@@ -1,8 +1,9 @@
1use std::{borrow::Cow, env, fs};1use std::{borrow::Cow, env, fs};
2 2
3use git_config::file::from_paths::Options;3use git_config::{
4use git_config::file::{from_env, from_paths};4 file::{from_env, from_paths, from_paths::Options},
5use git_config::File;5 File,
6};
6use serial_test::serial;7use serial_test::serial;
7use tempfile::tempdir;8use tempfile::tempdir;
8 9
git-config/tests/file/init/from_paths/includes/conditional/gitdir/util.rs+4−2
@@ -8,8 +8,10 @@ use std::{ · 7 unmodified lines
8 8
9use bstr::{BString, ByteSlice};9use bstr::{BString, ByteSlice};
10 10
11use crate::file::cow_str;11use crate::file::{
12use crate::file::init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir};12 cow_str,
13 init::from_paths::{escape_backslashes, includes::conditional::options_with_git_dir},
14};
13 15
14#[derive(Debug)]16#[derive(Debug)]
15pub struct GitEnv {17pub struct GitEnv {
git-config/tests/file/init/from_paths/includes/conditional/mod.rs+2−4
@@ -1,11 +1,9 @@
1use std::{fs, path::Path};1use std::{fs, path::Path};
2 2
3use git_config::file::from_paths;3use git_config::{file::from_paths, path, File};
4use git_config::{path, File};
5use tempfile::tempdir;4use tempfile::tempdir;
6 5
7use crate::file::cow_str;6use crate::file::{cow_str, init::from_paths::escape_backslashes};
8use crate::file::init::from_paths::escape_backslashes;
9 7
10mod gitdir;8mod gitdir;
11mod onbranch;9mod onbranch;
git-config/tests/file/init/from_paths/includes/unconditional.rs+2−4
@@ -1,11 +1,9 @@
1use std::fs;1use std::fs;
2 2
3use git_config::file::from_paths;3use git_config::{file::from_paths, File};
4use git_config::File;
5use tempfile::tempdir;4use tempfile::tempdir;
6 5
7use crate::file::cow_str;6use crate::file::{cow_str, init::from_paths::escape_backslashes};
8use crate::file::init::from_paths::escape_backslashes;
9 7
10#[test]8#[test]
11fn multiple() -> crate::Result {9fn multiple() -> crate::Result {
git-config/tests/file/mutable/multi_value.rs+2−4
@@ -1,6 +1,5 @@
1mod get {1mod get {
2 use crate::file::cow_str;2 use crate::file::{cow_str, mutable::multi_value::init_config};
3 use crate::file::mutable::multi_value::init_config;
4 3
5 #[test]4 #[test]
6 fn single_lines() -> crate::Result {5 fn single_lines() -> crate::Result {
@@ -50,8 +49,7 @@ mod access { · 43 unmodified lines
50}49}
51 50
52mod set {51mod set {
53 use crate::file::cow_str;52 use crate::file::{cow_str, mutable::multi_value::init_config};
54 use crate::file::mutable::multi_value::init_config;
55 53
56 #[test]54 #[test]
57 fn values_are_escaped() -> crate::Result {55 fn values_are_escaped() -> crate::Result {
git-config/tests/file/mutable/section.rs+8−4
@@ -1,8 +1,10 @@
1mod push {1mod push {
2 use crate::file::cow_str;
3 use git_config::parse::section::Key;
4 use std::convert::TryFrom;2 use std::convert::TryFrom;
5 3
4 use git_config::parse::section::Key;
5
6 use crate::file::cow_str;
7
6 #[test]8 #[test]
7 fn whitespace_is_derived_from_whitespace_before_first_value() -> crate::Result {9 fn whitespace_is_derived_from_whitespace_before_first_value() -> crate::Result {
8 for (input, expected_pre_key, expected_sep) in [10 for (input, expected_pre_key, expected_sep) in [
@@ -58,10 +60,12 @@ mod push { · 49 unmodified lines
58}60}
59 61
60mod set_leading_whitespace {62mod set_leading_whitespace {
61 use crate::file::cow_str;
62 use git_config::parse::section::Key;
63 use std::convert::TryFrom;63 use std::convert::TryFrom;
64 64
65 use git_config::parse::section::Key;
66
67 use crate::file::cow_str;
68
65 #[test]69 #[test]
66 fn any_whitespace_is_ok() -> crate::Result {70 fn any_whitespace_is_ok() -> crate::Result {
67 let mut config = git_config::File::default();71 let mut config = git_config::File::default();
git-config/tests/file/mutable/value.rs+2−1
@@ -1,7 +1,8 @@
1mod get {1mod get {
2 use crate::file::mutable::value::init_config;
3 use bstr::BString;2 use bstr::BString;
4 3
4 use crate::file::mutable::value::init_config;
5
5 fn config_get(input: &str) -> BString {6 fn config_get(input: &str) -> BString {
6 let mut file: git_config::File = input.parse().unwrap();7 let mut file: git_config::File = input.parse().unwrap();
7 file.raw_value_mut("a", None, "k").unwrap().get().unwrap().into_owned()8 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 @@
1use super::*;
2use git_config::parse::Events;1use git_config::parse::Events;
3 2
3use super::*;
4
4#[test]5#[test]
5#[rustfmt::skip]6#[rustfmt::skip]
6fn complex() {7fn complex() {
git-config/tests/parse/mod.rs+1−2
@@ -1,5 +1,4 @@
1use std::borrow::Cow;1use std::{borrow::Cow, convert::TryFrom};
2use std::convert::TryFrom;
3 2
4use git_config::parse::{Event, Events, Section};3use git_config::parse::{Event, Events, Section};
5 4
git-config/tests/parse/section.rs+10−7
@@ -1,16 +1,17 @@
1use git_config::parse::section;
2use git_config::parse::Event;
3use std::borrow::Cow;1use std::borrow::Cow;
4 2
3use git_config::parse::{section, Event};
4
5pub fn header_event(name: &'static str, subsection: impl Into<Option<&'static str>>) -> Event<'static> {5pub fn header_event(name: &'static str, subsection: impl Into<Option<&'static str>>) -> Event<'static> {
6 Event::SectionHeader(section::Header::new(name, subsection.into().map(Cow::Borrowed)).unwrap())6 Event::SectionHeader(section::Header::new(name, subsection.into().map(Cow::Borrowed)).unwrap())
7}7}
8 8
9mod header {9mod header {
10 mod write_to {10 mod write_to {
11 use git_config::parse::section;
12 use std::borrow::Cow;11 use std::borrow::Cow;
13 12
13 use git_config::parse::section;
14
14 #[test]15 #[test]
15 fn subsection_backslashes_and_quotes_are_escaped() -> crate::Result {16 fn subsection_backslashes_and_quotes_are_escaped() -> crate::Result {
16 assert_eq!(17 assert_eq!(
@@ -34,9 +35,10 @@ mod header { · 17 unmodified lines
34 }35 }
35 }36 }
36 mod new {37 mod new {
37 use git_config::parse::section;
38 use std::borrow::Cow;38 use std::borrow::Cow;
39 39
40 use git_config::parse::section;
41
40 #[test]42 #[test]
41 fn names_must_be_mostly_ascii() {43 fn names_must_be_mostly_ascii() {
42 for name in ["🤗", "x.y", "x y", "x\ny"] {44 for name in ["🤗", "x.y", "x y", "x\ny"] {
@@ -61,9 +63,10 @@ mod header { · 18 unmodified lines
61 }63 }
62}64}
63mod name {65mod name {
64 use git_config::parse::section::Name;
65 use std::convert::TryFrom;66 use std::convert::TryFrom;
66 67
68 use git_config::parse::section::Name;
69
67 #[test]70 #[test]
68 fn alphanum_and_dash_are_valid() {71 fn alphanum_and_dash_are_valid() {
69 assert!(Name::try_from("1a").is_ok());72 assert!(Name::try_from("1a").is_ok());
@@ -80,9 +83,9 @@ mod name { · 10 unmodified lines
80}83}
81 84
82mod key {85mod key {
86 use std::{cmp::Ordering, convert::TryFrom};
87
83 use git_config::parse::section::Key;88 use git_config::parse::section::Key;
84 use std::cmp::Ordering;
85 use std::convert::TryFrom;
86 89
87 fn key(k: &str) -> Key<'_> {90 fn key(k: &str) -> Key<'_> {
88 Key::try_from(k).unwrap()91 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