-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathGTBlameHunk.m
More file actions
68 lines (53 loc) · 1.6 KB
/
GTBlameHunk.m
File metadata and controls
68 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// GTBlameHunk.m
// ObjectiveGitFramework
//
// Created by David Catmull on 11/6/13.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//
#import "GTBlameHunk.h"
#import "GTOID.h"
#import "GTSignature.h"
@implementation GTBlameHunk
- (instancetype)init {
NSAssert(NO, @"Call to an unavailable initializer.");
return nil;
}
- (instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk {
self = [super init];
if (self == nil) return nil;
_git_blame_hunk = hunk;
return self;
}
- (NSRange)lines {
return NSMakeRange(self.git_blame_hunk.final_start_line_number, self.git_blame_hunk.lines_in_hunk);
}
- (GTOID *)finalCommitOID {
git_oid oid = self.git_blame_hunk.final_commit_id;
return [GTOID oidWithGitOid:&oid];
}
- (GTSignature *)finalSignature {
return [[GTSignature alloc] initWithGitSignature:self.git_blame_hunk.final_signature];
}
- (NSString *)originalPath {
NSString *path = @(self.git_blame_hunk.orig_path);
NSAssert(path, @"string was nil");
return path;
}
- (BOOL)isBoundary {
return self.git_blame_hunk.boundary;
}
- (BOOL)isEqual:(GTBlameHunk *)otherHunk {
if (self == otherHunk) return YES;
if (![otherHunk isKindOfClass:GTBlameHunk.class]) return NO;
if (!NSEqualRanges(self.lines, otherHunk.lines)) return NO;
if (![self.finalCommitOID isEqual:otherHunk.finalCommitOID]) return NO;
if (![self.finalSignature isEqual:otherHunk.finalSignature]) return NO;
if (![self.originalPath isEqualToString:otherHunk.originalPath]) return NO;
if (self.isBoundary != otherHunk.isBoundary) return NO;
return YES;
}
- (NSUInteger)hash {
return self.lines.location ^ self.lines.length;
}
@end