@@ -347,10 +347,7 @@ def run_command_class(self, cls, cmd, warn_only=False, **kwargs):
347
347
return build_cmd
348
348
349
349
350
- class LocalEnvironment (BaseEnvironment ):
351
-
352
- # TODO: BuildCommand name doesn't make sense here, should be just Command
353
- command_class = BuildCommand
350
+ class PostCommandRecordMixin (object ):
354
351
355
352
def post_run_command (self ):
356
353
command = self .commands [- 1 ]
@@ -359,6 +356,12 @@ def post_run_command(self):
359
356
if self .record :
360
357
command .save ()
361
358
359
+
360
+ class LocalEnvironment (BaseEnvironment , PostCommandRecordMixin ):
361
+
362
+ # TODO: BuildCommand name doesn't make sense here, should be just Command
363
+ command_class = BuildCommand
364
+
362
365
def run (self , * cmd , ** kwargs ):
363
366
self .record = kwargs .pop ('record' , False )
364
367
self .record_as_success = kwargs .pop ('record_as_success' , False )
@@ -381,7 +384,7 @@ def run_command_class(self, *cmd, **kwargs): # noqa
381
384
return super (LocalEnvironment , self ).run_command_class (* cmd , ** kwargs )
382
385
383
386
384
- class BuildEnvironment (BaseEnvironment ):
387
+ class BuildEnvironment (BaseEnvironment , PostCommandRecordMixin ):
385
388
386
389
"""
387
390
Base build environment.
@@ -459,13 +462,6 @@ def handle_exception(self, exc_type, exc_value, _):
459
462
self .failure = exc_value
460
463
return True
461
464
462
- def post_run_command (self ):
463
- command = self .commands [- 1 ]
464
- if self .record_as_success :
465
- command .exit_code = 0
466
- if self .record :
467
- command .save ()
468
-
469
465
def run (self , * cmd , ** kwargs ):
470
466
kwargs .update ({
471
467
'build_env' : self ,
0 commit comments