Skip to content

Commit 30552d8

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 5e1de04 commit 30552d8

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
@@ -673,13 +673,8 @@ fn template_workspace_path_hash_should_handle_symlink() {
673673
let symlink_hash_dir = parse_workspace_manifest_path_hash(&foo_dir);
674674
verify_layouts(&p, &symlink_hash_dir);
675675

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

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

0 commit comments

Comments
 (0)