diff options
| author | Jakub Beránek <jakub.beranek@vsb.cz> | 2024-07-03 11:33:43 +0200 |
|---|---|---|
| committer | Jakub Beránek <jakub.beranek@vsb.cz> | 2024-07-03 21:13:55 +0200 |
| commit | b90129dd21edb7492c7c4fc58883e849be8deff7 (patch) | |
| tree | 040bcea253c56d154624b1f7ea0e41d8654215b0 /src/bootstrap | |
| parent | 70b6e044523b0a2bc89b748a389c04277b5b9da1 (diff) | |
| download | rust-b90129dd21edb7492c7c4fc58883e849be8deff7.tar.gz rust-b90129dd21edb7492c7c4fc58883e849be8deff7.zip | |
Review changes
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/utils/exec.rs | 27 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/helpers.rs | 9 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 98d194e64d3..74fb483773e 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -34,8 +34,7 @@ pub enum OutputMode { /// If you want to allow failures, use [allow_failure]. /// If you want to delay failures until the end of bootstrap, use [delay_failure]. /// -/// By default, the command will print its stdout/stderr to stdout/stderr of bootstrap -/// ([OutputMode::Print]). +/// By default, the command will print its stdout/stderr to stdout/stderr of bootstrap ([OutputMode::Print]). /// If you want to handle the output programmatically, use [BootstrapCommand::capture]. /// /// Bootstrap will print a debug log to stdout if the command fails and failure is not allowed. @@ -144,8 +143,8 @@ impl From<Command> for BootstrapCommand { } } -/// Represents the outcome of starting a command. -enum CommandOutcome { +/// Represents the current status of `BootstrapCommand`. +enum CommandStatus { /// The command has started and finished with some status. Finished(ExitStatus), /// It was not even possible to start the command. @@ -155,20 +154,20 @@ enum CommandOutcome { /// Represents the output of an executed process. #[allow(unused)] pub struct CommandOutput { - outcome: CommandOutcome, + status: CommandStatus, stdout: Vec<u8>, stderr: Vec<u8>, } impl CommandOutput { pub fn did_not_start() -> Self { - Self { outcome: CommandOutcome::DidNotStart, stdout: vec![], stderr: vec![] } + Self { status: CommandStatus::DidNotStart, stdout: vec![], stderr: vec![] } } pub fn is_success(&self) -> bool { - match self.outcome { - CommandOutcome::Finished(status) => status.success(), - CommandOutcome::DidNotStart => false, + match self.status { + CommandStatus::Finished(status) => status.success(), + CommandStatus::DidNotStart => false, } } @@ -177,9 +176,9 @@ impl CommandOutput { } pub fn status(&self) -> Option<ExitStatus> { - match self.outcome { - CommandOutcome::Finished(status) => Some(status), - CommandOutcome::DidNotStart => None, + match self.status { + CommandStatus::Finished(status) => Some(status), + CommandStatus::DidNotStart => None, } } @@ -199,7 +198,7 @@ impl CommandOutput { impl Default for CommandOutput { fn default() -> Self { Self { - outcome: CommandOutcome::Finished(ExitStatus::default()), + status: CommandStatus::Finished(ExitStatus::default()), stdout: vec![], stderr: vec![], } @@ -209,7 +208,7 @@ impl Default for CommandOutput { impl From<Output> for CommandOutput { fn from(output: Output) -> Self { Self { - outcome: CommandOutcome::Finished(output.status), + status: CommandStatus::Finished(output.status), stdout: output.stdout, stderr: output.stderr, } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index bbd4185874f..2575b7939b4 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -494,12 +494,13 @@ pub fn check_cfg_arg(name: &str, values: Option<&[&str]>) -> String { format!("--check-cfg=cfg({name}{next})") } -/// Prepares `Command` that runs git inside the source directory if given. +/// Prepares `BootstrapCommand` that runs git inside the source directory if given. /// /// Whenever a git invocation is needed, this function should be preferred over -/// manually building a git `Command`. This approach allows us to manage bootstrap-specific -/// needs/hacks from a single source, rather than applying them on next to every `Command::new("git")`, -/// which is painful to ensure that the required change is applied on each one of them correctly. +/// manually building a git `BootstrapCommand`. This approach allows us to manage +/// bootstrap-specific needs/hacks from a single source, rather than applying them on next to every +/// `BootstrapCommand::new("git")`, which is painful to ensure that the required change is applied +/// on each one of them correctly. pub fn git(source_dir: Option<&Path>) -> BootstrapCommand { let mut git = BootstrapCommand::new("git"); |
