add do_not_cache method and update the warning on as_command_mut

This commit is contained in:
bit-aloo
2025-06-24 19:56:31 +05:30
parent 08d7b29719
commit 5291c9fcec
+9 -3
View File
@@ -101,6 +101,11 @@ pub fn should_cache(&self) -> bool {
self.should_cache
}
pub fn cache_never(&mut self) -> &mut Self {
self.should_cache = false;
self
}
pub fn args<I, S>(&mut self, args: I) -> &mut Self
where
I: IntoIterator<Item = S>,
@@ -203,10 +208,11 @@ pub fn start_capture_stdout(
/// Provides access to the stdlib Command inside.
/// FIXME: This function should be eventually removed from bootstrap.
pub fn as_command_mut(&mut self) -> &mut Command {
// We don't know what will happen with the returned command, so we need to mark this
// command as executed proactively.
// We proactively mark this command as executed since we can't be certain how the returned
// command will be handled. Caching must also be avoided here, as the inner command could be
// modified externally without us being aware.
self.mark_as_executed();
self.should_cache = false;
self.cache_never();
&mut self.command
}