Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Making the path determination a bit more reliable.

  • Loading branch information...
commit 5157b4a1ce2a3b3ebbe426d81b8f47e070986e4e 1 parent b549b63
Andrew Wooster authored July 09, 2011
6  .git-gps
... ...
@@ -1,7 +1,7 @@
1 1
 {
2  
-    "latitude":45.782119,
3  
-    "longitude":-108.505189,
  2
+    "latitude":45.782069,
  3
+    "longitude":-108.505118,
4 4
     "altitude":0.000000,
5  
-    "horizontalAccuracy":157.000000,
  5
+    "horizontalAccuracy":167.000000,
6 6
     "verticalAccuracy":-1.000000
7 7
 }
35  git-gps/source/GGGitTool.m
@@ -61,6 +61,16 @@ - (NSString *)determineGitPath {
61 61
     NSString *path = [self runTaskAndGatherOutput:task];
62 62
     [task release], task = nil;
63 63
     path = [path stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  64
+    
  65
+    NSFileManager *fm = [NSFileManager defaultManager];
  66
+    NSArray *paths = [NSArray arrayWithObjects:path, @"/usr/bin/git", @"/usr/local/bin/git", nil];
  67
+    for (NSString *tmpPath in paths) {
  68
+        if ([fm isExecutableFileAtPath:tmpPath]) {
  69
+            path = tmpPath;
  70
+            break;
  71
+        }
  72
+    }
  73
+    
64 74
     return path;
65 75
 }
66 76
 
@@ -76,13 +86,26 @@ - (NSString *)runTaskAndGatherOutput:(NSTask *)task {
76 86
 }
77 87
 
78 88
 - (NSString *)runGitCommandAndGatherOutput:(NSArray *)arguments {
  89
+    NSString *result = nil;
  90
+    
79 91
     NSTask *task = [[NSTask alloc] init];
80  
-    [task setLaunchPath:gitPath];
81  
-    [task setArguments:arguments];
82  
-    NSString *result = [self runTaskAndGatherOutput:task];
83  
-    result = [result stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
84  
-    terminationStatus = [task terminationStatus];
85  
-    [task release], task = nil;
  92
+    
  93
+    @try {
  94
+        [task setLaunchPath:gitPath];
  95
+        [task setArguments:arguments];
  96
+        result = [self runTaskAndGatherOutput:task];
  97
+        result = [result stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  98
+        terminationStatus = [task terminationStatus];
  99
+    }
  100
+    @catch (NSException * e) {
  101
+        NSLog(@"Exception running task: %@", e);
  102
+        NSLog(@"git path was: '%@'", gitPath);
  103
+        NSLog(@"arguments were: %@", arguments);
  104
+        @throw(e);
  105
+    }
  106
+    @finally {
  107
+        [task release], task = nil;
  108
+    }
86 109
     return result;
87 110
 }
88 111
 @end

0 notes on commit 5157b4a

Please sign in to comment.
Something went wrong with that request. Please try again.