Skip to content

Commit

Permalink
add an implementation of git_repository_init
Browse files Browse the repository at this point in the history
  • Loading branch information
m3ta4a committed Jan 21, 2017
1 parent 4864cc4 commit 31a0a3d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions SwiftGit2/Repository.swift
Original file line number Diff line number Diff line change
@@ -99,6 +99,25 @@ final public class Repository {

// MARK: - Creating Repositories

/// Load the repository at the given URL.
///
/// URL - The URL of the repository.
///
/// Returns a `Result` with a `Repository` or an error.
class public func createAt(_ url: URL) -> Result<Repository, NSError> {
var pointer: OpaquePointer? = nil
let result = url.withUnsafeFileSystemRepresentation {
git_repository_init(&pointer, $0, 0)
}

guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_init"))
}

let repository = Repository(pointer!)
return Result.success(repository)
}

/// Load the repository at the given URL.
///
/// URL - The URL of the repository.

0 comments on commit 31a0a3d

Please sign in to comment.