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

Default to manifest 17 #99

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ zip = { version = "0.6", default-features = false, features = ["deflate"] }
[dev-dependencies]
insta = "1.12"
walkdir = "2.3"

[profile.dev.package.insta]
opt-level = 3

[profile.dev.package.similar]
opt-level = 3

[profile.dev.package.sha2]
opt-level = 3
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct Args {
#[arg(long, conflicts_with_all = &["manifest_version", "channel"])]
manifest: Option<PathBuf>,
/// The manifest version to retrieve
#[arg(long, default_value = "16")]
#[arg(long, default_value = "17")]
manifest_version: String,
/// The product channel to use.
#[arg(long, default_value = "release")]
Expand Down
39 changes: 28 additions & 11 deletions src/splat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ pub(crate) fn finalize_splat(
) -> Result<(), Error> {
let mut files: std::collections::HashMap<
_,
_,
Header<'_>,
std::hash::BuildHasherDefault<twox_hash::XxHash64>,
> = Default::default();

Expand All @@ -627,18 +627,35 @@ pub(crate) fn finalize_splat(
path: PathBuf,
}

fn compare_hashes(existing: &Path, new: &PathBuf) -> anyhow::Result<()> {
use crate::util::Sha256;

let existing_hash = Sha256::digest(&std::fs::read(existing)?);
let new_hash = Sha256::digest(&std::fs::read(new)?);

anyhow::ensure!(
existing_hash == new_hash,
"2 files with same relative path were not equal: '{existing}' != '{new}'"
);

Ok(())
}

for hdrs in &sdk_headers {
for (k, v) in &hdrs.inner {
let existing = files.insert(
k,
Header {
root: hdrs,
path: v.clone(),
},
);

if let Some(existing) = existing {
panic!("already have {} matching {v}", existing.path);
if let Some(existing) = files.get(k) {
// We already have a file with the same path, if they're the same
// as each other it's fine, but if they differ we have an issue
compare_hashes(&existing.path, v)?;
tracing::debug!("skipped {v}, a matching path already exists");
} else {
files.insert(
k,
Header {
root: hdrs,
path: v.clone(),
},
);
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion tests/compiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ fn verify_compiles() {

let hidden = indicatif::ProgressBar::hidden();

let manifest = xwin::manifest::get_manifest(&ctx, "16", "release", hidden.clone()).unwrap();
// TODO: Bump to CI to 17 once github actions isn't using an ancient version,
// we could install in the action run, but not really worth it since I can
// test locally
let manifest_version = if std::env::var_os("CI").is_some() {
"16"
} else {
"17"
};

let manifest =
xwin::manifest::get_manifest(&ctx, manifest_version, "release", hidden.clone()).unwrap();
let pkg_manifest =
xwin::manifest::get_package_manifest(&ctx, &manifest, hidden.clone()).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/xwin.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Options:
--manifest-version <MANIFEST_VERSION>
The manifest version to retrieve

[default: 16]
[default: 17]

--channel <CHANNEL>
The product channel to use
Expand Down