Replace NSURL with URL wherever possible

This commit is contained in:
Matt Rubin 2016-12-07 00:08:05 -05:00
parent f97fcfab38
commit 59cccf62d0
2 changed files with 9 additions and 9 deletions

View File

@ -126,7 +126,7 @@ final public class Repository {
/// checkoutProgress - A block that's called with the progress of the checkout.
///
/// Returns a `Result` with a `Repository` or an error.
class public func cloneFromURL(_ remoteURL: NSURL, toURL: NSURL, localClone: Bool = false, bare: Bool = false,
class public func cloneFromURL(_ remoteURL: URL, toURL: URL, localClone: Bool = false, bare: Bool = false,
credentials: Credentials = .Default(), checkoutStrategy: CheckoutStrategy = .Safe, checkoutProgress: CheckoutProgressBlock? = nil) -> Result<Repository, NSError> {
var options = cloneOptions(
bare: bare, localClone: localClone,
@ -134,8 +134,8 @@ final public class Repository {
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
var pointer: OpaquePointer? = nil
let remoteURLString = remoteURL.isFileReferenceURL() ? remoteURL.path! : remoteURL.absoluteString!
let result = git_clone(&pointer, remoteURLString, toURL.fileSystemRepresentation, &options)
let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString
let result = git_clone(&pointer, remoteURLString, (toURL as NSURL).fileSystemRepresentation, &options)
if result != GIT_OK.rawValue {
return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_clone"))
@ -154,7 +154,7 @@ final public class Repository {
self.pointer = pointer
let path = git_repository_workdir(pointer)
self.directoryURL = path.map({ path in NSURL(fileURLWithPath: String(validatingUTF8: path)!, isDirectory: true) })
self.directoryURL = path.map({ path in URL(fileURLWithPath: String(validatingUTF8: path)!, isDirectory: true) })
}
deinit {
@ -168,7 +168,7 @@ final public class Repository {
/// The URL of the repository's working directory, or `nil` if the
/// repository is bare.
public let directoryURL: NSURL?
public let directoryURL: URL?
// MARK: - Object Lookups

View File

@ -73,7 +73,7 @@ class RepositorySpec: QuickSpec {
}
it("should be able to clone a remote repository") {
let remoteRepoURL = NSURL(string: "https://github.com/libgit2/libgit2.github.com.git")
let remoteRepoURL = URL(string: "https://github.com/libgit2/libgit2.github.com.git")
let localURL = self.temporaryURLForPurpose("public-remote-clone")
let cloneResult = Repository.cloneFromURL(remoteRepoURL!, toURL: localURL)
@ -95,7 +95,7 @@ class RepositorySpec: QuickSpec {
let privateKey = env["SG2TestPrivateKey"], let passphrase = env["SG2TestPassphrase"] {
it("should be able to clone a remote repository requiring credentials") {
let remoteRepoURL = NSURL(string: privateRepo)
let remoteRepoURL = URL(string: privateRepo)
let localURL = self.temporaryURLForPurpose("private-remote-clone")
let cloneResult = Repository.cloneFromURL(remoteRepoURL!, toURL: localURL,
@ -596,9 +596,9 @@ class RepositorySpec: QuickSpec {
}
}
func temporaryURLForPurpose(_ purpose: String) -> NSURL {
func temporaryURLForPurpose(_ purpose: String) -> URL {
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
return NSURL(fileURLWithPath: path)
return URL(fileURLWithPath: path)
}
}