Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

132 lines (108 sloc) 2.372 kB
//
// PBGitCommit.m
// GitTest
//
// Created by Pieter de Bie on 13-06-08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBGitCommit.h"
#import "PBGitDefaults.h"
@implementation PBGitCommit
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
- (NSArray *) parents
{
if (nParents == 0)
return NULL;
int i;
NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
for (i = 0; i < nParents; ++i)
{
char *s = git_oid_mkhex(parentShas + i);
[p addObject:[NSString stringWithUTF8String:s]];
free(s);
}
return p;
}
- (NSDate *)date
{
return [NSDate dateWithTimeIntervalSince1970:timestamp];
}
- (NSString *) dateString
{
NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];
return [formatter stringFromDate: self.date];
}
- (NSArray*) treeContents
{
return self.tree.children;
}
- (git_oid *)sha
{
return &sha;
}
- initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
{
details = nil;
repository = repo;
sha = newSha;
return self;
}
- (NSString *)realSha
{
char *hex = git_oid_mkhex(&sha);
NSString *str = [NSString stringWithUTF8String:hex];
free(hex);
return str;
}
// FIXME: Remove this method once it's unused.
- (NSString*) details
{
return @"";
}
- (NSString *) patch
{
if (_patch != nil)
return _patch;
NSString *p = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", [self realSha], nil]];
// Add a GitX identifier to the patch ;)
_patch = [[p substringToIndex:[p length] -1] stringByAppendingString:@"+GitX"];
return _patch;
}
- (PBGitTree*) tree
{
return [PBGitTree rootForCommit: self];
}
- (void)addRef:(PBGitRef *)ref
{
if (!self.refs)
self.refs = [NSMutableArray arrayWithObject:ref];
else
[self.refs addObject:ref];
}
- (void)removeRef:(id)ref
{
if (!self.refs)
return;
[self.refs removeObject:ref];
}
- (NSMutableArray *)refs
{
return [[repository refs] objectForKey:[self realSha]];
}
- (void) setRefs:(NSMutableArray *)refs
{
[[repository refs] setObject:refs forKey:[self realSha]];
}
- (void)finalize
{
free(parentShas);
[super finalize];
}
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
}
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}
@end
Jump to Line
Something went wrong with that request. Please try again.