Skip to content

Commit 757e19c

Browse files
committed
Merge pull request #452 from phatblat/phatblat/pr/swift1.2
Support for Swift 1.2 (Spec dependencies) and new Objective-C nullability qualifiers
2 parents d4e18a9 + 0a1c008 commit 757e19c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+683
-327
lines changed

Cartfile.private

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github "jspahrsummers/xcconfigs" >= 0.7.1
2-
github "Quick/Quick" ~> 0.2
3-
github "Quick/Nimble" ~> 0.2
2+
github "Quick/Quick" ~> 0.3
3+
github "Quick/Nimble" ~> 0.4

Cartfile.resolved

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
github "Quick/Nimble" "v0.2.0"
2-
github "Quick/Quick" "v0.2.2"
3-
github "jspahrsummers/xcconfigs" "0.7.1"
1+
github "Quick/Nimble" "v0.4.2"
2+
github "Quick/Quick" "v0.3.1"
3+
github "jspahrsummers/xcconfigs" "0.7.2"

Carthage/Checkouts/Nimble

Submodule Nimble updated 69 files

Carthage/Checkouts/xcconfigs

ObjectiveGit/GTBlame.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
@class GTBlameHunk;
1313
@class GTRepository;
1414

15-
/// A `GTBlame` provides authorship info, through `GTBlameHunk` for each line of a file.
15+
NS_ASSUME_NONNULL_BEGIN
16+
17+
/// A `GTBlame` provides authorship info, through `GTBlameHunk` for each line of a file. Analogous to `git_blame` in libgit2.
1618
@interface GTBlame : NSObject
1719

1820
/// Designated initializer.
19-
- (instancetype)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;
21+
///
22+
/// blame - A git_blame to wrap. May not be NULL.
23+
///
24+
/// Returns a blame, or nil if initialization failed.
25+
- (nullable instancetype)initWithGitBlame:(git_blame *)blame NS_DESIGNATED_INITIALIZER;
2026

2127
/// Get all the hunks in the blame. A convenience wrapper around `enumerateHunksUsingBlock:`
2228
@property (nonatomic, strong, readonly) NSArray *hunks;
@@ -29,12 +35,13 @@
2935
/// index - The index to retrieve the hunk from.
3036
///
3137
/// Returns a `GTBlameHunk` or nil if an error occurred.
32-
- (GTBlameHunk *)hunkAtIndex:(NSUInteger)index;
38+
- (nullable GTBlameHunk *)hunkAtIndex:(NSUInteger)index;
3339

3440
/// Enumerate the hunks in the blame.
3541
///
3642
/// block - A block invoked for every hunk in the blame.
3743
/// Setting stop to `YES` instantly stops the enumeration.
44+
/// May not be NULL.
3845
///
3946
- (void)enumerateHunksUsingBlock:(void (^)(GTBlameHunk *hunk, NSUInteger index, BOOL *stop))block;
4047

@@ -43,10 +50,11 @@
4350
/// lineNumber - The (1 based) line number to find a hunk for.
4451
///
4552
/// Returns a `GTBlameHunk` or nil if an error occurred.
46-
- (GTBlameHunk *)hunkAtLineNumber:(NSUInteger)lineNumber;
53+
- (nullable GTBlameHunk *)hunkAtLineNumber:(NSUInteger)lineNumber;
4754

4855
/// The underlying `git_blame` object.
4956
- (git_blame *)git_blame __attribute__((objc_returns_inner_pointer));
5057

5158
@end
5259

60+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTBlameHunk.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,27 @@
1212
@class GTOID;
1313
@class GTSignature;
1414

15+
NS_ASSUME_NONNULL_BEGIN
16+
1517
/// A `GTBlameHunk` is an object that provides authorship info for a set of lines in a `GTBlame`.
1618
@interface GTBlameHunk : NSObject
1719

18-
- (instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;
20+
/// Designated initializer.
21+
///
22+
/// hunk - A git_blame_hunk to wrap. May not be NULL.
23+
///
24+
/// Returns a blame hunk, or nil if initialization failed.
25+
- (nullable instancetype)initWithGitBlameHunk:(git_blame_hunk)hunk NS_DESIGNATED_INITIALIZER;
1926

2027
/// A NSRange where `location` is the (1 based) starting line number,
2128
/// and `length` is the number of lines in the hunk.
2229
@property (nonatomic, readonly) NSRange lines;
2330

2431
/// The OID of the commit where this hunk was last changed.
25-
@property (nonatomic, readonly, copy) GTOID *finalCommitOID;
32+
@property (nonatomic, readonly, copy, nullable) GTOID *finalCommitOID;
2633

2734
/// The signature of the commit where this hunk was last changed.
28-
@property (nonatomic, readonly) GTSignature *finalSignature;
35+
@property (nonatomic, readonly, nullable) GTSignature *finalSignature;
2936

3037
/// The path of the file in the original commit.
3138
@property (nonatomic, readonly, copy) NSString *originalPath;
@@ -38,3 +45,5 @@
3845
@property (nonatomic, readonly) git_blame_hunk git_blame_hunk;
3946

4047
@end
48+
49+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTBlob.h

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,91 @@
3030

3131
#import "GTObject.h"
3232

33+
NS_ASSUME_NONNULL_BEGIN
3334

3435
@interface GTBlob : GTObject
3536

36-
/// Convenience class methods
37-
+ (instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
38-
+ (instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
39-
+ (instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
37+
/// Creates a new blob from the given string.
38+
///
39+
/// This writes data to the repository's object database.
40+
///
41+
/// string - The string to add. This must not be nil.
42+
/// repository - The repository to put the object in. This must not be nil.
43+
/// error - Will be set if an error occurs. This may be nil.
44+
///
45+
/// Return a newly created blob object, or nil if an error occurs.
46+
+ (nullable instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
47+
48+
/// Creates a new blob from the given data.
49+
///
50+
/// This writes data to the repository's object database.
51+
///
52+
/// data - The data to add. This must not be nil.
53+
/// repository - The repository to put the object in. This must not be nil.
54+
/// error - Will be set if an error occurs. This may be nil.
55+
///
56+
/// Return a newly created blob object, or nil if an error occurs.
57+
+ (nullable instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
4058

59+
/// Creates a new blob given an NSURL to a file.
60+
///
61+
/// This copies the data from the file to the repository's object database.
62+
///
63+
/// file - The NSURL of the file to add. This must not be nil.
64+
/// repository - The repository to put the object in. This must not be nil.
65+
/// error - Will be set if an error occurs. This may be nil.
66+
///
67+
/// Return a newly created blob object, or nil if an error occurs.
68+
+ (nullable instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
69+
70+
/// Creates a new blob from the given string.
71+
///
4172
/// Convenience wrapper around `-initWithData:inRepository:error` that converts the string to UTF8 data
42-
- (instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
73+
///
74+
/// string - The string to add. This must not be nil.
75+
/// repository - The repository to put the object in. This must not be nil.
76+
/// error - Will be set if an error occurs. This may be nil.
77+
///
78+
/// Return a newly created blob object, or nil if an error occurs.
79+
- (nullable instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error;
4380

4481
/// Creates a new blob from the passed data.
4582
///
4683
/// This writes data to the repository's object database.
4784
///
48-
/// data - The data to write.
49-
/// repository - The repository to put the object in.
50-
/// error - Will be set if an error occurs.
85+
/// data - The data to write. This must not be nil.
86+
/// repository - The repository to put the object in. This must not be nil.
87+
/// error - Will be set if an error occurs. This may be nil.
5188
///
5289
/// Returns a newly created blob object, or nil if an error occurs.
53-
- (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
90+
- (nullable instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error;
5491

5592
/// Creates a new blob from the specified file.
5693
///
5794
/// This copies the data from the file to the repository's object database.
5895
///
59-
/// data - The file to copy contents from.
60-
/// repository - The repository to put the object in.
61-
/// error - Will be set if an error occurs.
96+
/// file - The file to copy contents from. This must not be nil.
97+
/// repository - The repository to put the object in. This must not be nil.
98+
/// error - Will be set if an error occurs. This may be nil.
6299
///
63100
/// Returns a newly created blob object, or nil if an error occurs.
64-
- (instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
101+
- (nullable instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error;
65102

66103
/// The underlying `git_object` as a `git_blob` object.
67104
- (git_blob *)git_blob __attribute__((objc_returns_inner_pointer));
68105

69106
- (git_off_t)size;
70107
- (NSString *)content;
71-
- (NSData *)data;
108+
- (nullable NSData *)data;
72109

73110
/// Attempts to apply the filter list for `path` to the blob.
74111
///
75112
/// path - The path to use filters from. Must not be nil.
76113
/// error - If not NULL, set to any error that occurs.
77114
///
78115
/// Returns the filtered data, or nil if an error occurs.
79-
- (NSData *)applyFiltersForPath:(NSString *)path error:(NSError **)error;
116+
- (nullable NSData *)applyFiltersForPath:(NSString *)path error:(NSError **)error;
80117

81118
@end
119+
120+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTBlob.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ - (NSString *)description {
4646

4747
#pragma mark API
4848

49-
+ (id)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error {
49+
+ (instancetype)blobWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error {
5050
return [[self alloc] initWithString:string inRepository:repository error:error];
5151
}
5252

53-
+ (id)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error {
53+
+ (instancetype)blobWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error {
5454
return [[self alloc] initWithData:data inRepository:repository error:error];
5555
}
5656

57-
+ (id)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error {
57+
+ (instancetype)blobWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error {
5858
return [[self alloc] initWithFile:file inRepository:repository error:error];
5959
}
6060

61-
- (id)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)repository error:(NSError **)error {
61+
- (instancetype)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)repository error:(NSError **)error {
6262
NSParameterAssert(oid != NULL);
6363
NSParameterAssert(repository != nil);
6464

@@ -74,12 +74,12 @@ - (id)initWithOid:(const git_oid *)oid inRepository:(GTRepository *)repository e
7474
return [self initWithObj:obj inRepository:repository];
7575
}
7676

77-
- (id)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error {
77+
- (instancetype)initWithString:(NSString *)string inRepository:(GTRepository *)repository error:(NSError **)error {
7878
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
7979
return [self initWithData:data inRepository:repository error:error];
8080
}
8181

82-
- (id)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error {
82+
- (instancetype)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:(NSError **)error {
8383
NSParameterAssert(data != nil);
8484
NSParameterAssert(repository != nil);
8585

@@ -95,7 +95,7 @@ - (id)initWithData:(NSData *)data inRepository:(GTRepository *)repository error:
9595
return [self initWithOid:&oid inRepository:repository error:error];
9696
}
9797

98-
- (id)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error {
98+
- (instancetype)initWithFile:(NSURL *)file inRepository:(GTRepository *)repository error:(NSError **)error {
9999
NSParameterAssert(file != nil);
100100
NSParameterAssert(repository != nil);
101101

ObjectiveGit/GTBranch.h

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,47 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
3535
GTBranchTypeRemote = GIT_BRANCH_REMOTE,
3636
};
3737

38+
NS_ASSUME_NONNULL_BEGIN
39+
3840
/// A git branch object.
3941
///
40-
/// Branches are considered to be equivalent iff both their `name` and `SHA` are
42+
/// Branches are considered to be equivalent if both their `name` and `SHA` are
4143
/// equal.
4244
@interface GTBranch : NSObject
4345

44-
@property (nonatomic, readonly) NSString *name;
45-
@property (nonatomic, readonly) NSString *shortName;
46-
@property (nonatomic, copy, readonly) GTOID *OID;
47-
@property (nonatomic, readonly) NSString *remoteName;
46+
@property (nonatomic, readonly, nullable) NSString *name;
47+
@property (nonatomic, readonly, nullable) NSString *shortName;
48+
@property (nonatomic, copy, readonly, nullable) GTOID *OID;
49+
@property (nonatomic, readonly, nullable) NSString *remoteName;
4850
@property (nonatomic, readonly) GTBranchType branchType;
4951
@property (nonatomic, readonly, strong) GTRepository *repository;
5052
@property (nonatomic, readonly, strong) GTReference *reference;
5153

5254
+ (NSString *)localNamePrefix;
5355
+ (NSString *)remoteNamePrefix;
5456

55-
- (id)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
56-
+ (id)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo;
57+
/// Designated initializer.
58+
///
59+
/// ref - The branch reference to wrap. Must not be nil.
60+
/// repo - The repository containing the branch. Must not be nil.
61+
///
62+
/// Returns the initialized receiver.
63+
- (nullable instancetype)initWithReference:(GTReference *)ref repository:(GTRepository *)repo NS_DESIGNATED_INITIALIZER;
64+
65+
/// Convenience class initializer.
66+
///
67+
/// ref - The branch reference to wrap. Must not be nil.
68+
/// repo - The repository containing the branch. Must not be nil.
69+
///
70+
/// Returns an initialized instance.
71+
+ (nullable instancetype)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo;
5772

5873
/// Get the target commit for this branch
5974
///
6075
/// error(out) - will be filled if an error occurs
6176
///
6277
/// returns a GTCommit object or nil if an error occurred
63-
- (GTCommit *)targetCommitAndReturnError:(NSError **)error;
78+
- (nullable GTCommit *)targetCommitAndReturnError:(NSError **)error;
6479

6580
/// Count all commits in this branch
6681
///
@@ -69,15 +84,21 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
6984
/// returns number of commits in the branch or NSNotFound if an error occurred
7085
- (NSUInteger)numberOfCommitsWithError:(NSError **)error;
7186

72-
- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
87+
/// Get unique commits
88+
///
89+
/// otherBranch -
90+
/// error - If not NULL, set to any error that occurs.
91+
///
92+
/// Returns a (possibly empty) array of GTCommits, or nil if an error occurs.
93+
- (nullable NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
7394

7495
/// Deletes the local branch and nils out the reference.
7596
- (BOOL)deleteWithError:(NSError **)error;
7697

7798
/// If the receiver is a local branch, looks up and returns its tracking branch.
7899
/// If the receiver is a remote branch, returns self. If no tracking branch was
79100
/// found, returns nil and sets `success` to YES.
80-
- (GTBranch *)trackingBranchWithError:(NSError **)error success:(BOOL *)success;
101+
- (nullable GTBranch *)trackingBranchWithError:(NSError **)error success:(nullable BOOL *)success;
81102

82103
/// Update the tracking branch.
83104
///
@@ -86,7 +107,7 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
86107
/// error - The error if one occurred.
87108
///
88109
/// Returns whether it was successful.
89-
- (BOOL)updateTrackingBranch:(GTBranch *)trackingBranch error:(NSError **)error;
110+
- (BOOL)updateTrackingBranch:(nullable GTBranch *)trackingBranch error:(NSError **)error;
90111

91112
/// Reloads the branch's reference and creates a new branch based off that newly
92113
/// loaded reference.
@@ -96,7 +117,7 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
96117
/// error - The error if one occurred.
97118
///
98119
/// Returns the reloaded branch, or nil if an error occurred.
99-
- (GTBranch *)reloadedBranchWithError:(NSError **)error;
120+
- (nullable GTBranch *)reloadedBranchWithError:(NSError **)error;
100121

101122
/// Calculate the ahead/behind count from this branch to the given branch.
102123
///
@@ -110,3 +131,5 @@ typedef NS_ENUM(NSInteger, GTBranchType) {
110131
- (BOOL)calculateAhead:(size_t *)ahead behind:(size_t *)behind relativeTo:(GTBranch *)branch error:(NSError **)error;
111132

112133
@end
134+
135+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)