ios - Objective-Git 的拉/推问题
问题描述
我正在尝试使用 iOS 应用程序拉取和推送存储库。我正在使用 Objective-Git 和 Swift。
我做了一个简单的拉和推类:
class Push: NSObject {
func push(_ url: URL?, options: NSDictionary?, progress: ((UInt32, UInt32, Int, UnsafeMutablePointer<ObjCBool>) -> Void)?) -> Bool {
let repo = try? GTRepository(url: url!)
let branches = try! repo?.branches()
let remotes = try! repo?.remoteNames()
let remote = try? GTRemote(name: (remotes?[0])!, in: repo!)
do {
try repo?.pushBranches(branches!, to: remote!, withOptions: options as? [AnyHashable : Any], progress: progress)
} catch {
print("Couldn't push")
}
return true
}
func pull(_ url: URL?, options: NSDictionary?, progress: @escaping (UnsafePointer<git_transfer_progress>, UnsafeMutablePointer<ObjCBool>) -> ()) -> Bool {
let repo = try? GTRepository(url: url!)
let branches = try! repo?.branches()
let remotes = try? repo?.remoteNames()
let remote = try? GTRemote(name: remotes!![0], in: repo!)
do {
try repo?.pull(branches![0], from: remote!, withOptions: options as? [AnyHashable : Any], progress: progress)
} catch {
print("Couldn't pull")
}
return true
}
func creds(creds: GTCredential?) -> NSDictionary? {
let gtcp = GTCredentialProvider { (type, a, b) -> GTCredential? in
return creds
}
let d: NSDictionary = [
"GTRepositoryRemoteOptionsCredentialProvider": gtcp
]
return d
}
}
不幸的是,当我尝试使用正确的凭据拉/推回购时,它不起作用
有什么想法可以解决这个问题吗?我找不到任何做这种事情的例子,所以也许我的代码完全错误。
解决方案
推荐阅读
- java - Android DataBindingUtil.inflate 总是返回 null
- ios - Xcode 10,实现代码覆盖的最小努力
- reactjs - 如何构建供 HTML 应用程序使用的 React 组件?
- sql - 按年份和比例排列数据
- c# - 样板上的 CA1304
- django - Django - @login_required 装饰器,同时使用表单 POST 传递参数
- angular - Is there a way to use background colors instead of primary for some components using material dark theme?
- json - 如何将一个值与前一个对象进行比较?
- c++ - C++ 定义/赋值语法
- android-studio - 我是 Flutter 新手,在运行我的第一个应用程序时遇到了错误