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

0.37.18 #1165

Merged
merged 1 commit into from
Sep 29, 2024
Merged

0.37.18 #1165

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### v0.37.18

* Enhancement: config to disable all installation steps #1147

### v0.37.17 (2024-09-28)

* Fix: support encrypted drives (shorten script file names) #1150
Expand Down
13 changes: 13 additions & 0 deletions examples/install_disabled.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

[config]
skip_core_tasks = true
disable_install = true

[tasks.alt-command-example1]
install_crate = { install_command = "custom-install" }
command = "cargo"
args = ["somecrate"]

[tasks.alt-command-example2]
install_crate = { crate_name = "somecrate", install_command = "custom-install" }

6 changes: 6 additions & 0 deletions src/lib/installer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ pub(crate) fn install(
flow_info: &FlowInfo,
flow_state: Rc<RefCell<FlowState>>,
) -> Result<(), CargoMakeError> {
if let Some(disable_install) = flow_info.config.config.disable_install {
if disable_install {
return Ok(());
}
}

let validate = !task_config.should_ignore_errors();

let toolchain = task_config.toolchain.clone();
Expand Down
14 changes: 14 additions & 0 deletions src/lib/installer/mod_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ fn install_empty_args() {
.unwrap();
}

#[test]
fn install_disabled() {
let mut task = Task::new();
task.install_crate = Some(InstallCrate::Value("test".to_string()));
task.command = Some("cargo".to_string());
task.args = Some(vec![]);

let mut flow_info = test::create_empty_flow_info();
flow_info.config.config.disable_install = Some(true);

// this should throw but since we disabled installation, we just return
install(&task, &flow_info, Rc::new(RefCell::new(FlowState::new()))).unwrap();
}

#[test]
fn install_enabled_crate_already_installed() {
let mut task = Task::new();
Expand Down
6 changes: 6 additions & 0 deletions src/lib/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,8 @@ pub struct ConfigSection {
pub time_summary: Option<bool>,
/// Automatically load cargo aliases as cargo-make tasks
pub load_cargo_aliases: Option<bool>,
/// If true (default false) disable all automatic/defined installation instructions
pub disable_install: Option<bool>,
/// The project information member (used by workspaces)
pub main_project_member: Option<String>,
/// Invoked while loading the descriptor file but before loading any extended descriptor
Expand Down Expand Up @@ -2294,6 +2296,10 @@ impl ConfigSection {
self.load_cargo_aliases = extended.load_cargo_aliases.clone();
}

if extended.disable_install.is_some() {
self.disable_install = extended.disable_install.clone();
}

if extended.main_project_member.is_some() {
self.main_project_member = extended.main_project_member.clone();
}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/types_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3899,6 +3899,7 @@ fn config_section_new() {
assert!(config.reduce_output.is_none());
assert!(config.time_summary.is_none());
assert!(config.load_cargo_aliases.is_none());
assert!(config.disable_install.is_none());
assert!(config.main_project_member.is_none());
assert!(config.load_script.is_none());
assert!(config.linux_load_script.is_none());
Expand Down Expand Up @@ -3929,6 +3930,7 @@ fn config_section_extend_all_values() {
base.reduce_output = Some(true);
base.time_summary = Some(true);
base.load_cargo_aliases = Some(true);
base.disable_install = Some(true);
base.load_script = Some(ScriptValue::Text(vec!["base_info".to_string()]));
base.linux_load_script = Some(ScriptValue::Text(vec![
"linux".to_string(),
Expand Down Expand Up @@ -3962,6 +3964,7 @@ fn config_section_extend_all_values() {
extended.reduce_output = Some(false);
extended.time_summary = Some(false);
extended.load_cargo_aliases = Some(false);
extended.disable_install = Some(false);
extended.load_script = Some(ScriptValue::Text(vec![
"extended_info".to_string(),
"arg2".to_string(),
Expand Down Expand Up @@ -3995,6 +3998,7 @@ fn config_section_extend_all_values() {
assert!(!base.reduce_output.unwrap());
assert!(!base.time_summary.unwrap());
assert!(!base.load_cargo_aliases.unwrap());
assert!(!base.disable_install.unwrap());
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 1);
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 1);
Expand Down Expand Up @@ -4024,6 +4028,7 @@ fn config_section_extend_no_values() {
base.reduce_output = Some(true);
base.time_summary = Some(true);
base.load_cargo_aliases = Some(true);
base.disable_install = Some(true);
base.load_script = Some(ScriptValue::Text(vec![
"base_info".to_string(),
"arg2".to_string(),
Expand Down Expand Up @@ -4066,6 +4071,7 @@ fn config_section_extend_no_values() {
assert!(base.reduce_output.unwrap());
assert!(base.time_summary.unwrap());
assert!(base.load_cargo_aliases.unwrap());
assert!(base.disable_install.unwrap());
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 2);
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 2);
Expand Down Expand Up @@ -4095,6 +4101,7 @@ fn config_section_extend_some_values() {
base.reduce_output = Some(true);
base.time_summary = Some(true);
base.load_cargo_aliases = Some(true);
base.disable_install = Some(true);
base.load_script = Some(ScriptValue::Text(vec![
"base_info".to_string(),
"arg2".to_string(),
Expand Down Expand Up @@ -4140,6 +4147,7 @@ fn config_section_extend_some_values() {
assert!(base.reduce_output.unwrap());
assert!(base.time_summary.unwrap());
assert!(base.load_cargo_aliases.unwrap());
assert!(base.disable_install.unwrap());
assert_eq!(get_script_as_vec(base.load_script).len(), 2);
assert_eq!(get_script_as_vec(base.linux_load_script).len(), 2);
assert_eq!(get_script_as_vec(base.windows_load_script).len(), 2);
Expand Down