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

Fix: --strategies on CLI do not seem to override disabled-strategies in the manifest #1857

Merged
merged 21 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
3 changes: 0 additions & 3 deletions crates/bin/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,6 @@ You cannot use --{option} and specify multiple packages at the same time. Do one
.error(ErrorKind::TooFewValues, "You have disabled all strategies")
.exit()
}

// Free disable_strategies as it will not be used again.
opts.disable_strategies = Vec::new();
}

// Ensure that Strategy::Compile is specified as the last strategy
Expand Down
8 changes: 7 additions & 1 deletion crates/bin/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ pub fn install_crates(
pkg_url: args.pkg_url,
pkg_fmt: args.pkg_fmt,
bin_dir: args.bin_dir,
disabled_strategies: None,
disabled_strategies: (!args.disable_strategies.is_empty()).then(|| {
args.disable_strategies
.into_iter()
.map(|strategy| strategy.0)
.collect::<Vec<_>>()
.into_boxed_slice()
}),
signing: None,
};

Expand Down
13 changes: 13 additions & 0 deletions e2e-tests/manifests/strategies-test-override-Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "cargo-quickinstall"
repository = "https://github.com/cargo-bins/cargo-quickinstall"
version = "0.2.10"

[[bin]]
name = "cargo-quickinstall"
path = "src/main.rs"
test = false
doc = false

[package.metadata.binstall]
disabled-strategies = ["crate-meta-data", "quick-install", "compile"]
5 changes: 4 additions & 1 deletion e2e-tests/strategies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi
## Test compile-only strategy
"./$1" binstall --no-confirm --strategies compile [email protected]

## Test --disable-strategies
## Test Cargo.toml disable-strategies
set +e

"./$1" binstall --no-confirm --manifest-path "manifests/strategies-test-Cargo.toml" [email protected]
Expand All @@ -49,3 +49,6 @@ if [ "$exit_code" != 94 ]; then
echo "Expected exit code 94, but actual exit code $exit_code"
exit 1
fi

NobodyXu marked this conversation as resolved.
Show resolved Hide resolved
## Test --strategies overriding `disabled-strategies=["compile"]` in Cargo.toml
"./$1" binstall --no-confirm --manifest-path "manifests/strategies-test-override-Cargo.toml" --strategies compile [email protected]
NobodyXu marked this conversation as resolved.
Show resolved Hide resolved
Loading