| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 2 | #[cfg(target_os = "windows")] |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#}; |
| 4 | 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#; |
| 5 | |
| 6 | 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#; |
| 7 | use craterust-analyzer cargo git-delta 0.19.2 crate/::utilsrust-analyzer cargo git-delta 0.19.2 utils/::batrust-analyzer cargo git-delta 0.19.2 utils/bat/::outputrust-analyzer cargo git-delta 0.19.2 utils/bat/output/::PagerCfgrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagerCfg#; |
| 8 | |
| 9 | pub fn make_featurerust-analyzer cargo git-delta 0.19.2 features/navigate/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#)> { |
| 10 | builtin_featurerust-analyzer cargo git-delta 0.19.2 features/builtin_feature!!([ |
| 11 | ( |
| 12 | "navigate", |
| 13 | bool, |
| 14 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 15 | _opt => true |
| 16 | ), |
| 17 | ( |
| 18 | "file-modified-label", |
| 19 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 20 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 21 | _opt => "Δ" |
| 22 | ), |
| 23 | ( |
| 24 | "hunk-label", |
| 25 | Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 26 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 27 | _opt => "•" |
| 28 | ) |
| 29 | ]) |
| 30 | } |
| 31 | |
| 32 | // Construct the regexp used by less for paging, if --show-themes or --navigate is enabled. |
| 33 | pub fn make_navigate_regexrust-analyzer cargo git-delta 0.19.2 features/navigate/make_navigate_regex().( |
| 34 | show_themes: bool, |
| 35 | file_modified_label: &str, |
| 36 | file_added_label: &str, |
| 37 | file_removed_label: &str, |
| 38 | file_renamed_label: &str, |
| 39 | hunk_label: &str, |
| 40 | ) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 41 | if show_themes { |
| 42 | "^Theme:".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 43 | } else { |
| 44 | let optional_regexp = |find: &str| { |
| 45 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().find.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 46 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("|{}", regexrust-analyzer cargo regex 1.12.3 crate/::escaperust-analyzer cargo regex 1.12.3 escape().(find)) |
| 47 | } else { |
| 48 | "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 49 | } |
| 50 | }; |
| 51 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 52 | "^(commit{}{}{}{}{})", |
| 53 | optional_regexp(file_added_label), |
| 54 | optional_regexp(file_removed_label), |
| 55 | optional_regexp(file_renamed_label), |
| 56 | optional_regexp(file_modified_label), |
| 57 | optional_regexp(hunk_label), |
| 58 | ) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Create a less history file to be used by delta's child less process. This file is initialized |
| 63 | // with the contents of user's real less hist file, to which the navigate regex is appended. This |
| 64 | // has the effect that 'n' or 'N' in delta's less process will search for the navigate regex, |
| 65 | // without the undesirable aspects of using --pattern, yet without polluting the user's less search |
| 66 | // history with delta's navigate regex. See |
| 67 | // https://github.com/dandavison/delta/issues/237#issuecomment-780654036. Note that with the |
| 68 | // current implementation, no writes to the delta less history file are propagated back to the real |
| 69 | // history file so, for example, a (non-navigate) search performed in the delta less process will |
| 70 | // not be stored in history. |
| 71 | pub fn copy_less_hist_file_and_append_navigate_regexrust-analyzer cargo git-delta 0.19.2 features/navigate/copy_less_hist_file_and_append_navigate_regex().( |
| 72 | config: &PagerCfgrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagerCfg#, |
| 73 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 74 | let delta_less_hist_file = get_delta_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/get_delta_less_hist_file().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 75 | let initial_contents = ".less-history-file:\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 76 | let mut contents = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hist_file) = get_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/get_less_hist_file().() { |
| 77 | 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/::read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/read_to_string().(hist_file).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(initial_contents) |
| 78 | } else { |
| 79 | initial_contents |
| 80 | }; |
| 81 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().contents.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().(".search\n") { |
| 82 | contents = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{contents}.search\n"); |
| 83 | } |
| 84 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!( |
| 85 | 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/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&delta_less_hist_file)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 86 | "{}\"{}", |
| 87 | contents, |
| 88 | config.navigate_regexrust-analyzer cargo git-delta 0.19.2 utils/bat/output/PagerCfg#navigate_regex..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 89 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 90 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(delta_less_hist_file) |
| 91 | } |
| 92 | |
| 93 | #[cfg(target_os = "windows")] |
| 94 | fn get_delta_less_hist_file() -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 95 | let mut path = dirsrust-analyzer cargo dirs 6.0.0 crate/::data_local_dirrust-analyzer cargo dirs 6.0.0 data_local_dir().() |
| 96 | .ok_or_else(|| Error::new(ErrorKind::NotFound, "Can't find AppData\\Local folder"))?; |
| 97 | path.push("delta"); |
| 98 | 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/::create_dir_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir_all().(&path)?; |
| 99 | path.push("delta.lesshst"); |
| 100 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(path) |
| 101 | } |
| 102 | |
| 103 | #[cfg(not(target_os = "windows"))] |
| 104 | fn get_delta_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/get_delta_less_hist_file().() -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 105 | let dir = xdgrust-analyzer cargo xdg 2.5.2 crate/::BaseDirectoriesrust-analyzer cargo xdg 2.5.2 base_directories/BaseDirectories#::with_prefixrust-analyzer cargo xdg 2.5.2 base_directories/impl#[BaseDirectories]with_prefix().("delta")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 106 | dir.place_data_filerust-analyzer cargo xdg 2.5.2 base_directories/impl#[BaseDirectories]place_data_file().("lesshst") |
| 107 | } |
| 108 | |
| 109 | // Get path of the less history file. See `man less` for more details. |
| 110 | // On Unix, check all possible locations and pick the newest file. |
| 111 | fn get_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/get_less_hist_file().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#> { |
| 112 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(home_dir) = dirsrust-analyzer cargo dirs 6.0.0 crate/::home_dirrust-analyzer cargo dirs 6.0.0 home_dir().() { |
| 113 | match stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("LESSHISTFILE").as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_deref().() { |
| 114 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("-") | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/dev/null") => { |
| 115 | // The user has explicitly disabled less history. |
| 116 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 117 | } |
| 118 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(path) => { |
| 119 | // The user has specified a custom histfile. |
| 120 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(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().(path)) |
| 121 | } |
| 122 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 123 | // The user is using the default less histfile location. |
| 124 | #[cfg(unix)] |
| 125 | { |
| 126 | // According to the less 643 manual: |
| 127 | // "$XDG_STATE_HOME/lesshst" or "$HOME/.local/state/lesshst" or |
| 128 | // "$XDG_DATA_HOME/lesshst" or "$HOME/.lesshst". |
| 129 | let xdg_dirs = xdgrust-analyzer cargo xdg 2.5.2 crate/::BaseDirectoriesrust-analyzer cargo xdg 2.5.2 base_directories/BaseDirectories#::newrust-analyzer cargo xdg 2.5.2 base_directories/impl#[BaseDirectories]new().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 130 | [ |
| 131 | xdg_dirs.get_state_homerust-analyzer cargo xdg 2.5.2 base_directories/impl#[BaseDirectories]get_state_home().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("lesshst"), |
| 132 | xdg_dirs.get_data_homerust-analyzer cargo xdg 2.5.2 base_directories/impl#[BaseDirectories]get_data_home().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("lesshst"), |
| 133 | home_dir.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(".lesshst"), |
| 134 | ] |
| 135 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 136 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|path| path.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().()) |
| 137 | .max_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max_by_key().(|path| { |
| 138 | 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/::metadatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/metadata().(path) |
| 139 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|m| m.modifiedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[Metadata]modified().()) |
| 140 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.) |
| 141 | }) |
| 142 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() |
| 143 | } |
| 144 | #[cfg(not(unix))] |
| 145 | { |
| 146 | let mut hist_file = home_dir; |
| 147 | hist_file.push(if cfgrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/cfg!!(windows) { |
| 148 | "_lesshst" |
| 149 | } else { |
| 150 | ".lesshst" |
| 151 | }); |
| 152 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hist_file) |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } else { |
| 157 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | #[cfg(test)] |
| 162 | mod testsrust-analyzer cargo git-delta 0.19.2 features/navigate/tests/ { |
| 163 | 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().; |
| 164 | |
| 165 | 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/; |
| 166 | |
| 167 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 168 | #[ignore] |
| 169 | // manually verify: cargo test -- test_get_less_hist_file --ignored --nocapture |
| 170 | fn test_get_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/tests/test_get_less_hist_file().() { |
| 171 | let hist_file = superrust-analyzer cargo git-delta 0.19.2 features/navigate/::get_less_hist_filerust-analyzer cargo git-delta 0.19.2 features/navigate/get_less_hist_file().(); |
| 172 | dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(hist_file); |
| 173 | } |
| 174 | |
| 175 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 176 | fn test_navigate_with_overridden_key_in_main_sectionrust-analyzer cargo git-delta 0.19.2 features/navigate/tests/test_navigate_with_overridden_key_in_main_section().() { |
| 177 | let git_config_contents = b" |
| 178 | [delta] |
| 179 | features = navigate |
| 180 | file-modified-label = \"modified: \" |
| 181 | "; |
| 182 | let git_config_path = "delta__test_navigate_with_overridden_key_in_main_section.gitconfig"; |
| 183 | |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 185 | 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().(&[], Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 186 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 187 | "" |
| 188 | ); |
| 189 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 190 | 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().( |
| 191 | &["--features", "navigate"], |
| 192 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 193 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 194 | ) |
| 195 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 196 | "Δ" |
| 197 | ); |
| 198 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 199 | 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().( |
| 200 | &["--navigate"], |
| 201 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 202 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 203 | ) |
| 204 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 205 | "Δ" |
| 206 | ); |
| 207 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 208 | 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().( |
| 209 | &[], |
| 210 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 211 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path) |
| 212 | ) |
| 213 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 214 | "modified: " |
| 215 | ); |
| 216 | |
| 217 | 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().(); |
| 218 | } |
| 219 | |
| 220 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 221 | fn test_navigate_with_overridden_key_in_custom_navigate_sectionrust-analyzer cargo git-delta 0.19.2 features/navigate/tests/test_navigate_with_overridden_key_in_custom_navigate_section().() { |
| 222 | let git_config_contents = b" |
| 223 | [delta] |
| 224 | features = navigate |
| 225 | |
| 226 | [delta \"navigate\"] |
| 227 | file-modified-label = \"modified: \" |
| 228 | "; |
| 229 | let git_config_path = |
| 230 | "delta__test_navigate_with_overridden_key_in_custom_navigate_section.gitconfig"; |
| 231 | |
| 232 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 233 | 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().(&[], Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) |
| 234 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 235 | "" |
| 236 | ); |
| 237 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 238 | 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().( |
| 239 | &["--features", "navigate"], |
| 240 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 241 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 242 | ) |
| 243 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 244 | "Δ" |
| 245 | ); |
| 246 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 247 | 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().( |
| 248 | &[], |
| 249 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 250 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path) |
| 251 | ) |
| 252 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 253 | "modified: " |
| 254 | ); |
| 255 | |
| 256 | 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().(); |
| 257 | } |
| 258 | |
| 259 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 260 | fn test_navigate_activated_by_custom_featurerust-analyzer cargo git-delta 0.19.2 features/navigate/tests/test_navigate_activated_by_custom_feature().() { |
| 261 | let git_config_contents = b" |
| 262 | [delta \"my-navigate-feature\"] |
| 263 | features = navigate |
| 264 | file-modified-label = \"modified: \" |
| 265 | "; |
| 266 | let git_config_path = "delta__test_navigate_activated_by_custom_feature.gitconfig"; |
| 267 | |
| 268 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 269 | 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().( |
| 270 | &[], |
| 271 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 272 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path) |
| 273 | ) |
| 274 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 275 | "" |
| 276 | ); |
| 277 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 278 | 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().( |
| 279 | &["--features", "my-navigate-feature"], |
| 280 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_contents), |
| 281 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(git_config_path) |
| 282 | ) |
| 283 | .file_modified_labelrust-analyzer cargo git-delta 0.19.2 cli/Opt#file_modified_label., |
| 284 | "modified: " |
| 285 | ); |
| 286 | |
| 287 | 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().(); |
| 288 | } |
| 289 | } |