eh: eliminated unnecessary string allocations in retry
Some checks are pending
Rust / build (push) Waiting to run
Some checks are pending
Rust / build (push) Waiting to run
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I50f693ec70719a2e23c7f355be3d2c446a6a6964
This commit is contained in:
parent
c3321858c4
commit
7498902d46
2 changed files with 14 additions and 11 deletions
|
|
@ -63,6 +63,11 @@ impl NixCommand {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn args_ref(mut self, args: &[String]) -> Self {
|
||||||
|
self.args.extend(args.iter().cloned());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn env<K: Into<String>, V: Into<String>>(
|
pub fn env<K: Into<String>, V: Into<String>>(
|
||||||
mut self,
|
mut self,
|
||||||
key: K,
|
key: K,
|
||||||
|
|
|
||||||
|
|
@ -174,13 +174,11 @@ pub fn handle_nix_with_retry(
|
||||||
|
|
||||||
// For run commands, try interactive first to avoid breaking terminal
|
// For run commands, try interactive first to avoid breaking terminal
|
||||||
if subcommand == "run" && interactive {
|
if subcommand == "run" && interactive {
|
||||||
let mut cmd = NixCommand::new(subcommand)
|
let status = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.interactive(true);
|
.interactive(true)
|
||||||
for arg in args {
|
.args_ref(args)
|
||||||
cmd = cmd.arg(arg);
|
.run_with_logs(StdIoInterceptor)?;
|
||||||
}
|
|
||||||
let status = cmd.run_with_logs(StdIoInterceptor)?;
|
|
||||||
if status.success() {
|
if status.success() {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +187,7 @@ pub fn handle_nix_with_retry(
|
||||||
// First, always capture output to check for errors that need retry
|
// First, always capture output to check for errors that need retry
|
||||||
let output_cmd = NixCommand::new(subcommand)
|
let output_cmd = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.args(args.iter().cloned());
|
.args_ref(args);
|
||||||
let output = output_cmd.output()?;
|
let output = output_cmd.output()?;
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
|
|
||||||
|
|
@ -200,7 +198,7 @@ pub fn handle_nix_with_retry(
|
||||||
info!("{}", Paint::green("✔ Fixed hash mismatch, retrying..."));
|
info!("{}", Paint::green("✔ Fixed hash mismatch, retrying..."));
|
||||||
let mut retry_cmd = NixCommand::new(subcommand)
|
let mut retry_cmd = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.args(args.iter().cloned());
|
.args_ref(args);
|
||||||
if interactive {
|
if interactive {
|
||||||
retry_cmd = retry_cmd.interactive(true);
|
retry_cmd = retry_cmd.interactive(true);
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +232,7 @@ pub fn handle_nix_with_retry(
|
||||||
);
|
);
|
||||||
let mut retry_cmd = NixCommand::new(subcommand)
|
let mut retry_cmd = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.args(args.iter().cloned())
|
.args_ref(args)
|
||||||
.env("NIXPKGS_ALLOW_UNFREE", "1")
|
.env("NIXPKGS_ALLOW_UNFREE", "1")
|
||||||
.impure(true);
|
.impure(true);
|
||||||
if interactive {
|
if interactive {
|
||||||
|
|
@ -255,7 +253,7 @@ pub fn handle_nix_with_retry(
|
||||||
);
|
);
|
||||||
let mut retry_cmd = NixCommand::new(subcommand)
|
let mut retry_cmd = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.args(args.iter().cloned())
|
.args_ref(args)
|
||||||
.env("NIXPKGS_ALLOW_INSECURE", "1")
|
.env("NIXPKGS_ALLOW_INSECURE", "1")
|
||||||
.impure(true);
|
.impure(true);
|
||||||
if interactive {
|
if interactive {
|
||||||
|
|
@ -275,7 +273,7 @@ pub fn handle_nix_with_retry(
|
||||||
);
|
);
|
||||||
let mut retry_cmd = NixCommand::new(subcommand)
|
let mut retry_cmd = NixCommand::new(subcommand)
|
||||||
.print_build_logs(true)
|
.print_build_logs(true)
|
||||||
.args(args.iter().cloned())
|
.args_ref(args)
|
||||||
.env("NIXPKGS_ALLOW_BROKEN", "1")
|
.env("NIXPKGS_ALLOW_BROKEN", "1")
|
||||||
.impure(true);
|
.impure(true);
|
||||||
if interactive {
|
if interactive {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue