Skip to content

Commit 51dc761

Browse files
committed
First cut.
1 parent b08294b commit 51dc761

File tree

6 files changed

+437
-0
lines changed

6 files changed

+437
-0
lines changed

LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2011, Andrew Wooster.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of git-gps, nor the
12+
names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL Andrew Wooster BE LIABLE FOR ANY
19+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# git-gps
2+
3+
A set of functionality to track commits in a git repository by GPS
4+
coordinates.
5+
6+
Currently only works on OS X.

git-gps/git-gps.1

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2+
.\"See Also:
3+
.\"man mdoc.samples for a complete listing of options
4+
.\"man mdoc for the short list of editing options
5+
.\"/usr/share/misc/mdoc.template
6+
.Dd 7/2/11 \" DATE
7+
.Dt git-gps 1 \" Program name and manual section number
8+
.Os Darwin
9+
.Sh NAME \" Section Header - required - don't modify
10+
.Nm git-gps,
11+
.\" The following lines are read in generating the apropos(man -k) database. Use only key
12+
.\" words here as the database is built based on the words here and in the .ND line.
13+
.Nm Other_name_for_same_program(),
14+
.Nm Yet another name for the same program.
15+
.\" Use .Nm macro to designate other names for the documented program.
16+
.Nd This line parsed for whatis database.
17+
.Sh SYNOPSIS \" Section Header - required - don't modify
18+
.Nm
19+
.Op Fl abcd \" [-abcd]
20+
.Op Fl a Ar path \" [-a path]
21+
.Op Ar file \" [file]
22+
.Op Ar \" [file ...]
23+
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24+
arg2 ... \" Arguments
25+
.Sh DESCRIPTION \" Section Header - required - don't modify
26+
Use the .Nm macro to refer to your program throughout the man page like such:
27+
.Nm
28+
Underlining is accomplished with the .Ar macro like this:
29+
.Ar underlined text .
30+
.Pp \" Inserts a space
31+
A list of items with descriptions:
32+
.Bl -tag -width -indent \" Begins a tagged list
33+
.It item a \" Each item preceded by .It macro
34+
Description of item a
35+
.It item b
36+
Description of item b
37+
.El \" Ends the list
38+
.Pp
39+
A list of flags and their descriptions:
40+
.Bl -tag -width -indent \" Differs from above in tag removed
41+
.It Fl a \"-a flag as a list item
42+
Description of -a flag
43+
.It Fl b
44+
Description of -b flag
45+
.El \" Ends the list
46+
.Pp
47+
.\" .Sh ENVIRONMENT \" May not be needed
48+
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49+
.\" .It Ev ENV_VAR_1
50+
.\" Description of ENV_VAR_1
51+
.\" .It Ev ENV_VAR_2
52+
.\" Description of ENV_VAR_2
53+
.\" .El
54+
.Sh FILES \" File used or created by the topic of the man page
55+
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56+
.It Pa /usr/share/file_name
57+
FILE_1 description
58+
.It Pa /Users/joeuser/Library/really_long_file_name
59+
FILE_2 description
60+
.El \" Ends the list
61+
.\" .Sh DIAGNOSTICS \" May not be needed
62+
.\" .Bl -diag
63+
.\" .It Diagnostic Tag
64+
.\" Diagnostic informtion here.
65+
.\" .It Diagnostic Tag
66+
.\" Diagnostic informtion here.
67+
.\" .El
68+
.Sh SEE ALSO
69+
.\" List links in ascending order by section, alphabetically within a section.
70+
.\" Please do not reference files that do not exist without filing a bug report
71+
.Xr a 1 ,
72+
.Xr b 1 ,
73+
.Xr c 1 ,
74+
.Xr a 2 ,
75+
.Xr b 2 ,
76+
.Xr a 3 ,
77+
.Xr b 3
78+
.\" .Sh BUGS \" Document known, unremedied bugs
79+
.\" .Sh HISTORY \" Document history if command behaves in a unique manner

git-gps/git-gps.m

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#import <Foundation/Foundation.h>
2+
3+
void usage(NSString *message) {
4+
NSLog(@"Usage: git-gps [init|commit]");
5+
if (message) {
6+
NSLog(@"%@", message);
7+
}
8+
}
9+
10+
NSString * gitPath() {
11+
NSString *result = nil;
12+
do { // once
13+
NSFileManager *fm = [NSFileManager defaultManager];
14+
NSString *cwd = [fm currentDirectoryPath];
15+
if (!cwd) break;
16+
17+
NSString *path = cwd;
18+
while (YES) {
19+
NSString *gitPath = [path stringByAppendingPathComponent:@".git"];
20+
BOOL isDir = NO;
21+
if ([fm fileExistsAtPath:gitPath isDirectory:&isDir] && isDir) {
22+
result = gitPath;
23+
break;
24+
}
25+
if ([path length] == 1) break;
26+
27+
path = [path stringByDeletingLastPathComponent];
28+
if (!path || [path length] == 0) {
29+
break;
30+
}
31+
}
32+
33+
} while (NO);
34+
return result;
35+
}
36+
37+
BOOL createGitGPSFile(NSString *path) {
38+
NSFileManager *fm = [NSFileManager defaultManager];
39+
NSString *filePath = [path stringByAppendingPathComponent:@".git-gps"];
40+
BOOL isDir = NO;
41+
if ([fm fileExistsAtPath:filePath isDirectory:&isDir]) {
42+
if (isDir) {
43+
usage([NSString stringWithFormat:@"\tDirectory found at: %@", filePath]);
44+
} else {
45+
usage([NSString stringWithFormat:@"\t.git-gps file already exists at: %@", filePat]);
46+
}
47+
return NO;
48+
}
49+
if ([fm createFileAtPath:filePath contents:nil attributes:nil]) {
50+
return YES;
51+
}
52+
return NO;
53+
}
54+
55+
int init() {
56+
NSString *path = gitPath();
57+
if (!path) {
58+
usage(@"\tNo .git path found in parent directories.");
59+
return 0;
60+
}
61+
NSFileManager *fm = [NSFileManager defaultManager];
62+
NSString *git
63+
return 1;
64+
}
65+
66+
int update() {
67+
return 1;
68+
}
69+
70+
int main (int argc, const char * argv[]) {
71+
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
72+
int result = 0;
73+
do { // once
74+
if (argc >= 2) {
75+
NSString *arg = [NSString stringWithUTF8String:argv[1]];
76+
if ([arg isEqualToString:@"init"]) {
77+
result = init();
78+
break;
79+
} else if ([arg isEqualToString:@"update"]) {
80+
result = update();
81+
break;
82+
} else {
83+
usage([NSString stringWithFormat:@"\tUnknown argument: %@", arg]);
84+
break;
85+
}
86+
}
87+
88+
usage(nil);
89+
} while (NO);
90+
91+
[pool drain];
92+
return 0;
93+
}

0 commit comments

Comments
 (0)