File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,24 @@ impl ExecutionContext {
146146 stdout : OutputMode ,
147147 stderr : OutputMode ,
148148 ) -> CommandOutput {
149- self . start ( command, stdout, stderr) . wait_for_output ( self )
149+ let cache_key = command. cache_key ( ) ;
150+
151+ if let Some ( cached_output) = self . command_cache . get ( & cache_key) {
152+ command. mark_as_executed ( ) ;
153+ if self . dry_run ( ) && !command. run_always {
154+ return CommandOutput :: default ( ) ;
155+ }
156+ self . verbose ( || println ! ( "Cache hit: {:?}" , command) ) ;
157+ return cached_output;
158+ }
159+
160+ let output = self . start ( command, stdout, stderr) . wait_for_output ( self ) ;
161+
162+ if output != CommandOutput :: default ( ) {
163+ self . command_cache . insert ( cache_key, output. clone ( ) ) ;
164+ }
165+
166+ output
150167 }
151168
152169 fn fail ( & self , message : & str , output : CommandOutput ) -> ! {
You can’t perform that action at this time.
0 commit comments