5 // Created by CiarĂ¡n Walsh on 15/08/2008.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
10 #import "PBRepositoryDocumentController.h"
11 #import "PBGitRevSpecifier.h"
12 #import "PBGitRepository.h"
13 #import "PBGitWindowController.h"
14 #import "PBGitBinary.h"
15 #import "PBDiffWindowController.h"
17 @implementation PBCLIProxy
18 @synthesize connection;
22 if (self = [super init]) {
23 self.connection = [NSConnection new];
24 [self.connection setRootObject:self];
26 if ([self.connection registerName:ConnectionName] == NO)
33 - (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
35 // FIXME I found that creating this redundant NSURL reference was necessary to
36 // work around an apparent bug with GC and Distributed Objects
37 // I am not familiar with GC though, so perhaps I was doing something wrong.
38 NSURL* url = [NSURL fileURLWithPath:[repositoryPath path]];
39 NSArray* arguments = [NSArray arrayWithArray:args];
41 PBGitRepository *document = [[PBRepositoryDocumentController sharedDocumentController] documentForLocation:url];
44 NSString *suggestion = [PBGitBinary path] ? @"this isn't a git repository" : @"GitX can't find your git binary";
46 NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Could not create document. Perhaps %@", suggestion]
47 forKey:NSLocalizedFailureReasonErrorKey];
49 *error = [NSError errorWithDomain:PBGitRepositoryErrorDomain code:2 userInfo:userInfo];
54 if ([arguments count] > 0 && ([[arguments objectAtIndex:0] isEqualToString:@"--commit"] ||
55 [[arguments objectAtIndex:0] isEqualToString:@"-c"]))
56 [document.windowController showCommitView:self];
58 PBGitRevSpecifier* rev = [[PBGitRevSpecifier alloc] initWithParameters:arguments];
59 rev.workingDirectory = repositoryPath;
60 document.currentBranch = [document addBranch: rev];
61 [document.windowController showHistoryView:self];
63 [NSApp activateIgnoringOtherApps:YES];
68 - (void)openDiffWindowWithDiff:(NSString *)diff
70 PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]];
71 [diffController showWindow:nil];
72 [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];