summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Otto <th1000s@posteo.net>2022-02-07 23:11:36 +0100
committerDan Davison <dandavison7@gmail.com>2022-02-07 19:35:27 -0500
commitb66d1d371709205525128fcd80ca302630f8ac9e (patch)
tree47d3bc174996a318598213bffaac869fd0411ba1
parent37dd3391844efefbfe59acbbf3ad661b497ed9ce (diff)
Fix unused imports and functions warnings on windows
Otherwise these warnings clutter the github diff display.
-rw-r--r--src/features/hyperlinks.rs91
-rw-r--r--src/handlers/hunk_header.rs5
2 files changed, 48 insertions, 48 deletions
diff --git a/src/features/hyperlinks.rs b/src/features/hyperlinks.rs
index 587faf9b..2fad166f 100644
--- a/src/features/hyperlinks.rs
+++ b/src/features/hyperlinks.rs
@@ -111,54 +111,55 @@ fn format_github_commit_url(commit: &str, github_repo: &str) -> String {
#[cfg(test)]
pub mod tests {
- use std::path::PathBuf;
+ #[cfg(not(target_os = "windows"))]
+ pub mod unix {
+ use std::path::PathBuf;
- use super::*;
- use crate::tests::integration_test_utils;
+ use super::super::*;
+ use crate::tests::integration_test_utils;
- fn assert_file_hyperlink_matches(
- relative_path: &str,
- expected_hyperlink_path: &str,
- config: &Config,
- ) {
- let link_text = "link text";
- assert_eq!(
- format_osc8_hyperlink(
- &PathBuf::from(expected_hyperlink_path).to_string_lossy(),
- link_text
- ),
- format_osc8_file_hyperlink(relative_path, None, link_text, config)
- )
- }
+ fn assert_file_hyperlink_matches(
+ relative_path: &str,
+ expected_hyperlink_path: &str,
+ config: &Config,
+ ) {
+ let link_text = "link text";
+ assert_eq!(
+ format_osc8_hyperlink(
+ &PathBuf::from(expected_hyperlink_path).to_string_lossy(),
+ link_text
+ ),
+ format_osc8_file_hyperlink(relative_path, None, link_text, config)
+ )
+ }
- #[test]
- #[cfg(not(target_os = "windows"))]
- fn test_relative_path_file_hyperlink_when_not_child_process_of_git() {
- // The current process is not a child process of git.
- // Delta receives a file path 'a'.
- // The hyperlink should be $cwd/a.
- let mut config = integration_test_utils::make_config_from_args(&[
- "--hyperlinks",
- "--hyperlinks-file-link-format",
- "{path}",
- ]);
- config.cwd_of_user_shell_process = Some(PathBuf::from("/some/cwd"));
- assert_file_hyperlink_matches("a", "/some/cwd/a", &config)
- }
+ #[test]
+ fn test_relative_path_file_hyperlink_when_not_child_process_of_git() {
+ // The current process is not a child process of git.
+ // Delta receives a file path 'a'.
+ // The hyperlink should be $cwd/a.
+ let mut config = integration_test_utils::make_config_from_args(&[
+ "--hyperlinks",
+ "--hyperlinks-file-link-format",
+ "{path}",
+ ]);
+ config.cwd_of_user_shell_process = Some(PathBuf::from("/some/cwd"));
+ assert_file_hyperlink_matches("a", "/some/cwd/a", &config)
+ }
- #[test]
- #[cfg(not(target_os = "windows"))]
- fn test_relative_path_file_hyperlink_when_child_process_of_git() {
- // The current process is a child process of git.
- // Delta receives a file path 'a'.
- // We are in directory b/ relative to the repo root.
- // The hyperlink should be $repo_root/b/a.
- let mut config = integration_test_utils::make_config_from_args(&[
- "--hyperlinks",
- "--hyperlinks-file-link-format",
- "{path}",
- ]);
- config.cwd_of_user_shell_process = Some(PathBuf::from("/some/repo-root/b"));
- assert_file_hyperlink_matches("a", "/some/repo-root/b/a", &config)
+ #[test]
+ fn test_relative_path_file_hyperlink_when_child_process_of_git() {
+ // The current process is a child process of git.
+ // Delta receives a file path 'a'.
+ // We are in directory b/ relative to the repo root.
+ // The hyperlink should be $repo_root/b/a.
+ let mut config = integration_test_utils::make_config_from_args(&[
+ "--hyperlinks",
+ "--hyperlinks-file-link-format",
+ "{path}",
+ ]);
+ config.cwd_of_user_shell_process = Some(PathBuf::from("/some/repo-root/b"));
+ assert_file_hyperlink_matches("a", "/some/repo-root/b/a", &config)
+ }
}
}
diff --git a/src/handlers/hunk_header.rs b/src/handlers/hunk_header.rs
index 53cfbacb..b52ba5b4 100644
--- a/src/handlers/hunk_header.rs
+++ b/src/handlers/hunk_header.rs
@@ -314,8 +314,6 @@ fn write_to_output_buffer(
#[cfg(test)]
pub mod tests {
- use std::path::PathBuf;
-
use super::*;
use crate::ansi::strip_ansi_codes;
use crate::tests::integration_test_utils;
@@ -412,7 +410,8 @@ pub mod tests {
let mut config =
integration_test_utils::make_config_from_args(&["--features", "hyperlinks"]);
- config.cwd_of_user_shell_process = Some(PathBuf::from("/some/current/directory"));
+ config.cwd_of_user_shell_process =
+ Some(std::path::PathBuf::from("/some/current/directory"));
let result = paint_file_path_with_line_number(Some(3), "some-file", &config);