Skip to content

Commit ed83316

Browse files
committed
Also display output of commit-msg hook
1 parent 8637a21 commit ed83316

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

PBGitIndex.m

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,23 @@ - (void)commitWithMessage:(NSString *)commitMessage
177177
int ret = 1;
178178

179179
[self postCommitUpdate:@"Running hooks"];
180-
NSString *preCommitHookOutput = nil;
181-
if (![repository executeHook:@"pre-commit" output:&preCommitHookOutput]) {
182-
NSString *preCommitFailureMessage = [NSString stringWithFormat:@"Pre-commit hook failed%@%@",
183-
[preCommitHookOutput length] > 0 ? @":\n" : @"",
184-
preCommitHookOutput];
185-
return [self postCommitFailure:preCommitFailureMessage];
180+
NSString *hookFailureMessage = nil;
181+
NSString *hookOutput = nil;
182+
if (![repository executeHook:@"pre-commit" output:&hookOutput]) {
183+
hookFailureMessage = [NSString stringWithFormat:@"Pre-commit hook failed%@%@",
184+
[hookOutput length] > 0 ? @":\n" : @"",
185+
hookOutput];
186186
}
187187

188-
if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil])
189-
return [self postCommitFailure:@"Commit-msg hook failed"];
188+
if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil]) {
189+
hookFailureMessage = [NSString stringWithFormat:@"Commit-msg hook failed%@%@",
190+
[hookOutput length] > 0 ? @":\n" : @"",
191+
hookOutput];
192+
}
193+
194+
if (hookFailureMessage != nil) {
195+
return [self postCommitFailure:hookFailureMessage];
196+
}
190197

191198
commitMessage = [NSString stringWithContentsOfFile:commitMessageFile encoding:NSUTF8StringEncoding error:nil];
192199

0 commit comments

Comments
 (0)