@@ -72,6 +72,14 @@ class PatchApplyError(KasUserError):
72
72
"""
73
73
The provided patch file could not be applied
74
74
"""
75
+ def __init__ (self , msg , cmd = None , out = None , err = None ):
76
+ if cmd :
77
+ msg += '\n vcs command: ' + ' ' .join (cmd )
78
+ if out and out .strip ():
79
+ msg += f'\n vcs output:\n { out .strip ()} '
80
+ if err and err .strip ():
81
+ msg += f'\n vcs error:\n { err .strip ()} '
82
+ super ().__init__ (msg )
75
83
76
84
77
85
class Repo :
@@ -500,24 +508,24 @@ async def apply_patches_async(self):
500
508
501
509
for (path , patch_id ) in my_patches :
502
510
cmd = self .apply_patches_file_cmd (path )
503
- (retc , output ) = await run_cmd_async (
504
- cmd , cwd = self .path , fail = False )
511
+ (retc , out , err ) = await run_cmd_async (
512
+ cmd , cwd = self .path , fail = False , capture_stderr = True )
505
513
if retc :
506
514
raise PatchApplyError (
507
- 'Could not apply patch. Please fix repos and patches. '
508
- f'( patch path: { path } , repo: { self .name } , patch '
509
- f'entry: { patch_id } , vcs output: { output } )' )
515
+ 'Could not apply patch. Please fix repos and patches: \n '
516
+ f'patch path: { path } , repo: { self .name } , patch '
517
+ f'entry: { patch_id } ' , cmd , out , err )
510
518
511
519
logging .info ('Patch applied. '
512
520
'(patch path: %s, repo: %s, patch entry: %s)' ,
513
521
path , self .name , patch_id )
514
522
515
523
cmd = self .add_cmd ()
516
- (retc , output ) = await run_cmd_async (
517
- cmd , cwd = self .path , fail = False )
524
+ (retc , out , err ) = await run_cmd_async (
525
+ cmd , cwd = self .path , fail = False , capture_stderr = True )
518
526
if retc :
519
- raise PatchApplyError ('Could not add patched files. repo: '
520
- f'{ self .name } , vcs output: { output } )' )
527
+ raise PatchApplyError ('Could not add patched files: repo: '
528
+ f'{ self .name } ' , cmd , out , err )
521
529
522
530
timestamp = self .get_patch_timestamp (path )
523
531
if not timestamp :
@@ -529,11 +537,11 @@ async def apply_patches_async(self):
529
537
msg = f'kas: { patch_id } \n \n patch { path } applied by kas'
530
538
cmd = self .
commit_cmd (
env ,
'kas <[email protected] >' ,
msg ,
531
539
timestamp )
532
- (retc , output ) = await run_cmd_async (
533
- cmd , cwd = self .path , env = env , fail = False )
540
+ (retc , out , err ) = await run_cmd_async (
541
+ cmd , cwd = self .path , env = env , fail = False , capture_stderr = True )
534
542
if retc :
535
543
raise PatchApplyError ('Could not commit patch changes. repo: '
536
- f'{ self .name } , vcs output: { output } )' )
544
+ f'{ self .name } ' , cmd , out , err )
537
545
538
546
return 0
539
547
0 commit comments