Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(build-dir): Resolve symlinks before hashing workspace-path-hash
This commit resolves symlinks in the manifest path before hashing it.
  • Loading branch information
ranger-ross committed Apr 8, 2025
commit 50533934d0c73b86750c2a7ac76e154f00b99e9a
3 changes: 2 additions & 1 deletion src/cargo/util/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ impl GlobalContext {
.to_string(),
),
("{workspace-path-hash}", {
let hash = crate::util::hex::short_hash(&workspace_manifest_path);
let real_path = std::fs::canonicalize(workspace_manifest_path)?;
let hash = crate::util::hex::short_hash(&real_path);
format!("{}{}{}", &hash[0..2], std::path::MAIN_SEPARATOR, &hash[2..])
}),
];
Expand Down
7 changes: 1 addition & 6 deletions tests/testsuite/build_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,8 @@ fn template_workspace_path_hash_should_handle_symlink() {
let symlink_hash_dir = parse_workspace_manifest_path_hash(&foo_dir);
verify_layouts(&p, &symlink_hash_dir);

// Verify the current behavior:
// unix: hash dir created from the symlinked and non-symlinked dirs are the same.
#[cfg(unix)]
// Verify the hash dir created from the symlinked and non-symlinked dirs are the same.
assert_eq!(original_hash_dir, symlink_hash_dir);
// windows: hash dir created from the symlinked and non-symlinked dirs are different.
#[cfg(windows)]
assert_ne!(original_hash_dir, symlink_hash_dir);

fn verify_layouts(p: &Project, build_dir_parent: &PathBuf) {
let build_dir = build_dir_parent.as_path().join("build-dir");
Expand Down