Skip to content

Commit

Permalink
Hash paths relative to the workspace into metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Dec 18, 2024
1 parent 6c9c4bc commit c51e36a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/cargo/core/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,17 +534,12 @@ impl SourceId {

/// Hashes `self`.
///
/// For paths, remove the workspace prefix so the same source will give the
/// For paths, make it relative to the workspace root so the same source will give the
/// same hash in different locations, helping reproducible builds.
pub fn stable_hash<S: hash::Hasher>(self, workspace: &Path, into: &mut S) {
if self.is_path() {
if let Ok(p) = self
.inner
.url
.to_file_path()
.unwrap()
.strip_prefix(workspace)
{
let path = self.inner.url.to_file_path().unwrap();
if let Some(p) = pathdiff::diff_paths(path, workspace) {
self.inner.kind.hash(into);
p.to_str().unwrap().hash(into);
return;
Expand Down

0 comments on commit c51e36a

Please sign in to comment.