From ff263c6717cc3cf13f26669ff923634157b8873c Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Sun, 13 Sep 2009 03:20:12 +0200 Subject: [PATCH] GitIndex: Add a few notifications --- PBGitIndex.h | 6 ++++++ PBGitIndex.m | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/PBGitIndex.h b/PBGitIndex.h index a358f5a..7dd0e93 100644 --- a/PBGitIndex.h +++ b/PBGitIndex.h @@ -11,6 +11,12 @@ @class PBGitRepository; @class PBChangedFile; +extern NSString *PBGitIndexIndexRefreshStatus; +extern NSString *PBGitIndexIndexRefreshFailed; +extern NSString *PBGitIndexFinishedIndexRefresh; +extern NSString *PBGitIndexCommitFailed; +extern NSString *PBGitIndexFinishedCommit; + // Represents a git index for a given work tree. // As a single git repository can have multiple trees, // the tree has to be given explicitly, even though diff --git a/PBGitIndex.m b/PBGitIndex.m index 717ceff..2ce84ab 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -13,6 +13,13 @@ #import "NSString_RegEx.h" #import "PBChangedFile.h" +NSString *PBGitIndexIndexRefreshStatus = @"PBGitIndexIndexRefreshStatus"; +NSString *PBGitIndexIndexRefreshFailed = @"PBGitIndexIndexRefreshFailed"; +NSString *PBGitIndexFinishedIndexRefresh = @"PBGitIndexFinishedIndexRefresh"; +NSString *PBGitIndexCommitFailed = @"PBGitIndexCommitFailed"; +NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit"; + + @interface PBGitIndex (IndexRefreshMethods) - (NSArray *)linesFromNotification:(NSNotification *)notification; @@ -316,10 +323,16 @@ { if ([(NSNumber *)[(NSDictionary *)[notification userInfo] objectForKey:@"NSFileHandleError"] intValue]) { - // TODO: send updatefailed notification? + [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexIndexRefreshFailed + object:self + userInfo:[NSDictionary dictionaryWithObject:@"update-index failed" forKey:@"description"]]; return; } + [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexIndexRefreshStatus + object:self + userInfo:[NSDictionary dictionaryWithObject:@"update-index success" forKey:@"description"]]; + // Now that the index is refreshed, we need to read the information from the index NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -529,7 +542,8 @@ [self didChangeValueForKey:@"indexChanges"]; } - // TODO: Sent index refresh finished operation + [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexFinishedIndexRefresh + object:self]; } @end