1616NSString *PBGitIndexIndexRefreshStatus = @" PBGitIndexIndexRefreshStatus" ;
1717NSString *PBGitIndexIndexRefreshFailed = @" PBGitIndexIndexRefreshFailed" ;
1818NSString *PBGitIndexFinishedIndexRefresh = @" PBGitIndexFinishedIndexRefresh" ;
19+
20+ NSString *PBGitIndexCommitStatus = @" PBGitIndexCommitStatus" ;
1921NSString *PBGitIndexCommitFailed = @" PBGitIndexCommitFailed" ;
2022NSString *PBGitIndexFinishedCommit = @" PBGitIndexFinishedCommit" ;
2123
@@ -40,6 +42,7 @@ @interface PBGitIndex ()
4042// Returns the tree to compare the index to, based
4143// on whether amend is set or not.
4244- (NSString *) parentTree ;
45+ - (void )postCommitUpdate : (NSString *)update ;
4346
4447@end
4548
@@ -138,8 +141,9 @@ - (void)commitWithMessage:(NSString *)commitMessage
138141 commitMessageFile = [repository.fileURL.path stringByAppendingPathComponent: @" COMMIT_EDITMSG" ];
139142
140143 [commitMessage writeToFile: commitMessageFile atomically: YES encoding: NSUTF8StringEncoding error: nil ];
144+
141145
142- // TODO: Notification: @"Creating tree.." ;
146+ [ self postCommitUpdate: @" Creating tree" ] ;
143147 NSString *tree = [repository outputForCommand: @" write-tree" ];
144148 if ([tree length ] != 40 )
145149 return ; // TODO: commitFailedBecause:@"Could not create a tree";
@@ -152,6 +156,7 @@ - (void)commitWithMessage:(NSString *)commitMessage
152156 [arguments addObject: parent];
153157 }
154158
159+ [self postCommitUpdate: @" Creating commit" ];
155160 int ret = 1 ;
156161 NSString *commit = [repository outputForArguments: arguments
157162 inputString: commitMessage
@@ -161,23 +166,38 @@ - (void)commitWithMessage:(NSString *)commitMessage
161166 if (ret || [commit length ] != 40 )
162167 return ; // TODO: [self commitFailedBecause:@"Could not create a commit object"];
163168
169+ [self postCommitUpdate: @" Running hooks" ];
164170 if (![repository executeHook: @" pre-commit" output: nil ])
165171 return ; // TODO: [self commitFailedBecause:@"Pre-commit hook failed"];
166172
167173 if (![repository executeHook: @" commit-msg" withArgs: [NSArray arrayWithObject: commitMessageFile] output: nil ])
168174 return ; // TODO: [self commitFailedBecause:@"Commit-msg hook failed"];
169175
176+ [self postCommitUpdate: @" Updating HEAD" ];
170177 [repository outputForArguments: [NSArray arrayWithObjects: @" update-ref" , @" -m" , commitSubject, @" HEAD" , commit, nil ]
171178 retValue: &ret];
172179 if (ret)
173180 return ; // TODO: [self commitFailedBecause:@"Could not update HEAD"];
174181
175- if (![repository executeHook: @" post-commit" output: nil ])
176- return ; // [webController setStateMessage:[NSString stringWithFormat:@"Post-commit hook failed, however, successfully created commit %@", commit]];
182+ [self postCommitUpdate: @" Running post-commit hook" ];
183+
184+ BOOL success = [repository executeHook: @" post-commit" output: nil ];
185+ NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject: [NSNumber numberWithBool: success] forKey: @" success" ];
186+ NSString *description;
187+ if (success)
188+ description = [NSString stringWithFormat: @" Successfull created commit %@ " , commit];
177189 else
178- // [webController setStateMessage:[NSString stringWithFormat:@"Successfully created commit %@", commit]];
179- ;
190+ description = [NSString stringWithFormat: @" Post-commit hook failed, but successfully created commit %@ " , commit];
180191
192+ [userInfo setObject: description forKey: @" description" ];
193+ [userInfo setObject: commit forKey: @" sha" ];
194+
195+ [[NSNotificationCenter defaultCenter ] postNotificationName: PBGitIndexFinishedCommit
196+ object: self
197+ userInfo: userInfo];
198+ if (!success)
199+ return ;
200+
181201 repository.hasChanged = YES ;
182202
183203 amendEnvironment = nil ;
@@ -188,6 +208,13 @@ - (void)commitWithMessage:(NSString *)commitMessage
188208
189209}
190210
211+ - (void )postCommitUpdate : (NSString *)update
212+ {
213+ [[NSNotificationCenter defaultCenter ] postNotificationName: PBGitIndexCommitStatus
214+ object: self
215+ userInfo: [NSDictionary dictionaryWithObject: update forKey: @" description" ]];
216+ }
217+
191218- (BOOL )stageFiles : (NSArray *)stageFiles
192219{
193220 // Input string for update-index
0 commit comments