Debian Codegraph @

src/features/diff_so_fancy.rs

raw symbols SCIP
1 use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::diff_highlightrust-analyzer cargo git-delta 0.19.2 features/diff_highlight/;
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_so_fancy/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 let mut feature = diff_highlightrust-analyzer cargo git-delta 0.19.2 features/diff_highlight/::_make_featurerust-analyzer cargo git-delta 0.19.2 features/diff_highlight/_make_feature().(true);
6 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!!([
7 (
8 "minus-emph-style",
9 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
10 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.oldHighlight"),
11 _opt => "bold red 52"
12 ),
13 (
14 "plus-emph-style",
15 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
16 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff-highlight.newHighlight"),
17 _opt => "bold green 22"
18 ),
19 (
20 "file-style",
21 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
22 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff.meta"),
23 _opt => "11"
24 ),
25 (
26 "file-decoration-style",
27 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
28 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
29 _opt => "bold yellow ul ol"
30 ),
31 (
32 "hunk-header-style",
33 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
34 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("color.diff.frag"),
35 _opt => "file line-number bold syntax"
36 ),
37 (
38 "hunk-header-decoration-style",
39 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
40 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
41 _opt => "magenta box"
42 )
43 ]));
44 feature
45 }
46
47 #[cfg(test)]
48 pub mod testsrust-analyzer cargo git-delta 0.19.2 features/diff_so_fancy/tests/ {
49 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().;
50
51 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/;
52
53 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
54 fn test_diff_so_fancy_defaultsrust-analyzer cargo git-delta 0.19.2 features/diff_so_fancy/tests/test_diff_so_fancy_defaults().() {
55 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().(
56 &["--features", "diff-so-fancy"],
57 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
58 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
59 );
60
61 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_style., "raw");
62 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_decoration_style., "none");
63
64 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., "11");
65 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., "bold yellow ul ol");
66
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_style., "file line-number bold syntax");
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_decoration_style., "magenta box");
69 }
70
71 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
72 fn test_diff_so_fancy_respects_git_configrust-analyzer cargo git-delta 0.19.2 features/diff_so_fancy/tests/test_diff_so_fancy_respects_git_config().() {
73 let git_config_contents = b"
74 [color \"diff\"]
75 meta = 11
76 frag = magenta bold
77 commit = purple bold
78 old = red bold
79 new = green bold
80 whitespace = red reverse
81 ";
82 let git_config_path = "delta__test_diff_so_fancy.gitconfig";
83
84 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().(
85 &["--features", "diff-so-fancy some-other-feature"],
86 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents),
87 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path),
88 );
89
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_style., "purple bold");
91 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., "11");
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_style., "magenta bold");
93 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.commit_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#commit_decoration_style., "none");
94 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., "bold yellow ul ol");
95 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.hunk_header_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#hunk_header_decoration_style., "magenta box");
96
97 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().();
98 }
99
100 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
101 fn test_diff_so_fancy_obeys_feature_precedence_rulesrust-analyzer cargo git-delta 0.19.2 features/diff_so_fancy/tests/test_diff_so_fancy_obeys_feature_precedence_rules().() {
102 let git_config_contents = b"
103 [color \"diff\"]
104 meta = 11
105 frag = magenta bold
106 commit = yellow bold
107 old = red bold
108 new = green bold
109 whitespace = red reverse
110
111 [delta \"decorations\"]
112 commit-decoration-style = bold box ul
113 file-style = bold 19 ul
114 file-decoration-style = none
115 ";
116 let git_config_path = "delta__test_diff_so_fancy_obeys_feature_precedence_rules.gitconfig";
117
118 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().(
119 &["--features", "decorations diff-so-fancy"],
120 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents),
121 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path),
122 );
123
124 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., "11");
125
126 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., "bold yellow ul ol");
127
128 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().(
129 &["--features", "diff-so-fancy decorations"],
130 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents),
131 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path),
132 );
133
134 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_style., "bold 19 ul");
135
136 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opt.file_decoration_stylerust-analyzer cargo git-delta 0.19.2 cli/Opt#file_decoration_style., "none");
137
138 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().();
139 }
140 }