5 // Created by Pieter de Bie on 13-06-08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
9 #import "PBGitCommit.h"
12 @implementation PBGitCommit
14 @synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
22 NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
23 for (i = 0; i < nParents; ++i)
25 char *s = git_oid_mkhex(parentShas + i);
26 [p addObject:[NSString stringWithUTF8String:s]];
34 return [NSDate dateWithTimeIntervalSince1970:timestamp];
37 - (NSString *) dateString
39 NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];
40 return [formatter stringFromDate: self.date];
43 - (NSArray*) treeContents
45 return self.tree.children;
53 - initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
63 char *hex = git_oid_mkhex(&sha);
64 NSString *str = [NSString stringWithUTF8String:hex];
69 // NOTE: This method should remain threadsafe, as we load it in async
76 details = [self.repository outputForArguments:[NSArray arrayWithObjects:@"show", @"--pretty=raw", @"-M", @"--no-color", [self realSha], nil]];
86 NSString *p = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", [self realSha], nil]];
87 // Add a GitX identifier to the patch ;)
88 _patch = [[p substringToIndex:[p length] -1] stringByAppendingString:@"+GitX"];
94 return [PBGitTree rootForCommit: self];
97 - (void)addRef:(PBGitRef *)ref
100 self.refs = [NSMutableArray arrayWithObject:ref];
102 [self.refs addObject:ref];
105 - (void)removeRef:(id)ref
110 [self.refs removeObject:ref];
113 - (NSMutableArray *)refs
115 return [[repository refs] objectForKey:[self realSha]];
118 - (void) setRefs:(NSMutableArray *)refs
120 [[repository refs] setObject:refs forKey:[self realSha]];
129 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
134 + (BOOL)isKeyExcludedFromWebScript:(const char *)name {