Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash paths relative to the workspace into metadata. #14953

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
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
Loading