Skip to content

Commit a8839f2

Browse files
committed
Convert GTRepository.cloneFromURL option keys into constants
1 parent 6075f7b commit a8839f2

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

Classes/GTRepository.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ typedef enum {
9494
GTCheckoutNotifyAll = GIT_CHECKOUT_NOTIFY_ALL,
9595
} GTCheckoutNotifyFlags;
9696

97+
// Transport flags sent as options to +cloneFromURL... method
98+
typedef enum {
99+
GTTransportFlagsNone = GIT_TRANSPORTFLAGS_NONE,
100+
// If you pass this flag and the connection is secured with SSL/TLS,
101+
// the authenticity of the server certificate will not be verified.
102+
GTTransportFlagsNoCheckCert = GIT_TRANSPORTFLAGS_NO_CHECK_CERT,
103+
} GTTransportFlags;
104+
105+
// An `NSNumber` wrapped `GTTransportFlags`, documented above.
106+
// Default value is `GTTransportFlagsNone`.
107+
extern NSString *const GTRepositoryCloneOptionsTransportFlags;
108+
109+
// An `NSNumber` wrapped `BOOL`, if YES, create a bare clone.
110+
// Default value is `NO`.
111+
extern NSString *const GTRepositoryCloneOptionsBare;
112+
113+
// An `NSNumber` wrapped `BOOL`, if NO, don't checkout the remote HEAD.
114+
// Default value is `YES`.
115+
extern NSString *const GTRepositoryCloneOptionsCheckout;
97116

98117
typedef void (^GTRepositoryStatusBlock)(NSURL *fileURL, GTRepositoryFileStatus status, BOOL *stop);
99118

@@ -131,12 +150,8 @@ typedef void (^GTRepositoryStatusBlock)(NSURL *fileURL, GTRepositoryFileStatus s
131150
// originURL - The URL to clone from.
132151
// workdirURL - A URL to the desired working directory on the local machine.
133152
// withCheckout - if NO, don't checkout the remote HEAD
134-
// options - A NSDictionary with NSString keys, used for specifying clone options. Possible keys are:
135-
// - @"bare" - BOOL value, if YES, create a bare clone, for example: [NSNumber numberWithBool:YES], defaults to NO
136-
// - @"checkout" - BOOL value, if NO, don't checkout the remote HEAD, for example: [NSNumber numberWithBool:NO], defaults to YES
137-
// - @"transportFlags" - int value, two possible values:
138-
// - GIT_TRANSPORTFLAGS_NONE (0), for example: [NSNumber numberWithInt:GIT_TRANSPORTFLAGS_NONE], this is the default value
139-
// - GIT_TRANSPORTFLAGS_NO_CHECK_CERT (1), for example: [NSNumber numberWithInt:GIT_TRANSPORTFLAGS_NO_CHECK_CERT], if you pass this flag and the connection is secured with SSL/TLS, the authenticity of the server certificate will not be verified
153+
// options - A dictionary containing any of the above options key constants, or
154+
// nil to use the defaults.
140155
// error - A pointer to fill in case of trouble.
141156
// transferProgressBlock - This block is called with network transfer updates.
142157
// checkoutProgressBlock - This block is called with checkout updates (if withCheckout is YES).

Classes/GTRepository.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#import "NSString+Git.h"
4545
#import "GTDiffFile.h"
4646

47+
NSString *const GTRepositoryCloneOptionsBare = @"GTRepositoryCloneOptionsBare";
48+
NSString *const GTRepositoryCloneOptionsCheckout = @"GTRepositoryCloneOptionsCheckout";
49+
NSString *const GTRepositoryCloneOptionsTransportFlags = @"GTRepositoryCloneOptionsTransportFlags";
4750

4851
// The type of block passed to -enumerateSubmodulesRecursively:usingBlock:.
4952
typedef void (^GTRepositorySubmoduleEnumerationBlock)(GTSubmodule *submodule, BOOL *stop);
@@ -172,13 +175,13 @@ + (id)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL opt
172175

173176
git_clone_options cloneOptions = GIT_CLONE_OPTIONS_INIT;
174177

175-
NSNumber *bare = options[@"bare"];
178+
NSNumber *bare = options[GTRepositoryCloneOptionsBare];
176179
cloneOptions.bare = bare == nil ? 0 : bare.boolValue;
177180

178-
NSNumber *transportFlags = options[@"transportFlags"];
181+
NSNumber *transportFlags = options[GTRepositoryCloneOptionsTransportFlags];
179182
cloneOptions.transport_flags = transportFlags == nil ? 0 : transportFlags.intValue;
180183

181-
NSNumber *checkout = options[@"checkout"];
184+
NSNumber *checkout = options[GTRepositoryCloneOptionsCheckout];
182185
BOOL withCheckout = checkout == nil ? YES : checkout.boolValue;
183186

184187
if (withCheckout) {

0 commit comments

Comments
 (0)