@@ -51,6 +51,7 @@ - (void)awakeFromNib
51
51
historyViewController = [[PBGitHistoryController alloc ] initWithRepository: repository superController: superController];
52
52
commitViewController = [[PBGitCommitController alloc ] initWithRepository: repository superController: superController];
53
53
54
+ [repository addObserver: self forKeyPath: @" refs" options: 0 context: @" updateRefs" ];
54
55
[repository addObserver: self forKeyPath: @" currentBranch" options: 0 context: @" currentBranchChange" ];
55
56
[repository addObserver: self forKeyPath: @" branches" options: (NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context: @" branchesModified" ];
56
57
@@ -79,9 +80,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
79
80
[sourceView reloadData ];
80
81
[self selectCurrentBranch ];
81
82
return ;
82
- }
83
-
84
- if ([@" branchesModified" isEqualToString: context]) {
83
+ }else if ([@" branchesModified" isEqualToString: context]) {
85
84
NSInteger changeKind = [(NSNumber *)[change objectForKey: NSKeyValueChangeKindKey ] intValue ];
86
85
87
86
if (changeKind == NSKeyValueChangeInsertion) {
@@ -97,10 +96,22 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
97
96
for (PBGitRevSpecifier *rev in removedRevSpecs)
98
97
[self removeRevSpec: rev];
99
98
}
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];
101
106
}
107
+ }
102
108
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 ));
104
115
}
105
116
106
117
- (PBSourceViewItem *) selectedItem
@@ -231,6 +242,11 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCe
231
242
cell.behind =nil ;
232
243
cell.ahead =nil ;
233
244
}
245
+
246
+ if ([item isKindOfClass: [PBGitSVRemoteItem class ]]){
247
+ NSLog (@" title: %@ " ,[item title ]);
248
+ cell.isCheckedOut =[item alert ];
249
+ }
234
250
[cell setImage: [item icon ]];
235
251
}
236
252
0 commit comments