Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (62 sloc) 2.399 kB
0bb4cbc @ciaran Adding a basic command-line tool to interface with the application th…
ciaran authored
1 //
7bf3043 @d0k Don't compile plain ObjC files as ObjC++
d0k authored
2 // PBCLIProxy.m
0bb4cbc @ciaran Adding a basic command-line tool to interface with the application th…
ciaran authored
3 // GitX
4 //
5 // Created by Ciarán Walsh on 15/08/2008.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "PBCLIProxy.h"
4547d51 @ciaran Amend the CLI tool to use the distributed objects system to try openi…
ciaran authored
10 #import "PBRepositoryDocumentController.h"
3c7a22e @pieter Let the gitx CLI use our RevSpecification
authored
11 #import "PBGitRevSpecifier.h"
86606ef @pieter Add a --commit option to the CLI client
authored
12 #import "PBGitRepository.h"
13 #import "PBGitWindowController.h"
59e3a18 @pieter cli-tool: Hint at another error if there is a git binary
authored
14 #import "PBGitBinary.h"
e8131c3 @pieter Add a diff window
authored
15 #import "PBDiffWindowController.h"
0bb4cbc @ciaran Adding a basic command-line tool to interface with the application th…
ciaran authored
16
17 @implementation PBCLIProxy
18 @synthesize connection;
19
20 - (id)init
21 {
22 if (self = [super init]) {
23 self.connection = [NSConnection new];
24 [self.connection setRootObject:self];
25
26 if ([self.connection registerName:ConnectionName] == NO)
27 NSBeep();
28
29 }
30 return self;
31 }
4547d51 @ciaran Amend the CLI tool to use the distributed objects system to try openi…
ciaran authored
32
5ceb62a @pieter CLI: allow passing of command line arguments
authored
33 - (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
4547d51 @ciaran Amend the CLI tool to use the distributed objects system to try openi…
ciaran authored
34 {
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]];
42e8196 @pieter Pass on arguments from the command line to the revwalk mechanism
authored
39 NSArray* arguments = [NSArray arrayWithArray:args];
86606ef @pieter Add a --commit option to the CLI client
authored
40
41 PBGitRepository *document = [[PBRepositoryDocumentController sharedDocumentController] documentForLocation:url];
8c96979 @pieter Better handle the cases when a Git binary can't be found
authored
42 if (!document) {
43 if (error) {
59e3a18 @pieter cli-tool: Hint at another error if there is a git binary
authored
44 NSString *suggestion = [PBGitBinary path] ? @"this isn't a git repository" : @"GitX can't find your git binary";
45
46 NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Could not create document. Perhaps %@", suggestion]
47 forKey:NSLocalizedFailureReasonErrorKey];
48
8c96979 @pieter Better handle the cases when a Git binary can't be found
authored
49 *error = [NSError errorWithDomain:PBGitRepositoryErrorDomain code:2 userInfo:userInfo];
50 }
86606ef @pieter Add a --commit option to the CLI client
authored
51 return NO;
8c96979 @pieter Better handle the cases when a Git binary can't be found
authored
52 }
7bf3043 @d0k Don't compile plain ObjC files as ObjC++
d0k authored
53
86606ef @pieter Add a --commit option to the CLI client
authored
54 if ([arguments count] > 0 && ([[arguments objectAtIndex:0] isEqualToString:@"--commit"] ||
55 [[arguments objectAtIndex:0] isEqualToString:@"-c"]))
c12e8b9 @d0k Get rid of some unnecessary casts
d0k authored
56 [document.windowController showCommitView:self];
86606ef @pieter Add a --commit option to the CLI client
authored
57 else {
58 PBGitRevSpecifier* rev = [[PBGitRevSpecifier alloc] initWithParameters:arguments];
d597452 @pieter CLIProxy: pass on the directory in which the `gitx` command is run
authored
59 rev.workingDirectory = repositoryPath;
a62e14f @pieter HistoryView: Remove the BranchController
authored
60 document.currentBranch = [document addBranch: rev];
c12e8b9 @d0k Get rid of some unnecessary casts
d0k authored
61 [document.windowController showHistoryView:self];
4547d51 @ciaran Amend the CLI tool to use the distributed objects system to try openi…
ciaran authored
62 }
86606ef @pieter Add a --commit option to the CLI client
authored
63 [NSApp activateIgnoringOtherApps:YES];
64
65 return YES;
4547d51 @ciaran Amend the CLI tool to use the distributed objects system to try openi…
ciaran authored
66 }
e8131c3 @pieter Add a diff window
authored
67
68 - (void)openDiffWindowWithDiff:(NSString *)diff
69 {
70 PBDiffWindowController *diffController = [[PBDiffWindowController alloc] initWithDiff:[diff copy]];
71 [diffController showWindow:nil];
72 [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
73 }
0bb4cbc @ciaran Adding a basic command-line tool to interface with the application th…
ciaran authored
74 @end
Something went wrong with that request. Please try again.