use ObjectiveGit instead of SwiftGit2
This commit is contained in:
parent
7f58e2e649
commit
1b0f8fcb05
7 changed files with 74 additions and 32 deletions
3
Cartfile
3
Cartfile
|
|
@ -1,3 +1,4 @@
|
|||
github "SwiftGit2/SwiftGit2"
|
||||
github "SVProgressHUD/SVProgressHUD"
|
||||
github "radex/SwiftyUserDefaults"
|
||||
github "libgit2/objective-git"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
94BA784B85E071D25EE89B59 /* libPods-pass.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */; };
|
||||
DC1208561E35D0BA0042942E /* PasswordsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */; };
|
||||
DC1208581E35EBE60042942E /* ObjectiveGit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC1208571E35EBE60042942E /* ObjectiveGit.framework */; };
|
||||
DC3DC8391E2F63240062A988 /* PasswordDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */; };
|
||||
DC6FDBBD1E35CE1E00A280F0 /* PasswordsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC6FDBBC1E35CE1E00A280F0 /* PasswordsTableViewController.swift */; };
|
||||
DC917BD71E2E8231000FDF54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC917BD61E2E8231000FDF54 /* AppDelegate.swift */; };
|
||||
DC917BDC1E2E8231000FDF54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDA1E2E8231000FDF54 /* Main.storyboard */; };
|
||||
DC917BDE1E2E8231000FDF54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDD1E2E8231000FDF54 /* Assets.xcassets */; };
|
||||
DC917BE11E2E8231000FDF54 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC917BDF1E2E8231000FDF54 /* LaunchScreen.storyboard */; };
|
||||
DC917BEF1E2F38C5000FDF54 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC917BEE1E2F38C5000FDF54 /* Result.framework */; };
|
||||
DC917BF11E2F38C9000FDF54 /* SwiftGit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */; };
|
||||
DCA049961E3357E000522E8F /* SwiftyUserDefaults.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCA049951E3357E000522E8F /* SwiftyUserDefaults.framework */; };
|
||||
DCA049981E33586A00522E8F /* DefaultKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA049971E33586A00522E8F /* DefaultKeys.swift */; };
|
||||
DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */; };
|
||||
|
|
@ -31,9 +31,10 @@
|
|||
274CCFCF32444A2FF46BE7F4 /* Pods-pass.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.debug.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-pass.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
AEAD6B31EAF5D061447A68CC /* Pods-pass.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.release.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.release.xcconfig"; sourceTree = "<group>"; };
|
||||
DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordsTableViewController.swift; sourceTree = "<group>"; };
|
||||
DC1208571E35EBE60042942E /* ObjectiveGit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjectiveGit.framework; path = Carthage/Build/iOS/ObjectiveGit.framework; sourceTree = "<group>"; };
|
||||
DC3DC8381E2F63240062A988 /* PasswordDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordDetailViewController.swift; sourceTree = "<group>"; };
|
||||
DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Objective-CBridgingHeader.h"; sourceTree = "<group>"; };
|
||||
DC6FDBBC1E35CE1E00A280F0 /* PasswordsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordsTableViewController.swift; sourceTree = "<group>"; };
|
||||
DC917BD31E2E8231000FDF54 /* pass.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = pass.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
DC917BDB1E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
|
|
@ -41,7 +42,6 @@
|
|||
DC917BE01E2E8231000FDF54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
DC917BE21E2E8231000FDF54 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
DC917BEE1E2F38C5000FDF54 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = "<group>"; };
|
||||
DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftGit2.framework; path = Carthage/Build/iOS/SwiftGit2.framework; sourceTree = "<group>"; };
|
||||
DCA049951E3357E000522E8F /* SwiftyUserDefaults.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyUserDefaults.framework; path = Carthage/Build/iOS/SwiftyUserDefaults.framework; sourceTree = "<group>"; };
|
||||
DCA049971E33586A00522E8F /* DefaultKeys.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultKeys.swift; sourceTree = "<group>"; };
|
||||
DCA049991E335CC800522E8F /* GitServerSettingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitServerSettingTableViewController.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -59,8 +59,8 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DC917BEF1E2F38C5000FDF54 /* Result.framework in Frameworks */,
|
||||
DC917BF11E2F38C9000FDF54 /* SwiftGit2.framework in Frameworks */,
|
||||
DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */,
|
||||
DC1208581E35EBE60042942E /* ObjectiveGit.framework in Frameworks */,
|
||||
DCA049961E3357E000522E8F /* SwiftyUserDefaults.framework in Frameworks */,
|
||||
94BA784B85E071D25EE89B59 /* libPods-pass.a in Frameworks */,
|
||||
);
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
DC917BD51E2E8231000FDF54 /* pass */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DC6FDBBC1E35CE1E00A280F0 /* PasswordsTableViewController.swift */,
|
||||
DC1208551E35D0BA0042942E /* PasswordsTableViewController.swift */,
|
||||
DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */,
|
||||
DC917BD61E2E8231000FDF54 /* AppDelegate.swift */,
|
||||
DC917BDA1E2E8231000FDF54 /* Main.storyboard */,
|
||||
|
|
@ -121,9 +121,9 @@
|
|||
DC917BED1E2F38C4000FDF54 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DC1208571E35EBE60042942E /* ObjectiveGit.framework */,
|
||||
DCA049951E3357E000522E8F /* SwiftyUserDefaults.framework */,
|
||||
DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */,
|
||||
DC917BF01E2F38C9000FDF54 /* SwiftGit2.framework */,
|
||||
DC917BEE1E2F38C5000FDF54 /* Result.framework */,
|
||||
ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */,
|
||||
);
|
||||
|
|
@ -254,10 +254,10 @@
|
|||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"$(SRCROOT)/Carthage/Build/iOS/SwiftGit2.framework",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/Result.framework",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/SVProgressHUD.framework",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/SwiftyUserDefaults.framework",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/ObjectiveGit.framework",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
|
|
@ -274,7 +274,7 @@
|
|||
files = (
|
||||
DCC408A41E2FCC9E00F29B0E /* PasswordStore.swift in Sources */,
|
||||
DCA0499C1E3362F400522E8F /* PGPKeySettingTableViewController.swift in Sources */,
|
||||
DC6FDBBD1E35CE1E00A280F0 /* PasswordsTableViewController.swift in Sources */,
|
||||
DC1208561E35D0BA0042942E /* PasswordsTableViewController.swift in Sources */,
|
||||
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
|
||||
DCA0499A1E335CC800522E8F /* GitServerSettingTableViewController.swift in Sources */,
|
||||
DCC277D21E30D6EA00402246 /* pass.xcdatamodeld in Sources */,
|
||||
|
|
@ -409,6 +409,13 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"${PODS_ROOT}/Headers/Public\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/ObjectivePGP\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/OpenSSL-Universal\"",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/ObjectiveGit.framework/Headers/",
|
||||
);
|
||||
INFOPLIST_FILE = pass/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.mssun.pass;
|
||||
|
|
@ -429,6 +436,13 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"${PODS_ROOT}/Headers/Public\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/ObjectivePGP\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/OpenSSL-Universal\"",
|
||||
"$(SRCROOT)/Carthage/Build/iOS/ObjectiveGit.framework/Headers/",
|
||||
);
|
||||
INFOPLIST_FILE = pass/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.mssun.pass;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<!--All-->
|
||||
<scene sceneID="2hn-YS-T8K">
|
||||
<objects>
|
||||
<tableViewController id="vGH-8E-Zez" sceneMemberID="viewController">
|
||||
<tableViewController id="vGH-8E-Zez" customClass="PasswordsTableViewController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Cow-I6-Nig">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
|
@ -47,7 +47,11 @@
|
|||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="All" id="2I8-8c-JEA">
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="JLS-BH-aaR"/>
|
||||
<barButtonItem key="rightBarButtonItem" systemItem="refresh" id="JLS-BH-aaR">
|
||||
<connections>
|
||||
<action selector="refreshPasswords:" destination="vGH-8E-Zez" id="nZd-1L-MFr"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="CHd-Vz-2cA" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@
|
|||
#define Objective_CBridgingHeader_h
|
||||
|
||||
#import <ObjectivePGP/ObjectivePGP.h>
|
||||
#import <ObjectiveGit/ObjectiveGit.h>
|
||||
|
||||
#endif /* Objective_CBridgingHeader_h */
|
||||
|
|
|
|||
|
|
@ -7,26 +7,28 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftGit2
|
||||
import Result
|
||||
import CoreData
|
||||
import UIKit
|
||||
import SwiftyUserDefaults
|
||||
import ObjectiveGit
|
||||
|
||||
class PasswordStore {
|
||||
static let shared = PasswordStore()
|
||||
|
||||
let storeURL = URL(fileURLWithPath: "\(Globals.shared.documentPath)/password-store")
|
||||
var storeRepo: Repository?
|
||||
var storeRepository: GTRepository?
|
||||
|
||||
let pgp: ObjectivePGP = ObjectivePGP()
|
||||
|
||||
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
|
||||
|
||||
|
||||
private init() {
|
||||
let result = Repository.at(storeURL)
|
||||
if case .success(let r) = result {
|
||||
storeRepo = r
|
||||
do {
|
||||
try storeRepository = GTRepository.init(url: storeURL)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
if Defaults[.pgpKeyID] != "" {
|
||||
pgp.importKeys(fromFile: Globals.shared.secringPath, allowDuplicates: false)
|
||||
|
|
@ -52,10 +54,10 @@ class PasswordStore {
|
|||
}
|
||||
|
||||
|
||||
func cloneRemoteRepo(remoteRepoURL: URL) -> Bool {
|
||||
func cloneRepository(remoteRepoURL: URL) -> Bool {
|
||||
print("start cloning remote repo")
|
||||
let fm = FileManager.default
|
||||
if (storeRepo != nil) {
|
||||
if (storeRepository != nil) {
|
||||
print("remove item")
|
||||
do {
|
||||
try fm.removeItem(at: storeURL)
|
||||
|
|
@ -63,14 +65,23 @@ class PasswordStore {
|
|||
print(error.debugDescription)
|
||||
}
|
||||
}
|
||||
let cloneResult = Repository.clone(from: remoteRepoURL, to: storeURL)
|
||||
switch cloneResult {
|
||||
case let .success(clonedRepo):
|
||||
storeRepo = clonedRepo
|
||||
print("clone repo: \(storeURL) success")
|
||||
do {
|
||||
storeRepository = try GTRepository.clone(from: remoteRepoURL, toWorkingDirectory: storeURL, options: nil, transferProgressBlock: nil, checkoutProgressBlock: nil)
|
||||
updatePasswordEntityCoreData()
|
||||
return true
|
||||
case let .failure(error):
|
||||
} catch {
|
||||
print(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
func pullRepository() -> Bool {
|
||||
print("pullRepoisitory")
|
||||
do {
|
||||
let remote = try GTRemote(name: "origin", in: storeRepository!)
|
||||
try storeRepository?.pull((storeRepository?.currentBranch())!, from: remote, withOptions: nil, progress: nil)
|
||||
updatePasswordEntityCoreData()
|
||||
return true
|
||||
} catch {
|
||||
print(error)
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,21 +7,25 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftGit2
|
||||
import Result
|
||||
import SVProgressHUD
|
||||
|
||||
extension PasswordsTableViewController: UISearchResultsUpdating {
|
||||
func updateSearchResults(for searchController: UISearchController) {
|
||||
filterContentForSearchText(searchText: searchController.searchBar.text!)
|
||||
}
|
||||
}
|
||||
|
||||
class PasswordsTableViewController: UITableViewController {
|
||||
private var passwordEntities: [PasswordEntity]?
|
||||
var filteredPasswordEntities = [PasswordEntity]()
|
||||
let searchController = UISearchController(searchResultsController: nil)
|
||||
|
||||
@IBAction func refreshPasswords(_ sender: UIBarButtonItem) {
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
if PasswordStore.shared.pullRepository() {
|
||||
print("pull success")
|
||||
self.passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData()
|
||||
|
|
@ -87,3 +91,10 @@ class PasswordsTableViewController: UITableViewController {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension PasswordsTableViewController: UISearchResultsUpdating {
|
||||
func updateSearchResults(for searchController: UISearchController) {
|
||||
filterContentForSearchText(searchText: searchController.searchBar.text!)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class SettingsTableViewController: UITableViewController {
|
|||
SVProgressHUD.show(withStatus: "Cloning Remote Repository")
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let ret = PasswordStore.shared.cloneRemoteRepo(remoteRepoURL: Defaults[.gitRepositoryURL]!)
|
||||
let ret = PasswordStore.shared.cloneRepository(remoteRepoURL: Defaults[.gitRepositoryURL]!)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if ret {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue