Skip to content

Commit

Permalink
GitIndex: Add a few notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Sep 13, 2009
1 parent cdae809 commit ff263c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions PBGitIndex.h
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions PBGitIndex.m
Expand Up @@ -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;
Expand Down Expand Up @@ -316,10 +323,16 @@ - (void)indexRefreshFinished:(NSNotification *)notification
{
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];

Expand Down Expand Up @@ -529,7 +542,8 @@ - (void)indexStepComplete
[self didChangeValueForKey:@"indexChanges"];
}

// TODO: Sent index refresh finished operation
[[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexFinishedIndexRefresh
object:self];
}

@end

0 comments on commit ff263c6

Please sign in to comment.