Added git_repository_open_ext wrapper#593
Conversation
ObjectiveGit/GTRepository.h
Outdated
| /// +initWithURL:flags:ceilingDirs:error:. | ||
| /// | ||
| /// See respository.h for documentation of each individual flag. | ||
| typedef NS_OPTIONS(UInt32, GTRepositoryOpenFlags) { |
There was a problem hiding this comment.
NSInteger instead of UInt32. I think UInt32 comes from Carbon ?
There was a problem hiding this comment.
Correct, UInt32 will not always be an unsigned int. I guess I will just use an NSInteger and down-cast it to an unsigned int.
ObjectiveGit/GTRepository.h
Outdated
| /// error - The error if one occurs. | ||
| /// | ||
| /// Returns the initialized repository, or nil if an error occurred. | ||
| + (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(nullable const char *)ceilingDirs error:(NSError **)error; |
There was a problem hiding this comment.
initWith...class-method is confusing. It should be named-repositoryWith...instead.- Use the typedef name instead of
UInt32
There was a problem hiding this comment.
const char *isn't very Cocoa-y. What about passing anNSArray <NSURL *> *and doing the conversion internally ?
There was a problem hiding this comment.
- Others class-methods for
GTRepositoryare usinginitWithURL:.... It make sense for me to stay consistent. (Plus, I don't know howrepositoryWithURL...will translate into Swift. I will experiment and see) NSArray <NSURL *> *it is 😃
ObjectiveGit/GTRepository.m
Outdated
|
|
||
| - (instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(const char *)ceilingDirs error:(NSError **)error { | ||
| if (!localFileURL.isFileURL || localFileURL.path == nil) { | ||
| if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to initialize repository.", @"") }]; |
There was a problem hiding this comment.
NSFileWriteUnsupportedScheme ?
There was a problem hiding this comment.
Copy paste error. Will fix.
ObjectiveGit/GTRepository.h
Outdated
| /// error - The error if one occurs. | ||
| /// | ||
| /// Returns the initialized repository, or nil if an error occurred. | ||
| - (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(nullable const char *)ceilingDirs error:(NSError **)error; |
There was a problem hiding this comment.
Also, having both a class and an instance method is unwarranted IMHO. I'd drop this one.
There was a problem hiding this comment.
I totally agree on this one. I will remove the instance method. I only created this one for consistency with the rest
There was a problem hiding this comment.
Actually, is there any reason you would rather drop the instance initializer rather than the class initializer? Keeping the convenience instance initializer allows my Swift code to look cleaner: GTRepository(url: url, flags: 0, ceilingDirs: nil)
There was a problem hiding this comment.
Usually, my Cocoa-fu says that convenience initializers get declared as class methods, designated initializers go under -init.... Arguably, this one could be kept as a designated initializer (since it ends up calling one of the handful libgit2 functions that creates objects), but our designated initializer is actually initWithGitRepository:.
I'm not sure how that would like after being Swift-preprocessed though.
glegrain
left a comment
There was a problem hiding this comment.
Thank you for your input. Greatly appreciated.
ObjectiveGit/GTRepository.h
Outdated
| /// +initWithURL:flags:ceilingDirs:error:. | ||
| /// | ||
| /// See respository.h for documentation of each individual flag. | ||
| typedef NS_OPTIONS(UInt32, GTRepositoryOpenFlags) { |
There was a problem hiding this comment.
Correct, UInt32 will not always be an unsigned int. I guess I will just use an NSInteger and down-cast it to an unsigned int.
ObjectiveGit/GTRepository.h
Outdated
| /// error - The error if one occurs. | ||
| /// | ||
| /// Returns the initialized repository, or nil if an error occurred. | ||
| - (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(nullable const char *)ceilingDirs error:(NSError **)error; |
There was a problem hiding this comment.
I totally agree on this one. I will remove the instance method. I only created this one for consistency with the rest
ObjectiveGit/GTRepository.m
Outdated
|
|
||
| - (instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(const char *)ceilingDirs error:(NSError **)error { | ||
| if (!localFileURL.isFileURL || localFileURL.path == nil) { | ||
| if (error != NULL) *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnsupportedSchemeError userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid file path URL to initialize repository.", @"") }]; |
There was a problem hiding this comment.
Copy paste error. Will fix.
ObjectiveGit/GTRepository.h
Outdated
| /// error - The error if one occurs. | ||
| /// | ||
| /// Returns the initialized repository, or nil if an error occurred. | ||
| + (nullable instancetype)initWithURL:(NSURL *)localFileURL flags:(UInt32)flags ceilingDirs:(nullable const char *)ceilingDirs error:(NSError **)error; |
There was a problem hiding this comment.
- Others class-methods for
GTRepositoryare usinginitWithURL:.... It make sense for me to stay consistent. (Plus, I don't know howrepositoryWithURL...will translate into Swift. I will experiment and see) NSArray <NSURL *> *it is 😃
|
Any ideas how to fix Travis? |
|
The iOS tests are flaky, so (unless you happen to find a solution 😉 ), you're better off just making sure the macOS run is green. |
d15fb27 to
367ad42
Compare
|
Travis is still failing after rebase |
|
iOS is green, Mac is failing because of SSH check which is because of something else. So this should be good from a CI standpoint. |
|
Thanks for the PR 👾 |
Added a GTRepository convenience initializer to use git_repository_open_ext to permit "searching" from the given url.