Skip to content

Commit 0151598

Browse files
committed
(inital) display if remotes need a fetch
1 parent 0253054 commit 0151598

4 files changed

+27
-6
lines changed

PBGitSVRemoteItem.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212

1313
@interface PBGitSVRemoteItem : PBSourceViewItem {
14-
14+
BOOL alert;
1515
}
1616

17+
@property (assign) BOOL alert;
18+
1719
+ (id)remoteItemWithTitle:(NSString *)title;
1820

1921
@end

PBGitSVRemoteItem.m

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@implementation PBGitSVRemoteItem
1414

15+
@synthesize alert;
1516

1617
+ (id)remoteItemWithTitle:(NSString *)title
1718
{

PBGitSidebarController.h

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
- (void)setHistorySearch:(NSString *)searchString mode:(NSInteger)mode;
4242

43+
-(bool)remoteNeedFetch:(NSString *)remote;
44+
4345
@property(readonly) NSMutableArray *items;
4446
@property(readonly) NSView *sourceListControlsView;
4547
@property(readonly) PBGitHistoryController *historyViewController;

PBGitSidebarController.m

+21-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ - (void)awakeFromNib
5151
historyViewController = [[PBGitHistoryController alloc] initWithRepository:repository superController:superController];
5252
commitViewController = [[PBGitCommitController alloc] initWithRepository:repository superController:superController];
5353

54+
[repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"];
5455
[repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"currentBranchChange"];
5556
[repository addObserver:self forKeyPath:@"branches" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:@"branchesModified"];
5657

@@ -79,9 +80,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
7980
[sourceView reloadData];
8081
[self selectCurrentBranch];
8182
return;
82-
}
83-
84-
if ([@"branchesModified" isEqualToString:context]) {
83+
}else if ([@"branchesModified" isEqualToString:context]) {
8584
NSInteger changeKind = [(NSNumber *)[change objectForKey:NSKeyValueChangeKindKey] intValue];
8685

8786
if (changeKind == NSKeyValueChangeInsertion) {
@@ -97,10 +96,22 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
9796
for (PBGitRevSpecifier *rev in removedRevSpecs)
9897
[self removeRevSpec:rev];
9998
}
100-
return;
99+
}else if ([@"updateRefs" isEqualToString:context]) {
100+
for(PBGitSVRemoteItem* remote in [remotes children]){
101+
NSLog(@"remote.title=%@",[remote title]);
102+
[remote setAlert:[self remoteNeedFetch:[remote title]]];
103+
}
104+
}else{
105+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
101106
}
107+
}
102108

103-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
109+
-(bool)remoteNeedFetch:(NSString *)remote
110+
{
111+
int ret;
112+
NSArray *args = [NSArray arrayWithObjects:@"fetch", @"--dry-run", remote, nil];
113+
NSString *o = [repository outputForArguments:args retValue:&ret];
114+
return ((ret==0) && ([o length]!=0));
104115
}
105116

106117
- (PBSourceViewItem *) selectedItem
@@ -231,6 +242,11 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCe
231242
cell.behind=nil;
232243
cell.ahead=nil;
233244
}
245+
246+
if([item isKindOfClass:[PBGitSVRemoteItem class]]){
247+
NSLog(@"title: %@",[item title]);
248+
cell.isCheckedOut=[item alert];
249+
}
234250
[cell setImage:[item icon]];
235251
}
236252

0 commit comments

Comments
 (0)