| 1 | use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::rawrust-analyzer cargo git-delta 0.19.2 features/raw/; |
| 2 | use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::OptionValueFunctionrust-analyzer cargo git-delta 0.19.2 features/OptionValueFunction#; |
| 3 | |
| 4 | pub fn make_featurerust-analyzer cargo git-delta 0.19.2 features/diff_highlight/make_feature().() -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, OptionValueFunctionrust-analyzer cargo git-delta 0.19.2 features/OptionValueFunction#)> { |
| 5 | _make_featurerust-analyzer cargo git-delta 0.19.2 features/diff_highlight/_make_feature().(false) |
| 6 | } |
| 7 | |
| 8 | pub fn _make_featurerust-analyzer cargo git-delta 0.19.2 features/diff_highlight/_make_feature().(bold: bool) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, OptionValueFunctionrust-analyzer cargo git-delta 0.19.2 features/OptionValueFunction#)> { |
| 9 | let mut feature = rawrust-analyzer cargo git-delta 0.19.2 features/raw/::make_featurerust-analyzer cargo git-delta 0.19.2 features/raw/make_feature().(); |
| 10 | feature.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|(s, _)| s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."keep-plus-minus-markers" && s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."tabs"); |
| 11 | feature.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(builtin_featurerust-analyzer cargo git-delta 0.19.2 features/builtin_feature!!([ |
| 12 | ( |
| 13 | "commit-style", |
| 14 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 15 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff.commit"), |
| 16 | _opt => "raw" |
| 17 | ), |
| 18 | ( |
| 19 | "minus-style", |
| 20 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 21 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff.old"), |
| 22 | _opt => if bold { "bold red" } else { "red" } |
| 23 | ), |
| 24 | ( |
| 25 | "minus-non-emph-style", |
| 26 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 27 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.oldNormal"), |
| 28 | opt => opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().() |
| 29 | ), |
| 30 | ( |
| 31 | "minus-emph-style", |
| 32 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 33 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.oldHighlight"), |
| 34 | opt => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} reverse", opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style.) |
| 35 | ), |
| 36 | ( |
| 37 | "plus-style", |
| 38 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 39 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff.new"), |
| 40 | _opt => if bold { "bold green" } else { "green" } |
| 41 | ), |
| 42 | ( |
| 43 | "plus-non-emph-style", |
| 44 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 45 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.newNormal"), |
| 46 | opt => opt.plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().() |
| 47 | ), |
| 48 | ( |
| 49 | "plus-emph-style", |
| 50 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 51 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.newHighlight"), |
| 52 | opt => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} reverse", opt.plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style.) |
| 53 | ) |
| 54 | ])); |
| 55 | feature |
| 56 | } |
| 57 | |
| 58 | #[cfg(test)] |
| 59 | mod test_utilsrust-analyzer cargo git-delta 0.19.2 features/diff_highlight/test_utils/ { |
| 60 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().; |
| 61 | |
| 62 | use craterust-analyzer cargo git-delta 0.19.2 crate/::testsrust-analyzer cargo git-delta 0.19.2 tests/::integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/; |
| 63 | |
| 64 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 65 | fn test_diff_highlight_defaultsrust-analyzer cargo git-delta 0.19.2 features/diff_highlight/test_utils/test_diff_highlight_defaults().() { |
| 66 | let opt = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_options_from_args_and_git_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_options_from_args_and_git_config().( |
| 67 | &["--features", "diff-highlight"], |
| 68 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 69 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 70 | ); |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style., "red"); |
| 72 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_non_emph_style., "red"); |
| 73 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style., "red reverse"); |
| 74 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#zero_style., "normal"); |
| 75 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style., "green"); |
| 76 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_non_emph_style., "green"); |
| 77 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_emph_style., "green reverse"); |
| 78 | } |
| 79 | |
| 80 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 81 | fn test_diff_highlight_respects_gitconfigrust-analyzer cargo git-delta 0.19.2 features/diff_highlight/test_utils/test_diff_highlight_respects_gitconfig().() { |
| 82 | let git_config_contents = b" |
| 83 | [color \"diff\"] |
| 84 | old = red bold |
| 85 | new = green bold |
| 86 | |
| 87 | [color \"diff-highlight\"] |
| 88 | oldNormal = ul red bold |
| 89 | oldHighlight = red bold 52 |
| 90 | newNormal = ul green bold |
| 91 | newHighlight = green bold 22 |
| 92 | "; |
| 93 | let git_config_path = "delta__test_diff_highlight.gitconfig"; |
| 94 | |
| 95 | let opt = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_options_from_args_and_git_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_options_from_args_and_git_config().( |
| 96 | &["--features", "diff-highlight"], |
| 97 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 98 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path), |
| 99 | ); |
| 100 | |
| 101 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_style., "red bold"); |
| 102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_non_emph_style., "ul red bold"); |
| 103 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.minus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#minus_emph_style., "red bold 52"); |
| 104 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.zero_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#zero_style., "normal"); |
| 105 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_style., "green bold"); |
| 106 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_non_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_non_emph_style., "ul green bold"); |
| 107 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.plus_emph_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#plus_emph_style., "green bold 22"); |
| 108 | |
| 109 | remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(git_config_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 110 | } |
| 111 | } |