Skip to content

Commit

Permalink
Merge branch 'rust-lang:master' into fix-metadata-not-retriggering-bu…
Browse files Browse the repository at this point in the history
…ilds
  • Loading branch information
ranger-ross authored Dec 24, 2024
2 parents d999267 + 0c157e0 commit 3c3901f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 50 deletions.
99 changes: 61 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ filetime = "0.2.23"
flate2 = { version = "1.0.30", default-features = false, features = ["zlib"] }
git2 = "0.19.0"
git2-curl = "0.20.0"
gix = { version = "0.68.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] }
gix = { version = "0.69.1", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] }
glob = "0.3.1"
handlebars = { version = "6.0.0", features = ["dir_source"] }
hex = "0.4.3"
Expand Down
19 changes: 10 additions & 9 deletions src/cargo/core/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ impl SourceId {
url == CRATES_IO_INDEX || url == CRATES_IO_HTTP_INDEX || is_overridden_crates_io_url(url)
}

/// Hashes `self`.
/// Hashes `self` to be used in the name of some Cargo folders, so shouldn't vary.
///
/// For git and url, `as_str` gives the serialisation of a url (which has a spec) and so
/// insulates against possible changes in how the url crate does hashing.
///
/// For paths, remove the workspace prefix so the same source will give the
/// same hash in different locations, helping reproducible builds.
Expand All @@ -550,7 +553,11 @@ impl SourceId {
return;
}
}
self.hash(into)
self.inner.kind.hash(into);
match self.inner.kind {
SourceKind::Git(_) => (&self).inner.canonical_url.hash(into),
_ => (&self).inner.url.as_str().hash(into),
}
}

pub fn full_eq(self, other: SourceId) -> bool {
Expand Down Expand Up @@ -665,16 +672,10 @@ impl fmt::Display for SourceId {
}
}

/// The hash of `SourceId` is used in the name of some Cargo folders, so shouldn't
/// vary. `as_str` gives the serialisation of a url (which has a spec) and so
/// insulates against possible changes in how the url crate does hashing.
impl Hash for SourceId {
fn hash<S: hash::Hasher>(&self, into: &mut S) {
self.inner.kind.hash(into);
match self.inner.kind {
SourceKind::Git(_) => self.inner.canonical_url.hash(into),
_ => self.inner.url.as_str().hash(into),
}
self.inner.canonical_url.hash(into);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/sources/git/oxide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub fn cargo_config_to_gitoxide_overrides(gctx: &GlobalContext) -> CargoResult<V
}

/// Reinitializes a given Git repository. This is useful when a Git repository
/// seems corrupted and we want to start over.
/// seems corrupted, and we want to start over.
pub fn reinitialize(git_dir: &Path) -> CargoResult<()> {
fn init(path: &Path, bare: bool) -> CargoResult<()> {
let mut opts = git2::RepositoryInitOptions::new();
Expand Down
4 changes: 3 additions & 1 deletion src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,9 @@ pub fn fetch(
fn has_shallow_lock_file(err: &crate::sources::git::fetch::Error) -> bool {
matches!(
err,
gix::env::collate::fetch::Error::Fetch(gix::remote::fetch::Error::LockShallowFile(_))
gix::env::collate::fetch::Error::Fetch(gix::remote::fetch::Error::Fetch(
gix::protocol::fetch::Error::LockShallowFile(_)
))
)
}

Expand Down

0 comments on commit 3c3901f

Please sign in to comment.