From ed833164d92fdd069c11272087ecbfce80c41584 Mon Sep 17 00:00:00 2001 From: Sebastian Staudt Date: Sun, 12 Sep 2010 14:30:11 +0200 Subject: [PATCH] Also display output of commit-msg hook --- PBGitIndex.m | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/PBGitIndex.m b/PBGitIndex.m index 87c7aa6..d39ce25 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -177,16 +177,23 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; int ret = 1; [self postCommitUpdate:@"Running hooks"]; - NSString *preCommitHookOutput = nil; - if (![repository executeHook:@"pre-commit" output:&preCommitHookOutput]) { - NSString *preCommitFailureMessage = [NSString stringWithFormat:@"Pre-commit hook failed%@%@", - [preCommitHookOutput length] > 0 ? @":\n" : @"", - preCommitHookOutput]; - return [self postCommitFailure:preCommitFailureMessage]; + NSString *hookFailureMessage = nil; + NSString *hookOutput = nil; + if (![repository executeHook:@"pre-commit" output:&hookOutput]) { + hookFailureMessage = [NSString stringWithFormat:@"Pre-commit hook failed%@%@", + [hookOutput length] > 0 ? @":\n" : @"", + hookOutput]; } - if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil]) - return [self postCommitFailure:@"Commit-msg hook failed"]; + if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil]) { + hookFailureMessage = [NSString stringWithFormat:@"Commit-msg hook failed%@%@", + [hookOutput length] > 0 ? @":\n" : @"", + hookOutput]; + } + + if (hookFailureMessage != nil) { + return [self postCommitFailure:hookFailureMessage]; + } commitMessage = [NSString stringWithContentsOfFile:commitMessageFile encoding:NSUTF8StringEncoding error:nil];