Skip to content

Commit 4e77003

Browse files
author
Ben Chatelain
committed
GTCredentialProvider nullability
1 parent 4b6574b commit 4e77003

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ObjectiveGit/GTCredential.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ typedef NS_ENUM(NSInteger, GTCredentialType) {
1717
GTCredentialTypeSSHCustom = GIT_CREDTYPE_SSH_CUSTOM,
1818
};
1919

20+
NS_ASSUME_NONNULL_BEGIN
21+
2022
@class GTCredential;
2123

2224
/// The GTCredentialProvider acts as a proxy for GTCredential requests.
@@ -29,6 +31,7 @@ typedef NS_ENUM(NSInteger, GTCredentialType) {
2931
/// Creates a provider from a block.
3032
///
3133
/// credentialBlock - a block that will be called when credentials are requested.
34+
/// Must not be nil.
3235
+ (instancetype)providerWithBlock:(GTCredential *(^)(GTCredentialType type, NSString *URL, NSString *userName))credentialBlock;
3336

3437
/// Default credential provider method.
@@ -43,7 +46,7 @@ typedef NS_ENUM(NSInteger, GTCredentialType) {
4346
/// type - the credential types allowed by the operation.
4447
/// URL - the URL the operation is authenticating against.
4548
/// userName - the user name provided by the operation. Can be nil, and might be ignored.
46-
- (GTCredential *)credentialForType:(GTCredentialType)type URL:(NSString *)URL userName:(NSString *)userName;
49+
- (GTCredential *)credentialForType:(GTCredentialType)type URL:(NSString *)URL userName:(nullable NSString *)userName;
4750
@end
4851

4952
/// The GTCredential class is used to provide authentication data.
@@ -57,21 +60,23 @@ typedef NS_ENUM(NSInteger, GTCredentialType) {
5760
/// error - If not NULL, set to any errors that occur.
5861
///
5962
/// Return a new GTCredential instance, or nil if an error occurred
60-
+ (instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error;
63+
+ (nullable instancetype)credentialWithUserName:(NSString *)userName password:(NSString *)password error:(NSError **)error;
6164

6265
/// Create a credential object from a SSH keyfile
6366
///
64-
/// userName - The username to authenticate as.
67+
/// userName - The username to authenticate as. Must not be nil.
6568
/// publicKeyURL - The URL to the public key for that user.
6669
/// Can be omitted to reconstruct the public key from the private key.
67-
/// privateKeyURL - The URL to the private key for that user.
70+
/// privateKeyURL - The URL to the private key for that user. Must not be nil.
6871
/// passphrase - The passPhrase for the private key. Optional if the private key has no password.
6972
/// error - If not NULL, set to any errors that occur.
7073
///
7174
/// Return a new GTCredential instance, or nil if an error occurred
72-
+ (instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(NSString *)passphrase error:(NSError **)error;
75+
+ (nullable instancetype)credentialWithUserName:(NSString *)userName publicKeyURL:(nullable NSURL *)publicKeyURL privateKeyURL:(NSURL *)privateKeyURL passphrase:(nullable NSString *)passphrase error:(NSError **)error;
7376

7477
/// The underlying `git_cred` object.
7578
- (git_cred *)git_cred __attribute__((objc_returns_inner_pointer));
7679

7780
@end
81+
82+
NS_ASSUME_NONNULL_END

ObjectiveGit/GTCredential.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ @interface GTCredentialProvider ()
1919
@end
2020

2121
@implementation GTCredentialProvider
22+
2223
+ (instancetype)providerWithBlock:(GTCredentialProviderBlock)credentialBlock {
2324
NSParameterAssert(credentialBlock != nil);
2425

0 commit comments

Comments
 (0)