Skip to content

Conversation

@mickgmdb
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings December 17, 2025 07:51
@mickgmdb mickgmdb merged commit 860adb2 into main Dec 17, 2025
4 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes test failures on Windows by conditionally disabling tests that rely on Unix-specific functionality. The changes also replace a temporary file creation mechanism with a more explicit path generation using UUIDs.

Key Changes:

  • Added #[cfg(not(windows))] attributes to 9 test functions to skip them on Windows
  • Replaced NamedTempFile with explicit UUID-based temp path generation in decompress.rs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/pre_commit_installer.rs Added Windows exclusion directives to 9 test functions that likely depend on Unix-specific Git hook behavior
src/decompress.rs Replaced NamedTempFile with custom UUID-based temporary path generation and added uuid import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +275 to +280
std::env::temp_dir().join(format!(
"kingfisher-{}-{}-{}",
std::process::id(),
Uuid::new_v4(),
extension
))
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated temporary path is created but the file is never actually created on the filesystem. Unlike NamedTempFile::new().unwrap().into_temp_path() which creates the file, this only returns a path. This could lead to race conditions where multiple processes generate the same path, or the path might conflict with existing files. Consider using std::fs::File::create() after generating the path, or use tempfile::Builder::new().suffix(extension).tempfile() to maintain atomic file creation.

Suggested change
std::env::temp_dir().join(format!(
"kingfisher-{}-{}-{}",
std::process::id(),
Uuid::new_v4(),
extension
))
let path = std::env::temp_dir().join(format!(
"kingfisher-{}-{}-{}",
std::process::id(),
Uuid::new_v4(),
extension
));
// Best-effort creation of the temporary file to avoid race conditions.
let _ = fs::File::create(&path);
path
Copilot uses AI. Check for mistakes.
Comment on lines +275 to +280
std::env::temp_dir().join(format!(
"kingfisher-{}-{}-{}",
std::process::id(),
Uuid::new_v4(),
extension
))
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension is appended directly to the UUID without a dot separator, resulting in paths like /tmp/kingfisher-1234-uuid-tar instead of /tmp/kingfisher-1234-uuid.tar. If extension is expected to be a file extension, it should be prefixed with a dot or use .with_extension() method instead of string concatenation.

Suggested change
std::env::temp_dir().join(format!(
"kingfisher-{}-{}-{}",
std::process::id(),
Uuid::new_v4(),
extension
))
std::env::temp_dir()
.join(format!(
"kingfisher-{}-{}",
std::process::id(),
Uuid::new_v4(),
))
.with_extension(extension)
Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants