forked from dgrijalva/gitx
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathPBWebDiffController.m
60 lines (46 loc) · 1.39 KB
/
PBWebDiffController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// PBWebDiffController.m
// GitX
//
// Created by Pieter de Bie on 13-10-08.
// Copyright 2008 Pieter de Bie. All rights reserved.
//
#import "PBWebDiffController.h"
@implementation PBWebDiffController
- (void) awakeFromNib
{
startFile = @"diff";
[super awakeFromNib];
[diffController addObserver:self forKeyPath:@"diff" options:0 context:@"ChangedDiff"];
}
- (void)closeView
{
[diffController removeObserver:self forKeyPath:@"diff"];
[super closeView];
}
- (void) didLoad
{
[self showDiff:diffController.diff];
}
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([(__bridge NSString *)context isEqualToString: @"ChangedDiff"])
[self showDiff:diffController.diff];
}
- (void) showDiff: (NSString *) diff
{
if (diff == nil || !finishedLoading)
return;
id script = [view windowScriptObject];
if ([diff length] == 0)
[script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObject:@"There are no differences"]];
else
[script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:diff]];
}
// TODO: need to be refactoring
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
{
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,file,nil];
[repository handleInWorkDirForArguments:args];
}
@end