Debian Codegraph @

src/features/hyperlinks.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
3
4 use lazy_staticrust-analyzer cargo lazy_static 1.4.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!;
5 use regexrust-analyzer cargo regex 1.12.3 crate/::{Matchrust-analyzer cargo regex 1.12.3 regex/string/Match#, Matchesrust-analyzer cargo regex 1.12.3 regex/string/Matches#, Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#};
6
7 use craterust-analyzer cargo git-delta 0.19.2 crate/::configrust-analyzer cargo git-delta 0.19.2 config/::Configrust-analyzer cargo git-delta 0.19.2 config/Config#;
8 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#;
9
10 #[cfg(test)]
11 use craterust-analyzer cargo git-delta 0.19.2 crate/::git_configrust-analyzer cargo git-delta 0.19.2 git_config/::GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#;
12
13 pub fn make_featurerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/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#)> {
14 builtin_featurerust-analyzer cargo git-delta 0.19.2 features/builtin_feature!!([
15 (
16 "hyperlinks",
17 bool,
18 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
19 _opt => true
20 )
21 ])
22 }
23
24 lazy_staticrust-analyzer cargo lazy_static 1.4.0 lazy_static!! {
25 // Commit hashes can be abbreviated to 7 characters, these necessarily become longer
26 // when more objects are in a repository.
27 // Note: pure numbers are filtered out later again.
28 static ref COMMIT_HASH_REGEXrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/COMMIT_HASH_REGEX#: Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex# = Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#::newrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]new().(r"\b[0-9a-f]{7,40}\b").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
29 }
30
31 pub fn format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().<'a>(
32 line: &'a str,
33 config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
34 ) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str> {
35 // Given matches in a line, m = matches[0] and pos = 0: store line[pos..m.start()] first, then
36 // store the T(line[m.start()..m.end()]) match transformation, then set pos = m.end().
37 // Repeat for matches[1..]. Finally, store line[pos..].
38 struct HyperlinkCommitsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/HyperlinkCommits#<T>(T)
39 where
40 T: Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
41 impl<T: for<'b> Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#(&'b str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> HyperlinkCommitsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/HyperlinkCommits#<T> {
42 fn _mrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]_m().(&self, result: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, line: &str, m: &Matchrust-analyzer cargo regex 1.12.3 regex/string/Match#, prev_pos: usize) -> usize {
43 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&line[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().prev_pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#m.startrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
44 let commit = &line[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().m.startrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]start().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#m.endrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]end().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
45 // Do not link numbers, require at least one non-decimal:
46 if commit.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(|c| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(c, 'a'..='f')) {
47 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&format_osc8_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_hyperlink().(&self.0rust-analyzer cargo git-delta 0.19.2 features/hyperlinks/HyperlinkCommits#0.(commit), commit));
48 } else {
49 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(commit);
50 }
51 m.endrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]end().()
52 }
53 fn with_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]with_input().(&self, line: &str, m0: &Matchrust-analyzer cargo regex 1.12.3 regex/string/Match#, matches123: &mut Matchesrust-analyzer cargo regex 1.12.3 regex/string/Matches#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
54 let mut result = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
55 let mut pos = self._mrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]_m().(&mut result, line, m0, 0);
56 // limit number of matches per line, an exhaustive `find_iter` is O(len(line) * len(regex)^2)
57 for m in matches123.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(12) {
58 pos = self._mrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]_m().(&mut result, line, &m, pos);
59 }
60 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&line[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
61 result
62 }
63 }
64
65 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(commit_link_format) = &config.hyperlinks_commit_link_formatrust-analyzer cargo git-delta 0.19.2 config/Config#hyperlinks_commit_link_format. {
66 let mut matches = COMMIT_HASH_REGEXrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/COMMIT_HASH_REGEX..find_iterrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]find_iter().(line);
67 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first_match) = matches.nextrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Matches<'r, 'h>`][Iterator]next().() {
68 let result =
69 HyperlinkCommitsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/HyperlinkCommits#(|commit_hash| commit_link_format.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("{commit}", commit_hash))
70 .with_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]with_input().(line, &first_match, &mut matches);
71 return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'a, str>`][`From<String>`]from().(result);
72 }
73 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(config) = config.git_configrust-analyzer cargo git-delta 0.19.2 config/impl#[Config]git_config().() {
74 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(repo) = config.get_remote_urlrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]get_remote_url().() {
75 let mut matches = COMMIT_HASH_REGEXrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/COMMIT_HASH_REGEX..find_iterrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]find_iter().(line);
76 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first_match) = matches.nextrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Matches<'r, 'h>`][Iterator]next().() {
77 let result = HyperlinkCommitsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/HyperlinkCommits#(|commit_hash| repo.format_commit_urlrust-analyzer cargo git-delta 0.19.2 git_config/remote/impl#[GitRemoteRepo]format_commit_url().(commit_hash))
78 .with_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/impl#[`HyperlinkCommits<T>`]with_input().(line, &first_match, &mut matches);
79 return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'a, str>`][`From<String>`]from().(result);
80 }
81 }
82 }
83 Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'a, str>`][`From<&'a str>`]from().(line)
84 }
85
86 /// Create a file hyperlink, displaying `text`.
87 pub fn format_osc8_file_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_file_hyperlink().<'a, P>(
88 absolute_path: P,
89 line_number: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
90 text: &str,
91 config: &Configrust-analyzer cargo git-delta 0.19.2 config/Config#,
92 ) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str>
93 where
94 P: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>,
95 P: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
96 {
97 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(absolute_path.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().is_absoluterust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]is_absolute().());
98 let mut url = config
99 .hyperlinks_file_link_formatrust-analyzer cargo git-delta 0.19.2 config/Config#hyperlinks_file_link_format.
100 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("{path}", &absolute_path.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().());
101 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(host) = &config.hostnamerust-analyzer cargo git-delta 0.19.2 config/Config#hostname. {
102 url = url.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("{host}", host)
103 }
104 let n = line_number.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(1);
105 url = url.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("{line}", &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{n}"));
106 Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'a, str>`][`From<String>`]from().(format_osc8_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_hyperlink().(&url, text))
107 }
108
109 fn format_osc8_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_hyperlink().(url: &str, text: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
110 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
111 "{osc}8;;{url}{st}{text}{osc}8;;{st}",
112 url = url,
113 text = text,
114 osc = "\x1b]",
115 st = "\x1b\\"
116 )
117 }
118
119 #[cfg(not(target_os = "windows"))]
120 #[cfg(test)]
121 pub mod testsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/ {
122 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#;
123 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
124
125 use pretty_assertionsrust-analyzer cargo pretty_assertions 1.4.1 crate/::assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!;
126
127 use superrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/::*;
128
129 use craterust-analyzer cargo git-delta 0.19.2 crate/::{
130 testsrust-analyzer cargo git-delta 0.19.2 tests/::integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::{selfrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/, make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args()., DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#},
131 utilsrust-analyzer cargo git-delta 0.19.2 utils/,
132 };
133
134 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
135 fn test_file_hyperlink_line_number_defaults_to_onerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_file_hyperlink_line_number_defaults_to_one().() {
136 let config =
137 make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&["--hyperlinks-file-link-format", "file://{path}:{line}"]);
138
139 let result =
140 format_osc8_file_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_file_hyperlink().("/absolute/path/to/file.rs", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(42), "file.rs", &config);
141 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
142 result,
143 "\u{1b}]8;;file:///absolute/path/to/file.rs:42\u{1b}\\file.rs\u{1b}]8;;\u{1b}\\",
144 );
145
146 let result =
147 format_osc8_file_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_file_hyperlink().("/absolute/path/to/file.rs", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "file.rs", &config);
148 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
149 result,
150 "\u{1b}]8;;file:///absolute/path/to/file.rs:1\u{1b}\\file.rs\u{1b}]8;;\u{1b}\\",
151 );
152 }
153
154 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
155 fn test_formatted_hyperlinksrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_formatted_hyperlinks().() {
156 let config = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&["--hyperlinks-commit-link-format", "HERE:{commit}"]);
157
158 let line = "001234abcdf";
159 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
160 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
161 result,
162 "\u{1b}]8;;HERE:001234abcdf\u{1b}\\001234abcdf\u{1b}]8;;\u{1b}\\",
163 );
164
165 let line = "a2272718f0b398e48652ace17fca85c1962b3fc22"; // length: 41 > 40
166 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
167 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(result, "a2272718f0b398e48652ace17fca85c1962b3fc22",);
168
169 let line = "a2272718f0+b398e48652ace17f,ca85c1962b3fc2";
170 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
171 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(result, "\u{1b}]8;;HERE:a2272718f0\u{1b}\\a2272718f0\u{1b}]8;;\u{1b}\\+\u{1b}]8;;\
172 HERE:b398e48652ace17f\u{1b}\\b398e48652ace17f\u{1b}]8;;\u{1b}\\,\u{1b}]8;;HERE:ca85c1962b3fc2\
173 \u{1b}\\ca85c1962b3fc2\u{1b}]8;;\u{1b}\\");
174
175 let line = "This 01234abcdf Hash";
176 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
177 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
178 result,
179 "This \u{1b}]8;;HERE:01234abcdf\u{1b}\\01234abcdf\u{1b}]8;;\u{1b}\\ Hash",
180 );
181
182 let line =
183 "Another 01234abcdf hash but also this one: dc623b084ad2dd14fe5d90189cacad5d49bfbfd3!";
184 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
185 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
186 result,
187 "Another \u{1b}]8;;HERE:01234abcdf\u{1b}\\01234abcdf\u{1b}]8;;\u{1b}\\ hash but \
188 also this one: \u{1b}]8;;HERE:dc623b084ad2dd14fe5d90189cacad5d49bfbfd3\u{1b}\
189 \\dc623b084ad2dd14fe5d90189cacad5d49bfbfd3\u{1b}]8;;\u{1b}\\!"
190 );
191
192 let line = "01234abcdf 03043baf30 12abcdef0 12345678";
193 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
194 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
195 result,
196 "\u{1b}]8;;HERE:01234abcdf\u{1b}\\01234abcdf\u{1b}]8;;\u{1b}\\ \u{1b}]8;;\
197 HERE:03043baf30\u{1b}\\03043baf30\u{1b}]8;;\u{1b}\\ \u{1b}]8;;HERE:12abcdef0\u{1b}\\\
198 12abcdef0\u{1b}]8;;\u{1b}\\ 12345678"
199 );
200 }
201
202 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
203 fn test_hyperlinks_to_reporust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_hyperlinks_to_repo().() {
204 let mut config = make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(&["--hyperlinks"]);
205 config.git_configrust-analyzer cargo git-delta 0.19.2 config/Config#git_config. = GitConfigrust-analyzer cargo git-delta 0.19.2 git_config/GitConfig#::for_testingrust-analyzer cargo git-delta 0.19.2 git_config/impl#[GitConfig]for_testing().();
206
207 let line = "This a589ff9debaefdd delta commit";
208 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
209 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
210 result,
211 "This \u{1b}]8;;https://github.com/dandavison/delta/commit/a589ff9debaefdd\u{1b}\
212 \\a589ff9debaefdd\u{1b}]8;;\u{1b}\\ delta commit",
213 );
214
215 let line =
216 "Another a589ff9debaefdd hash but also this one: c5696757c0827349a87daa95415656!";
217 let result = format_commit_line_with_osc8_commit_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_commit_line_with_osc8_commit_hyperlink().(line, &config);
218 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
219 result,
220 "Another \u{1b}]8;;https://github.com/dandavison/delta/commit/a589ff9debaefdd\
221 \u{1b}\\a589ff9debaefdd\u{1b}]8;;\u{1b}\\ hash but also this one: \u{1b}]8;;\
222 https://github.com/dandavison/delta/commit/c5696757c0827349a87daa95415656\u{1b}\
223 \\c5696757c0827349a87daa95415656\u{1b}]8;;\
224 \u{1b}\\!"
225 );
226 }
227
228 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
229 fn test_paths_and_hyperlinks_user_in_repo_root_dirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_paths_and_hyperlinks_user_in_repo_root_dir().() {
230 // Expectations are uninfluenced by git's --relative and delta's relative_paths options.
231 let input_type = InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#;
232 let true_location_of_file_relative_to_repo_root = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("a");
233 let git_prefix_env_var = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("");
234
235 for (delta_relative_paths_option, calling_cmd) in [
236 (false, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff")),
237 (false, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff --relative")),
238 (true, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff")),
239 (true, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff --relative")),
240 ] {
241 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
242 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
243 "delta relative_paths={delta_relative_paths_option} calling_cmd={calling_cmd:?}",
244 ),
245 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
246 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
247 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
248 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.,
249 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
250 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.,
251 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "a",
252 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "a",
253 })
254 }
255 }
256
257 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
258 fn test_paths_and_hyperlinks_user_in_subdir_file_in_same_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_paths_and_hyperlinks_user_in_subdir_file_in_same_subdir().() {
259 let input_type = InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#;
260 let true_location_of_file_relative_to_repo_root = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`FromIterator<P>`]from_iter().(&["b", "a"]);
261 let git_prefix_env_var = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("b");
262
263 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
264 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from b",
265 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
266 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff"),
267 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
268 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
269 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
270 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
271 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "b/a",
272 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "b/a",
273 });
274 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
275 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from b",
276 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
277 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff --relative"),
278 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
279 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
280 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
281 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
282 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "a",
283 // delta saw a and wasn't configured to make any changes
284 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "a",
285 });
286 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
287 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from b",
288 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
289 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff"),
290 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
291 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
292 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
293 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: true,
294 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "b/a",
295 // delta saw b/a and changed it to a
296 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "a",
297 });
298 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
299 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from b",
300 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
301 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff --relative"),
302 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
303 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
304 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
305 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: true,
306 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "a",
307 // delta saw a and didn't change it
308 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "a",
309 });
310 }
311
312 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
313 fn test_paths_and_hyperlinks_user_in_subdir_file_in_different_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_paths_and_hyperlinks_user_in_subdir_file_in_different_subdir().() {
314 let input_type = InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#;
315 let true_location_of_file_relative_to_repo_root = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`FromIterator<P>`]from_iter().(&["b", "a"]);
316 let git_prefix_env_var = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("c");
317
318 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
319 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from c",
320 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
321 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff"),
322 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
323 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
324 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
325 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
326 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "b/a",
327 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "b/a",
328 });
329 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
330 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from c",
331 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
332 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff --relative"),
333 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
334 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
335 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
336 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
337 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "../b/a",
338 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "../b/a",
339 });
340 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
341 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "b/a from c",
342 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
343 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git diff"),
344 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: true,
345 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
346 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
347 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.,
348 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "b/a",
349 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "../b/a",
350 });
351 }
352
353 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
354 fn test_paths_and_hyperlinks_git_grep_user_in_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_paths_and_hyperlinks_git_grep_user_in_root().() {
355 let input_type = InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#;
356 let true_location_of_file_relative_to_repo_root = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`FromIterator<P>`]from_iter().(&["b", "a.txt"]);
357
358 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
359 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "git grep: b/a.txt from root dir",
360 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
361 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git grep foo"),
362 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
363 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
364 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
365 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(""),
366 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "b/a.txt",
367 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "b/a.txt:",
368 });
369 }
370
371 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
372 fn test_paths_and_hyperlinks_grep_user_in_subdir_file_in_same_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/test_paths_and_hyperlinks_grep_user_in_subdir_file_in_same_subdir().() {
373 _run_test_grep_user_in_subdir_file_in_same_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/_run_test_grep_user_in_subdir_file_in_same_subdir().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("git grep foo"));
374 _run_test_grep_user_in_subdir_file_in_same_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/_run_test_grep_user_in_subdir_file_in_same_subdir().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rg foo"));
375 }
376
377 fn _run_test_grep_user_in_subdir_file_in_same_subdirrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/_run_test_grep_user_in_subdir_file_in_same_subdir().(calling_cmd: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) {
378 let input_type = InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#;
379 let true_location_of_file_relative_to_repo_root = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`FromIterator<P>`]from_iter().(&["b", "a.txt"]);
380 run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase# {
381 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: "git grep: b/a.txt from b/ dir",
382 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.,
383 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.,
384 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: false,
385 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.:
386 true_location_of_file_relative_to_repo_root.as_pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]as_path().(),
387 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("b/"),
388 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: "a.txt",
389 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: "a.txt:",
390 });
391 }
392
393 const GIT_DIFF_OUTPUTrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GIT_DIFF_OUTPUT.: &str = r#"
394 diff --git a/__path__ b/__path__
395 index 587be6b..975fbec 100644
396 --- a/__path__
397 +++ b/__path__
398 @@ -1 +1 @@
399 -x
400 +y
401 "#;
402
403 const GIT_GREP_OUTPUTrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GIT_GREP_OUTPUT.: &str = "\
404 __path__: some matching line
405 ";
406
407 struct FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#<'a> {
408 // True location of file in repo
409 true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.: &'a Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
410
411 // Git spawns delta from repo root, and stores in this env var the cwd in which the user invoked delta.
412 git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>,
413
414 delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option.: bool,
415 input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type.: InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#,
416 calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>,
417 path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.: &'a str,
418 expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.: &'a str,
419 #[allow(dead_code)]
420 namerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#name.: &'a str,
421 }
422
423 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
424 enum GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative# {
425 Yesrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#Yes#,
426 Norust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#No#,
427 }
428
429 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
430 enum CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess# {
431 GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#),
432 GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep#,
433 OtherGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#OtherGrep#,
434 }
435
436 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
437 enum InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType# {
438 GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#,
439 Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#,
440 }
441
442 impl<'a> FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#<'a> {
443 pub fn get_argsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]get_args().(&self) -> 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#> {
444 let mut args = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
445 "--navigate", // helps locate the file path in the output
446 "--line-numbers",
447 "--hyperlinks",
448 "--hyperlinks-file-link-format",
449 "{path}",
450 "--grep-file-style",
451 "raw",
452 "--grep-line-number-style",
453 "raw",
454 "--grep-output-type",
455 "classic",
456 "--hunk-header-file-style",
457 "raw",
458 "--hunk-header-line-number-style",
459 "raw",
460 "--line-numbers-plus-style",
461 "raw",
462 "--line-numbers-left-style",
463 "raw",
464 "--line-numbers-right-style",
465 "raw",
466 "--line-numbers-left-format",
467 "{nm}અ",
468 "--line-numbers-right-format",
469 "{np}જ",
470 ];
471 if self.delta_relative_paths_optionrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#delta_relative_paths_option. {
472 args.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().("--relative-paths");
473 }
474 args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
475 }
476
477 pub fn calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().(&self) -> CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess# {
478 match (&self.input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type., self.calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.) {
479 (InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s)) if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("git diff --relative") => {
480 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#::Yesrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#Yes#)
481 }
482 (InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#GitDiff#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s)) if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("git diff") => {
483 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#::Norust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#No#)
484 }
485 (InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s)) if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("git grep") => CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep#,
486 (InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s)) if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("rg") => CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#OtherGrep#,
487 (InputTyperust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#::Greprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/InputType#Grep#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep#,
488 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(
489 "Unexpected calling spec: {:?} {:?}",
490 self.input_typerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#input_type., self.calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd.
491 ),
492 }
493 }
494
495 pub fn path_in_git_outputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]path_in_git_output().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
496 match self.calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().() {
497 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#::Norust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#No#) => self
498 .true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.
499 .to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().()
500 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
501 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(GitDiffRelativerust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#::Yesrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GitDiffRelative#Yes#) => pathdiffrust-analyzer cargo pathdiff 0.2.1 crate/::diff_pathsrust-analyzer cargo pathdiff 0.2.1 diff_paths().(
502 self.true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.,
503 self.git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
504 )
505 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
506 .to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().()
507 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
508 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected calling process: {:?}", self.calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().()),
509 }
510 }
511
512 /// Return the relative path as it would appear in grep output, i.e. accounting for facts
513 /// such as that the user may have invoked the grep command from a non-root directory
514 /// in the repo.
515 pub fn path_in_grep_outputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]path_in_grep_output().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
516 use CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::*;
517 match (self.calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().(), self.git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var.) {
518 (GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => self
519 .true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.
520 .to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().()
521 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
522 (GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dir)) => {
523 // Delta must have been invoked as core.pager since GIT_PREFIX env var is set.
524 // Note that it is possible that `true_location_of_file_relative_to_repo_root`
525 // is not under `git_prefix_env_var` since one can do things like `git grep foo
526 // ..`
527 pathdiffrust-analyzer cargo pathdiff 0.2.1 crate/::diff_pathsrust-analyzer cargo pathdiff 0.2.1 diff_paths().(self.true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root., dir)
528 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
529 .to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().()
530 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
531 }
532 (OtherGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#OtherGrep#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => {
533 // Output from e.g. rg has been piped to delta.
534 // Therefore
535 // (a) the cwd that the delta process reports is the user's shell process cwd
536 // (b) the file in question must be under this cwd
537 // (c) grep output will contain the path relative to this cwd
538
539 // So to compute the path as it would appear in grep output, we could form the
540 // absolute path to the file and strip off the config.cwd_of_delta_process
541 // prefix. The absolute path to the file could be constructed as (absolute path
542 // to repo root) + true_location_of_file_relative_to_repo_root). But I don't
543 // think we know the absolute path to repo root.
544 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Not implemented")
545 }
546 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Not implemented"),
547 }
548 }
549
550 pub fn expected_hyperlink_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]expected_hyperlink_path().(&self) -> PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf# {
551 utilsrust-analyzer cargo git-delta 0.19.2 utils/::pathrust-analyzer cargo git-delta 0.19.2 utils/path/::fake_delta_cwd_for_testsrust-analyzer cargo git-delta 0.19.2 utils/path/fake_delta_cwd_for_tests().()
552 .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(self.true_location_of_file_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#true_location_of_file_relative_to_repo_root.)
553 }
554 }
555
556 fn run_testrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/run_test().(test_case: FilePathsTestCaserust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#) {
557 let mut config = integration_test_utilsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/::make_config_from_argsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/make_config_from_args().(
558 test_case
559 .get_argsrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]get_args().()
560 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
561 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().())
562 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>>()
563 .as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(),
564 );
565 // The test is simulating delta invoked by git hence these are the same
566 config.cwd_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 config/Config#cwd_relative_to_repo_root. = test_case.git_prefix_env_varrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#git_prefix_env_var..maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
567 config.cwd_of_user_shell_processrust-analyzer cargo git-delta 0.19.2 config/Config#cwd_of_user_shell_process. = utilsrust-analyzer cargo git-delta 0.19.2 utils/::pathrust-analyzer cargo git-delta 0.19.2 utils/path/::cwd_of_user_shell_processrust-analyzer cargo git-delta 0.19.2 utils/path/cwd_of_user_shell_process().(
568 config.cwd_of_delta_processrust-analyzer cargo git-delta 0.19.2 config/Config#cwd_of_delta_process..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(),
569 config.cwd_relative_to_repo_rootrust-analyzer cargo git-delta 0.19.2 config/Config#cwd_relative_to_repo_root..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
570 );
571 let mut delta_test = DeltaTestrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/DeltaTest#::with_configrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_config().(&config);
572 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cmd) = test_case.calling_cmdrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#calling_cmd. {
573 delta_test = delta_test.with_calling_processrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_calling_process().(cmd)
574 }
575 let delta_test = match test_case.calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().() {
576 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(_) => {
577 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
578 test_case.path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.,
579 test_case.path_in_git_outputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]path_in_git_output().()
580 );
581 delta_test
582 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&GIT_DIFF_OUTPUTrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GIT_DIFF_OUTPUT..replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("__path__", test_case.path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.))
583 }
584 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep# => {
585 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
586 test_case.path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.,
587 test_case.path_in_grep_outputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]path_in_grep_output().()
588 );
589 delta_test
590 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&GIT_GREP_OUTPUTrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GIT_GREP_OUTPUT..replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("__path__", test_case.path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.))
591 }
592 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#OtherGrep# => delta_test
593 .with_inputrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[`DeltaTest<'a>`]with_input().(&GIT_GREP_OUTPUTrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/GIT_GREP_OUTPUT..replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("__path__", test_case.path_in_delta_inputrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#path_in_delta_input.)),
594 };
595 let make_expected_hyperlink = |text| {
596 format_osc8_hyperlinkrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/format_osc8_hyperlink().(&test_case.expected_hyperlink_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]expected_hyperlink_path().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().(), text)
597 };
598 match test_case.calling_processrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/impl#[`FilePathsTestCase<'a>`]calling_process().() {
599 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitDiffrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitDiff#(_) => {
600 let line_number = "1";
601 delta_test
602 .inspect_rawrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]inspect_raw().()
603 // file hyperlink
604 .expect_raw_containsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_raw_contains().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
605 "Δ {}",
606 make_expected_hyperlink(test_case.expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.)
607 ))
608 // hunk header hyperlink
609 .expect_raw_containsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_raw_contains().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("• {}", make_expected_hyperlink(line_number)))
610 // line number hyperlink
611 .expect_raw_containsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_raw_contains().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("અ{}જ", make_expected_hyperlink(line_number)));
612 }
613 CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::GitGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#GitGrep# | CallingProcessrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#::OtherGreprust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/CallingProcess#OtherGrep# => {
614 delta_test
615 .inspect_rawrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]inspect_raw().()
616 .expect_raw_containsrust-analyzer cargo git-delta 0.19.2 tests/integration_test_utils/impl#[DeltaTestOutput]expect_raw_contains().(&make_expected_hyperlink(
617 test_case.expected_displayed_pathrust-analyzer cargo git-delta 0.19.2 features/hyperlinks/tests/FilePathsTestCase#expected_displayed_path.,
618 ));
619 }
620 }
621 }
622 }