@@ -307,21 +307,27 @@ - (void)commitWithMessage:(NSString *)commitMessage andVerify:(BOOL) doVerify
307
307
if (doVerify) {
308
308
[self postCommitUpdate: @" Running hooks" ];
309
309
NSString *hookFailureMessage = nil ;
310
- NSString *hookOutput = nil ;
311
- if (![self .repository executeHook: @" pre-commit" output: &hookOutput]) {
310
+ NSError *error = nil ;
311
+ BOOL success = [self .repository executeHook: @" pre-commit" error: &error];
312
+ if (!success) {
313
+ NSError *taskError = error.userInfo [NSUnderlyingErrorKey ];
314
+ NSString *hookOutput = taskError.userInfo [PBTaskTerminationOutputKey];
312
315
hookFailureMessage = [NSString stringWithFormat: @" Pre-commit hook failed%@%@ " ,
313
- [hookOutput length ] > 0 ? @" :\n " : @" " ,
314
- hookOutput];
316
+ hookOutput && [hookOutput length ] > 0 ? @" :\n " : @" " ,
317
+ hookOutput];
318
+ [self postCommitHookFailure: hookFailureMessage];
319
+ return ;
315
320
}
316
321
317
- if (![self .repository executeHook: @" commit-msg" withArgs: [NSArray arrayWithObject: commitMessageFile] output: nil ]) {
322
+ success = [self .repository executeHook: @" commit-msg" arguments: @[commitMessageFile] error: &error];
323
+ if (!success) {
324
+ NSError *taskError = error.userInfo [NSUnderlyingErrorKey ];
325
+ NSString *hookOutput = taskError.userInfo [PBTaskTerminationOutputKey];
318
326
hookFailureMessage = [NSString stringWithFormat: @" Commit-msg hook failed%@%@ " ,
319
- [hookOutput length ] > 0 ? @" :\n " : @" " ,
320
- hookOutput];
321
- }
322
-
323
- if (hookFailureMessage != nil ) {
324
- return [self postCommitHookFailure: hookFailureMessage];
327
+ hookOutput && [hookOutput length ] > 0 ? @" :\n " : @" " ,
328
+ hookOutput];
329
+ [self postCommitHookFailure: hookFailureMessage];
330
+ return ;
325
331
}
326
332
}
327
333
@@ -343,7 +349,7 @@ - (void)commitWithMessage:(NSString *)commitMessage andVerify:(BOOL) doVerify
343
349
344
350
[self postCommitUpdate: @" Running post-commit hook" ];
345
351
346
- BOOL success = [self .repository executeHook: @" post-commit" output: nil ];
352
+ BOOL success = [self .repository executeHook: @" post-commit" error: NULL ];
347
353
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject: [NSNumber numberWithBool: success] forKey: @" success" ];
348
354
NSString *description;
349
355
if (success)
0 commit comments