Refactor Git URL related code, fix #336
This commit is contained in:
parent
e83a2f941e
commit
258906fdbb
8 changed files with 119 additions and 105 deletions
|
|
@ -22,9 +22,9 @@ public extension DefaultsKeys {
|
|||
static let gitSSHPrivateKeyArmor = DefaultsKey<String?>("gitSSHPrivateKeyArmor")
|
||||
static let passcodeKey = DefaultsKey<String?>("passcodeKey")
|
||||
|
||||
static let gitURL = DefaultsKey<URL?>("gitURL")
|
||||
static let gitAuthenticationMethod = DefaultsKey<String?>("gitAuthenticationMethod")
|
||||
static let gitUsername = DefaultsKey<String?>("gitUsername")
|
||||
static let gitURL = DefaultsKey<URL>("gitURL", defaultValue: URL(string: "https://")!)
|
||||
static let gitAuthenticationMethod = DefaultsKey<GitAuthenticationMethod>("gitAuthenticationMethod", defaultValue: GitAuthenticationMethod.password)
|
||||
static let gitUsername = DefaultsKey<String>("gitUsername", defaultValue: "git")
|
||||
static let gitBranchName = DefaultsKey<String>("gitBranchName", defaultValue: "master")
|
||||
static let gitSSHPrivateKeyURL = DefaultsKey<URL?>("gitSSHPrivateKeyURL")
|
||||
static let gitSSHKeySource = DefaultsKey<String?>("gitSSHKeySource")
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ import UIKit
|
|||
import SwiftyUserDefaults
|
||||
import ObjectiveGit
|
||||
|
||||
public enum GitAuthenticationMethod: String, DefaultsSerializable {
|
||||
case password, key
|
||||
}
|
||||
|
||||
public struct GitCredential {
|
||||
private var credential: Credential
|
||||
private let passwordStore = PasswordStore.shared
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ public class PasswordStore {
|
|||
return (try? fm.allocatedSizeOfDirectoryAtURL(directoryURL: self.storeURL)) ?? 0
|
||||
}
|
||||
|
||||
public var numberOfLocalCommits: Int? {
|
||||
return (try? getLocalCommits())?.flatMap { $0.count }
|
||||
public var numberOfLocalCommits: Int {
|
||||
return (try? getLocalCommits())?.flatMap { $0.count } ?? 0
|
||||
}
|
||||
|
||||
public var lastSyncedTime: Date? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue