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 document.currentBranch = [document addBranch: rev];
60 [document.windowController showHistoryView:self];
62 [NSApp activateIgnoringOtherApps:YES];
67 - (void)openDiffWindowWithDiff:(NSString *)diff
69 PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]];
70 [diffController showWindow:nil];
71 [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];