mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add failed commit notifications
This commit is contained in:
+12
-12
@@ -18,6 +18,7 @@
|
||||
- (void)refreshFinished:(NSNotification *)notification;
|
||||
- (void)commitStatusUpdated:(NSNotification *)notification;
|
||||
- (void)commitFinished:(NSNotification *)notification;
|
||||
- (void)commitFailed:(NSNotification *)notification;
|
||||
@end
|
||||
|
||||
@implementation PBGitCommitController
|
||||
@@ -35,6 +36,7 @@
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshFinished:) name:PBGitIndexFinishedIndexRefresh object:index];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitStatusUpdated:) name:PBGitIndexCommitStatus object:index];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFinished:) name:PBGitIndexFinishedCommit object:index];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFailed:) name:PBGitIndexCommitFailed object:index];
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -95,14 +97,6 @@
|
||||
[self refresh:nil];
|
||||
}
|
||||
|
||||
- (void) commitFailedBecause:(NSString *)reason
|
||||
{
|
||||
//self.busy--;
|
||||
self.status = [@"Commit failed: " stringByAppendingString:reason];
|
||||
[[repository windowController] showMessageSheet:@"Commit failed" infoText:reason];
|
||||
return;
|
||||
}
|
||||
|
||||
- (IBAction) commit:(id) sender
|
||||
{
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:[repository.fileURL.path stringByAppendingPathComponent:@"MERGE_HEAD"]]) {
|
||||
@@ -145,10 +139,16 @@
|
||||
- (void)commitFinished:(NSNotification *)notification
|
||||
{
|
||||
[webController setStateMessage:[NSString stringWithFormat:[[notification userInfo] objectForKey:@"description"]]];
|
||||
|
||||
BOOL success = [[[notification userInfo] objectForKey:@"success"] boolValue];
|
||||
if (success)
|
||||
[commitMessageView setString:@""];
|
||||
[commitMessageView setEditable:YES];
|
||||
}
|
||||
|
||||
- (void)commitFailed:(NSNotification *)notification
|
||||
{
|
||||
self.busy = NO;
|
||||
NSString *reason = [[notification userInfo] objectForKey:@"description"];
|
||||
self.status = [@"Commit failed: " stringByAppendingString:reason];
|
||||
[[repository windowController] showMessageSheet:@"Commit failed" infoText:reason];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
+14
-6
@@ -43,7 +43,7 @@ NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit";
|
||||
// on whether amend is set or not.
|
||||
- (NSString *) parentTree;
|
||||
- (void)postCommitUpdate:(NSString *)update;
|
||||
|
||||
- (void)postCommitFailure:(NSString *)reason;
|
||||
@end
|
||||
|
||||
@implementation PBGitIndex
|
||||
@@ -146,7 +146,7 @@ NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit";
|
||||
[self postCommitUpdate:@"Creating tree"];
|
||||
NSString *tree = [repository outputForCommand:@"write-tree"];
|
||||
if ([tree length] != 40)
|
||||
return; //TODO: commitFailedBecause:@"Could not create a tree";
|
||||
return [self postCommitFailure:@"Creating tree failed"];
|
||||
|
||||
|
||||
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"commit-tree", tree, nil];
|
||||
@@ -164,20 +164,20 @@ NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit";
|
||||
retValue: &ret];
|
||||
|
||||
if (ret || [commit length] != 40)
|
||||
return; // TODO: [self commitFailedBecause:@"Could not create a commit object"];
|
||||
return [self postCommitFailure:@"Could not create a commit object"];
|
||||
|
||||
[self postCommitUpdate:@"Running hooks"];
|
||||
if (![repository executeHook:@"pre-commit" output:nil])
|
||||
return; // TODO: [self commitFailedBecause:@"Pre-commit hook failed"];
|
||||
return [self postCommitFailure:@"Pre-commit hook failed"];
|
||||
|
||||
if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil])
|
||||
return; // TODO: [self commitFailedBecause:@"Commit-msg hook failed"];
|
||||
return [self postCommitFailure:@"Commit-msg hook failed"];
|
||||
|
||||
[self postCommitUpdate:@"Updating HEAD"];
|
||||
[repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-m", commitSubject, @"HEAD", commit, nil]
|
||||
retValue: &ret];
|
||||
if (ret)
|
||||
return; // TODO: [self commitFailedBecause:@"Could not update HEAD"];
|
||||
return [self postCommitFailure:@"Could not update HEAD"];
|
||||
|
||||
[self postCommitUpdate:@"Running post-commit hook"];
|
||||
|
||||
@@ -215,6 +215,14 @@ NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit";
|
||||
userInfo:[NSDictionary dictionaryWithObject:update forKey:@"description"]];
|
||||
}
|
||||
|
||||
- (void)postCommitFailure:(NSString *)reason
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexCommitFailed
|
||||
object:self
|
||||
userInfo:[NSDictionary dictionaryWithObject:reason forKey:@"description"]];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)stageFiles:(NSArray *)stageFiles
|
||||
{
|
||||
// Input string for update-index
|
||||
|
||||
Reference in New Issue
Block a user