Skip to content

Commit 2ad624f

Browse files
Seth Raphaelbrotherbard
Seth Raphael
authored andcommitted
Follow Commit-msg hook rules: allow it to edit the commit message, before committing.
1 parent 969ff24 commit 2ad624f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

PBGitIndex.m

+10-7
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ - (void)commitWithMessage:(NSString *)commitMessage
175175

176176
[self postCommitUpdate:@"Creating commit"];
177177
int ret = 1;
178-
NSString *commit = [repository outputForArguments:arguments
179-
inputString:commitMessage
180-
byExtendingEnvironment:amendEnvironment
181-
retValue: &ret];
182-
183-
if (ret || [commit length] != 40)
184-
return [self postCommitFailure:@"Could not create a commit object"];
185178

186179
[self postCommitUpdate:@"Running hooks"];
187180
if (![repository executeHook:@"pre-commit" output:nil])
@@ -190,6 +183,16 @@ - (void)commitWithMessage:(NSString *)commitMessage
190183
if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil])
191184
return [self postCommitFailure:@"Commit-msg hook failed"];
192185

186+
commitMessage = [NSString stringWithContentsOfFile:commitMessageFile encoding:NSUTF8StringEncoding error:nil];
187+
188+
NSString *commit = [repository outputForArguments:arguments
189+
inputString:commitMessage
190+
byExtendingEnvironment:amendEnvironment
191+
retValue: &ret];
192+
193+
if (ret || [commit length] != 40)
194+
return [self postCommitFailure:@"Could not create a commit object"];
195+
193196
[self postCommitUpdate:@"Updating HEAD"];
194197
[repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-m", commitSubject, @"HEAD", commit, nil]
195198
retValue: &ret];

0 commit comments

Comments
 (0)