Skip to content

Commit

Permalink
incorporate requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
m3ta4a committed Aug 9, 2017
1 parent 242741a commit f635f50
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions SwiftGit2/Credentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ private class Wrapper<T> {
}
}

/// Convert libgit2 string to Swift string
///
/// - parameter cStr: C string pointer
///
/// - returns: Swift string
func git_string_converter(_ cStr: UnsafePointer<CChar>) -> String {
return String(cString: cStr)
}

public enum Credentials {
case `default`
case agent
Expand All @@ -43,18 +34,18 @@ public enum Credentials {
/// Handle the request of credentials, passing through to a wrapped block after converting the arguments.
/// Converts the result to the correct error code required by libgit2 (0 = success, 1 = rejected setting creds,
/// -1 = error)
internal func credentialsCallback(cred: UnsafeMutablePointer<UnsafeMutablePointer<git_cred>?>?,
url: UnsafePointer<CChar>?, username: UnsafePointer<CChar>?,
_: UInt32, payload: UnsafeMutableRawPointer?) -> Int32 {
internal func credentialsCallback(
cred: UnsafeMutablePointer<UnsafeMutablePointer<git_cred>?>?,
url: UnsafePointer<CChar>?,
username: UnsafePointer<CChar>?,
_: UInt32,
payload: UnsafeMutableRawPointer?
) -> Int32 {

let result: Int32

// Find username_from_url
let name: String?
if username == nil {
name = nil
} else {
name = git_string_converter(username!)
}
let name = username.map(String.init(cString:))

switch Credentials.fromPointer(payload!) {
case .default:
Expand Down

0 comments on commit f635f50

Please sign in to comment.