Skip to content

Commit 5053393

Browse files
committed
feat(build-dir): Resolve symlinks before hashing workspace-path-hash
This commit resolves symlinks in the manifest path before hashing it.
1 parent dc0d113 commit 5053393

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/cargo/util/context/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ impl GlobalContext {
672672
.to_string(),
673673
),
674674
("{workspace-path-hash}", {
675-
let hash = crate::util::hex::short_hash(&workspace_manifest_path);
675+
let real_path = std::fs::canonicalize(workspace_manifest_path)?;
676+
let hash = crate::util::hex::short_hash(&real_path);
676677
format!("{}{}{}", &hash[0..2], std::path::MAIN_SEPARATOR, &hash[2..])
677678
}),
678679
];

tests/testsuite/build_dir.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,8 @@ fn template_workspace_path_hash_should_handle_symlink() {
674674
let symlink_hash_dir = parse_workspace_manifest_path_hash(&foo_dir);
675675
verify_layouts(&p, &symlink_hash_dir);
676676

677-
// Verify the current behavior:
678-
// unix: hash dir created from the symlinked and non-symlinked dirs are the same.
679-
#[cfg(unix)]
677+
// Verify the hash dir created from the symlinked and non-symlinked dirs are the same.
680678
assert_eq!(original_hash_dir, symlink_hash_dir);
681-
// windows: hash dir created from the symlinked and non-symlinked dirs are different.
682-
#[cfg(windows)]
683-
assert_ne!(original_hash_dir, symlink_hash_dir);
684679

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

0 commit comments

Comments
 (0)