Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43b1632877 | ||
|
|
e1c3e89e09 | ||
|
|
edbd64318c | ||
|
|
b620e0c08e | ||
|
|
dc6a307153 | ||
|
|
ac7f35a976 | ||
|
|
3c7c920c47 | ||
|
|
5a56c22a97 | ||
|
|
cbb2207031 | ||
|
|
712cfc50ea | ||
|
|
39f160344e | ||
|
|
b253e02ac8 | ||
|
|
3dc0712e24 | ||
|
|
827ec79117 | ||
|
|
08c382a327 | ||
|
|
f577819044 | ||
|
|
0842b80a3d | ||
|
|
734d25c15b | ||
|
|
84e7f996ae | ||
|
|
ab0f592aed | ||
|
|
ed618c6fbc | ||
|
|
17a0b7514d | ||
|
|
1e57a9ff00 | ||
|
|
e78fe86a34 | ||
|
|
c8a192f18b | ||
|
|
e7656b1d88 | ||
|
|
62d0e15491 | ||
|
|
5ec4722a20 | ||
|
|
c5cbf4cc17 | ||
|
|
b87b66f11a | ||
|
|
571cdef3c4 | ||
|
|
cc4833b334 |
@@ -1,3 +1,6 @@
|
||||
.vscode/
|
||||
.build/
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
language: objective-c
|
||||
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
osx_image: xcode11.4
|
||||
|
||||
sudo: false # Enable container-based builds
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
github "jspahrsummers/xcconfigs" ~> 1.0
|
||||
github "jspahrsummers/xcconfigs" ~> 1.1
|
||||
github "Quick/Quick" ~> 2.0
|
||||
github "Quick/Nimble" ~> 8.0
|
||||
github "ZipArchive/ZipArchive" ~> 2.0
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
github "Quick/Nimble" "v8.0.1"
|
||||
github "Quick/Quick" "v2.0.0"
|
||||
github "ZipArchive/ZipArchive" "v2.1.5"
|
||||
github "jspahrsummers/xcconfigs" "1.0"
|
||||
github "Quick/Nimble" "v8.1.2"
|
||||
github "Quick/Quick" "v2.2.1"
|
||||
github "ZipArchive/ZipArchive" "v2.2.3"
|
||||
github "jspahrsummers/xcconfigs" "1.1"
|
||||
|
||||
Vendored
+1
-1
Submodule Carthage/Checkouts/Nimble updated: 43304bf2b1...7a46a5fc86
Vendored
+1
-1
Submodule Carthage/Checkouts/Quick updated: 0b4ed6c706...09b3becb37
Vendored
+1
-1
Submodule Carthage/Checkouts/ZipArchive updated: 6017baba3c...f3379e6efa
Vendored
+1
-1
Submodule Carthage/Checkouts/xcconfigs updated: d0f8992afa...4ced0ad5a9
Vendored
+1
-1
Submodule External/libgit2 updated: f23dc5b29f...7f4fa17862
@@ -2,24 +2,31 @@
|
||||
[](https://travis-ci.org/SwiftGit2/SwiftGit2)
|
||||
[](#carthage)
|
||||
[](https://github.com/SwiftGit2/SwiftGit2/releases)
|
||||

|
||||

|
||||
|
||||
Swift bindings to [libgit2](https://github.com/libgit2/libgit2).
|
||||
|
||||
```swift
|
||||
let URL: NSURL = ...
|
||||
let repo = Repository.at(URL)
|
||||
if let repo = repo.value {
|
||||
let latestCommit: Result<Commit, NSError> = repo
|
||||
let URL: URL = ...
|
||||
let result = Repository.at(URL)
|
||||
switch result {
|
||||
case let .success(repo):
|
||||
let latestCommit = repo
|
||||
.HEAD()
|
||||
.flatMap { repo.commit($0.oid) }
|
||||
if let commit = latestCommit.value {
|
||||
.flatMap {
|
||||
repo.commit($0.oid)
|
||||
}
|
||||
|
||||
switch latestCommit {
|
||||
case let .success(commit):
|
||||
print("Latest Commit: \(commit.message) by \(commit.author.name)")
|
||||
} else {
|
||||
print("Could not get commit: \(latestCommit.error)")
|
||||
|
||||
case let .failure(error):
|
||||
print("Could not get commit: \(error)")
|
||||
}
|
||||
} else {
|
||||
println("Could not open repository: \(repo.error)")
|
||||
|
||||
case let .failure(error):
|
||||
print("Could not open repository: \(error)")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -44,6 +51,10 @@ To build SwiftGit2, you'll need the following tools installed locally:
|
||||
* automake
|
||||
* pkg-config
|
||||
|
||||
```
|
||||
brew install cmake libssh2 libtool autoconf automake pkg-config
|
||||
```
|
||||
|
||||
## Adding SwiftGit2 to your Project
|
||||
The easiest way to add SwiftGit2 to your project is to use [Carthage](https://github.com/Carthage/Carthage). Simply add `github "SwiftGit2/SwiftGit2"` to your `Cartfile` and run `carthage update`.
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
237731C71F46542B0020A3FE /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; };
|
||||
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
|
||||
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
|
||||
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
|
||||
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
|
||||
621E66A01C72958800A0F352 /* OID.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E41A1ACB1A002C3F4E /* OID.swift */; };
|
||||
621E66A11C72958800A0F352 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
|
||||
621E66A21C72958800A0F352 /* CheckoutStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE276B281ACCD3CF00D6DAD7 /* CheckoutStrategy.swift */; };
|
||||
@@ -136,6 +138,7 @@
|
||||
232861421F4A3A2E00276D65 /* Diffs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diffs.swift; sourceTree = "<group>"; };
|
||||
237731C61F46542B0020A3FE /* repository-with-status.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "repository-with-status.zip"; sourceTree = "<group>"; };
|
||||
25499A996CA7BD416620A397 /* CommitIterator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommitIterator.swift; sourceTree = "<group>"; };
|
||||
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusOptions.swift; sourceTree = "<group>"; };
|
||||
621E66B41C72958800A0F352 /* SwiftGit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftGit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SwiftGit2-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66E11C729CE500A0F352 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -315,6 +318,7 @@
|
||||
BECB5F691A56F19900999413 /* References.swift */,
|
||||
BECB5F6D1A57284700999413 /* Remotes.swift */,
|
||||
25499A996CA7BD416620A397 /* CommitIterator.swift */,
|
||||
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */,
|
||||
);
|
||||
path = SwiftGit2;
|
||||
sourceTree = "<group>";
|
||||
@@ -593,7 +597,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 1010;
|
||||
LastUpgradeCheck = 1220;
|
||||
ORGANIZATIONNAME = "GitHub, Inc";
|
||||
TargetAttributes = {
|
||||
621E66611C72958800A0F352 = {
|
||||
@@ -756,6 +760,7 @@
|
||||
621E66A71C72958800A0F352 /* Pointers.swift in Sources */,
|
||||
621E66A81C72958800A0F352 /* Errors.swift in Sources */,
|
||||
621E66A91C72958800A0F352 /* SwiftGit2.m in Sources */,
|
||||
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */,
|
||||
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -791,6 +796,7 @@
|
||||
BE7A753F1A4A2BCC002DA7E3 /* Pointers.swift in Sources */,
|
||||
DA5914761A94579000AED74C /* Errors.swift in Sources */,
|
||||
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */,
|
||||
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */,
|
||||
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -928,6 +934,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -936,6 +943,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
@@ -976,6 +984,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F451A0D75EE00F525B9 /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
@@ -991,6 +1000,7 @@
|
||||
baseConfigurationReference = BEB31F471A0D75EE00F525B9 /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
@@ -1083,6 +1093,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1091,6 +1102,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1220"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -41,6 +41,15 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-OSX"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -53,17 +62,6 @@
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-OSX"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -84,8 +82,6 @@
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1220"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -41,6 +41,15 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "621E66611C72958800A0F352"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-iOS"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -53,17 +62,6 @@
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "621E66611C72958800A0F352"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-iOS"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -84,8 +82,6 @@
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// The flags defining how a checkout should be performed.
|
||||
/// More detail is available in the libgit2 documentation for `git_checkout_strategy_t`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public class CommitIterator: IteratorProtocol, Sequence {
|
||||
public typealias Iterator = CommitIterator
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private class Wrapper<T> {
|
||||
let value: T
|
||||
@@ -22,8 +22,23 @@ public enum Credentials {
|
||||
case plaintext(username: String, password: String)
|
||||
case sshMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
|
||||
|
||||
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials {
|
||||
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
|
||||
private static var previouslyUsedPointer: String? = nil
|
||||
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials? {
|
||||
// check if we had just seen this pointer
|
||||
if pointer.debugDescription == previouslyUsedPointer {
|
||||
// we have already used this pointer, so it is likely that libgit2
|
||||
// has already freed the memory and using Unmanaged<>.fromOpaque will
|
||||
// result in a BAD_ACCESS crash
|
||||
return nil
|
||||
} else {
|
||||
// mark that we have used this pointer so that
|
||||
// later attempts to use it in this function will
|
||||
// be blocked
|
||||
previouslyUsedPointer = pointer.debugDescription
|
||||
// access the pointer and convert it into a
|
||||
// Credentials Swift object
|
||||
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
|
||||
}
|
||||
}
|
||||
|
||||
internal func toPointer() -> UnsafeMutableRawPointer {
|
||||
@@ -55,6 +70,8 @@ internal func credentialsCallback(
|
||||
result = git_cred_userpass_plaintext_new(cred, username, password)
|
||||
case .sshMemory(let username, let publicKey, let privateKey, let passphrase):
|
||||
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
|
||||
default:
|
||||
result = git_cred_default_new(cred)
|
||||
}
|
||||
|
||||
return (result != GIT_OK.rawValue) ? -1 : 0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2017 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public struct StatusEntry {
|
||||
public var status: Diff.Status
|
||||
@@ -32,7 +32,7 @@ public struct Diff {
|
||||
public var deltas = [Delta]()
|
||||
|
||||
public struct Delta {
|
||||
public static let type = GIT_OBJ_REF_DELTA
|
||||
public static let type = GIT_OBJECT_REF_DELTA
|
||||
|
||||
public var status: Status
|
||||
public var flags: Flags
|
||||
@@ -50,7 +50,7 @@ public struct Diff {
|
||||
public struct File {
|
||||
public var oid: OID
|
||||
public var path: String
|
||||
public var size: Int64
|
||||
public var size: UInt64
|
||||
public var flags: Flags
|
||||
|
||||
public init(_ diffFile: git_diff_file) {
|
||||
@@ -94,7 +94,7 @@ public struct Diff {
|
||||
}
|
||||
public let rawValue: UInt32
|
||||
|
||||
public static let binary = Flags(rawValue: 0)
|
||||
public static let binary = Flags([])
|
||||
public static let notBinary = Flags(rawValue: 1 << 0)
|
||||
public static let validId = Flags(rawValue: 1 << 1)
|
||||
public static let exists = Flags(rawValue: 1 << 2)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public let libGit2ErrorDomain = "org.libgit2.libgit2"
|
||||
|
||||
@@ -42,7 +42,7 @@ private func errorMessage(_ errorCode: Int32) -> String? {
|
||||
let last = giterr_last()
|
||||
if let lastErrorPointer = last {
|
||||
return String(validatingUTF8: lastErrorPointer.pointee.message)
|
||||
} else if UInt32(errorCode) == GITERR_OS.rawValue {
|
||||
} else if UInt32(errorCode) == GIT_ERROR_OS.rawValue {
|
||||
return String(validatingUTF8: strerror(errno))
|
||||
} else {
|
||||
return nil
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
extension git_strarray {
|
||||
func filter(_ isIncluded: (String) -> Bool) -> [String] {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// An identifier for a Git object.
|
||||
public struct OID {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A git object.
|
||||
public protocol ObjectType {
|
||||
static var type: git_otype { get }
|
||||
static var type: git_object_t { get }
|
||||
|
||||
/// The OID of the object.
|
||||
var oid: OID { get }
|
||||
@@ -84,7 +84,7 @@ extension Signature: Hashable {
|
||||
|
||||
/// A git commit.
|
||||
public struct Commit: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_COMMIT
|
||||
public static let type = GIT_OBJECT_COMMIT
|
||||
|
||||
/// The OID of the commit.
|
||||
public let oid: OID
|
||||
@@ -120,7 +120,7 @@ public struct Commit: ObjectType, Hashable {
|
||||
|
||||
/// A git tree.
|
||||
public struct Tree: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_TREE
|
||||
public static let type = GIT_OBJECT_TREE
|
||||
|
||||
/// An entry in a `Tree`.
|
||||
public struct Entry: Hashable {
|
||||
@@ -176,7 +176,7 @@ extension Tree.Entry: CustomStringConvertible {
|
||||
|
||||
/// A git blob.
|
||||
public struct Blob: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_BLOB
|
||||
public static let type = GIT_OBJECT_BLOB
|
||||
|
||||
/// The OID of the blob.
|
||||
public let oid: OID
|
||||
@@ -195,7 +195,7 @@ public struct Blob: ObjectType, Hashable {
|
||||
|
||||
/// An annotated git tag.
|
||||
public struct Tag: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_TAG
|
||||
public static let type = GIT_OBJECT_TAG
|
||||
|
||||
/// The OID of the tag.
|
||||
public let oid: OID
|
||||
|
||||
+15
-15
@@ -6,15 +6,15 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A pointer to a git object.
|
||||
public protocol PointerType: Hashable {
|
||||
/// The OID of the referenced object.
|
||||
var oid: OID { get }
|
||||
|
||||
/// The libgit2 `git_otype` of the referenced object.
|
||||
var type: git_otype { get }
|
||||
/// The libgit2 `git_object_t` of the referenced object.
|
||||
var type: git_object_t { get }
|
||||
}
|
||||
|
||||
public extension PointerType {
|
||||
@@ -48,29 +48,29 @@ public enum Pointer: PointerType {
|
||||
}
|
||||
}
|
||||
|
||||
public var type: git_otype {
|
||||
public var type: git_object_t {
|
||||
switch self {
|
||||
case .commit:
|
||||
return GIT_OBJ_COMMIT
|
||||
return GIT_OBJECT_COMMIT
|
||||
case .tree:
|
||||
return GIT_OBJ_TREE
|
||||
return GIT_OBJECT_TREE
|
||||
case .blob:
|
||||
return GIT_OBJ_BLOB
|
||||
return GIT_OBJECT_BLOB
|
||||
case .tag:
|
||||
return GIT_OBJ_TAG
|
||||
return GIT_OBJECT_TAG
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an instance with an OID and a libgit2 `git_otype`.
|
||||
init?(oid: OID, type: git_otype) {
|
||||
/// Create an instance with an OID and a libgit2 `git_object_t`.
|
||||
init?(oid: OID, type: git_object_t) {
|
||||
switch type {
|
||||
case GIT_OBJ_COMMIT:
|
||||
case GIT_OBJECT_COMMIT:
|
||||
self = .commit(oid)
|
||||
case GIT_OBJ_TREE:
|
||||
case GIT_OBJECT_TREE:
|
||||
self = .tree(oid)
|
||||
case GIT_OBJ_BLOB:
|
||||
case GIT_OBJECT_BLOB:
|
||||
self = .blob(oid)
|
||||
case GIT_OBJ_TAG:
|
||||
case GIT_OBJECT_TAG:
|
||||
self = .tag(oid)
|
||||
default:
|
||||
return nil
|
||||
@@ -96,7 +96,7 @@ extension Pointer: CustomStringConvertible {
|
||||
public struct PointerTo<T: ObjectType>: PointerType {
|
||||
public let oid: OID
|
||||
|
||||
public var type: git_otype {
|
||||
public var type: git_object_t {
|
||||
return T.type
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A reference to a git object.
|
||||
public protocol ReferenceType {
|
||||
@@ -107,7 +107,7 @@ public struct Branch: ReferenceType, Hashable {
|
||||
longName = String(validatingUTF8: git_reference_name(pointer))!
|
||||
|
||||
var oid: OID
|
||||
if git_reference_type(pointer).rawValue == GIT_REF_SYMBOLIC.rawValue {
|
||||
if git_reference_type(pointer).rawValue == GIT_REFERENCE_SYMBOLIC.rawValue {
|
||||
var resolved: OpaquePointer? = nil
|
||||
let success = git_reference_resolve(&resolved, pointer)
|
||||
guard success == GIT_OK.rawValue else {
|
||||
@@ -178,7 +178,7 @@ public enum TagReference: ReferenceType, Hashable {
|
||||
var oid = git_reference_target(pointer).pointee
|
||||
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG)
|
||||
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJECT_TAG)
|
||||
if result == GIT_OK.rawValue {
|
||||
self = .annotated(name, Tag(pointer!))
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A remote in a git repository.
|
||||
public struct Remote: Hashable {
|
||||
|
||||
+24
-22
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
|
||||
|
||||
@@ -206,7 +206,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the result of calling `transform` or an error if the object
|
||||
/// cannot be loaded.
|
||||
private func withGitObject<T>(_ oid: OID, type: git_otype,
|
||||
private func withGitObject<T>(_ oid: OID, type: git_object_t,
|
||||
transform: (OpaquePointer) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
var oid = oid.oid
|
||||
@@ -221,11 +221,11 @@ public final class Repository {
|
||||
return value
|
||||
}
|
||||
|
||||
private func withGitObject<T>(_ oid: OID, type: git_otype, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
|
||||
private func withGitObject<T>(_ oid: OID, type: git_object_t, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
|
||||
return withGitObject(oid, type: type) { Result.success(transform($0)) }
|
||||
}
|
||||
|
||||
private func withGitObjects<T>(_ oids: [OID], type: git_otype, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
private func withGitObjects<T>(_ oids: [OID], type: git_object_t, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
var pointers = [OpaquePointer]()
|
||||
defer {
|
||||
for pointer in pointers {
|
||||
@@ -254,7 +254,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns a `Blob`, `Commit`, `Tag`, or `Tree` if one exists, or an error.
|
||||
public func object(_ oid: OID) -> Result<ObjectType, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_ANY) { object in
|
||||
return withGitObject(oid, type: GIT_OBJECT_ANY) { object in
|
||||
let type = git_object_type(object)
|
||||
if type == Blob.type {
|
||||
return Result.success(Blob(object))
|
||||
@@ -270,7 +270,7 @@ public final class Repository {
|
||||
domain: "org.libgit2.SwiftGit2",
|
||||
code: 1,
|
||||
userInfo: [
|
||||
NSLocalizedDescriptionKey: "Unrecognized git_otype '\(type)' for oid '\(oid)'.",
|
||||
NSLocalizedDescriptionKey: "Unrecognized git_object_t '\(type)' for oid '\(oid)'.",
|
||||
]
|
||||
)
|
||||
return Result.failure(error)
|
||||
@@ -283,7 +283,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the blob if it exists, or an error.
|
||||
public func blob(_ oid: OID) -> Result<Blob, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_BLOB) { Blob($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_BLOB) { Blob($0) }
|
||||
}
|
||||
|
||||
/// Loads the commit with the given OID.
|
||||
@@ -292,7 +292,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the commit if it exists, or an error.
|
||||
public func commit(_ oid: OID) -> Result<Commit, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { Commit($0) }
|
||||
}
|
||||
|
||||
/// Loads the tag with the given OID.
|
||||
@@ -301,7 +301,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the tag if it exists, or an error.
|
||||
public func tag(_ oid: OID) -> Result<Tag, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_TAG) { Tag($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_TAG) { Tag($0) }
|
||||
}
|
||||
|
||||
/// Loads the tree with the given OID.
|
||||
@@ -310,7 +310,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the tree if it exists, or an error.
|
||||
public func tree(_ oid: OID) -> Result<Tree, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_TREE) { Tree($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_TREE) { Tree($0) }
|
||||
}
|
||||
|
||||
/// Loads the referenced object from the pointer.
|
||||
@@ -588,9 +588,10 @@ public final class Repository {
|
||||
|
||||
/// Stage the file(s) under the specified path.
|
||||
public func add(path: String) -> Result<(), NSError> {
|
||||
let dir = path
|
||||
var dirPointer = UnsafeMutablePointer<Int8>(mutating: (dir as NSString).utf8String)
|
||||
var paths = git_strarray(strings: &dirPointer, count: 1)
|
||||
var dirPointer = UnsafeMutablePointer<Int8>(mutating: (path as NSString).utf8String)
|
||||
var paths = withUnsafeMutablePointer(to: &dirPointer) {
|
||||
git_strarray(strings: $0, count: 1)
|
||||
}
|
||||
return unsafeIndex().flatMap { index in
|
||||
defer { git_index_free(index) }
|
||||
let addResult = git_index_add_all(index, &paths, 0, nil, nil)
|
||||
@@ -795,7 +796,7 @@ public final class Repository {
|
||||
}
|
||||
|
||||
if oldTree != nil && newTree != nil {
|
||||
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJ_TREE) { objects in
|
||||
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJECT_TREE) { objects in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -805,7 +806,7 @@ public final class Repository {
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
}
|
||||
} else if let tree = oldTree {
|
||||
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
|
||||
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -815,7 +816,7 @@ public final class Repository {
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
})
|
||||
} else if let tree = newTree {
|
||||
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
|
||||
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -857,7 +858,7 @@ public final class Repository {
|
||||
}
|
||||
|
||||
private func safeTreeForCommitId(_ oid: OID) -> Result<Tree, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_COMMIT) { commit in
|
||||
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { commit in
|
||||
let treeId = git_commit_tree_id(commit)
|
||||
return tree(OID(treeId!.pointee))
|
||||
}
|
||||
@@ -867,14 +868,14 @@ public final class Repository {
|
||||
private func unsafeTreeForCommitId(_ oid: OID) -> Result<OpaquePointer, NSError> {
|
||||
var commit: OpaquePointer? = nil
|
||||
var oid = oid.oid
|
||||
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJ_COMMIT)
|
||||
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJECT_COMMIT)
|
||||
guard commitResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: commitResult, pointOfFailure: "git_object_lookup"))
|
||||
}
|
||||
|
||||
var tree: OpaquePointer? = nil
|
||||
let treeId = git_commit_tree_id(commit)
|
||||
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJ_TREE)
|
||||
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJECT_TREE)
|
||||
|
||||
git_object_free(commit)
|
||||
|
||||
@@ -887,7 +888,7 @@ public final class Repository {
|
||||
|
||||
// MARK: - Status
|
||||
|
||||
public func status() -> Result<[StatusEntry], NSError> {
|
||||
public func status(options: StatusOptions = [.includeUntracked]) -> Result<[StatusEntry], NSError> {
|
||||
var returnArray = [StatusEntry]()
|
||||
|
||||
// Do this because GIT_STATUS_OPTIONS_INIT is unavailable in swift
|
||||
@@ -896,12 +897,13 @@ public final class Repository {
|
||||
guard optionsResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options"))
|
||||
}
|
||||
var options = pointer.move()
|
||||
var listOptions = pointer.move()
|
||||
listOptions.flags = options.rawValue
|
||||
pointer.deallocate()
|
||||
|
||||
var unsafeStatus: OpaquePointer? = nil
|
||||
defer { git_status_list_free(unsafeStatus) }
|
||||
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &options)
|
||||
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &listOptions)
|
||||
guard statusResult == GIT_OK.rawValue, let unwrapStatusResult = unsafeStatus else {
|
||||
return .failure(NSError(gitError: statusResult, pointOfFailure: "git_status_list_new"))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Copyright © 2020 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Clibgit2
|
||||
import Foundation
|
||||
|
||||
public struct StatusOptions: OptionSet {
|
||||
public let rawValue: UInt32
|
||||
|
||||
public init(rawValue: UInt32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let includeUntracked = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNTRACKED.rawValue
|
||||
)
|
||||
public static let includeIgnored = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_IGNORED.rawValue
|
||||
)
|
||||
public static let includeUnmodified = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNMODIFIED.rawValue
|
||||
)
|
||||
public static let excludeSubmodules = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_EXCLUDE_SUBMODULES.rawValue
|
||||
)
|
||||
public static let recurseUntrackedDirs = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS.rawValue
|
||||
)
|
||||
public static let disablePathSpecMatch = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH.rawValue
|
||||
)
|
||||
public static let recurseIgnoredDirs = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RECURSE_IGNORED_DIRS.rawValue
|
||||
)
|
||||
public static let renamesHeadToIndex = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX.rawValue
|
||||
)
|
||||
public static let renamesIndexToWorkDir = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR.rawValue
|
||||
)
|
||||
public static let sortCasesSensitively = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_SORT_CASE_SENSITIVELY.rawValue
|
||||
)
|
||||
public static let sortCasesInSensitively = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY.rawValue
|
||||
)
|
||||
public static let renamesFromRewrites = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_FROM_REWRITES.rawValue
|
||||
)
|
||||
public static let noRefresh = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_NO_REFRESH.rawValue
|
||||
)
|
||||
public static let updateIndex = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_UPDATE_INDEX.rawValue
|
||||
)
|
||||
public static let includeUnreadable = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNREADABLE.rawValue
|
||||
)
|
||||
public static let includeUnreadableAsUntracked = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED.rawValue
|
||||
)
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitObject<T>(_ oid: OID, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -17,7 +17,7 @@ private extension Repository {
|
||||
var oid = oid.oid
|
||||
|
||||
var pointer: OpaquePointer? = nil
|
||||
git_object_lookup(&pointer, repository, &oid, GIT_OBJ_ANY)
|
||||
git_object_lookup(&pointer, repository, &oid, GIT_OBJECT_ANY)
|
||||
let result = transform(pointer!)
|
||||
git_object_free(pointer)
|
||||
|
||||
@@ -25,7 +25,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class SignatureSpec: QuickSpec {
|
||||
class SignatureSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Signature(signature)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitReference<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -24,7 +24,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceSpec: QuickSpec {
|
||||
class ReferenceSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Reference(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitRemote<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -24,7 +24,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteSpec: QuickSpec {
|
||||
class RemoteSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Remote(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -12,7 +12,7 @@ import Quick
|
||||
|
||||
// swiftlint:disable cyclomatic_complexity
|
||||
|
||||
class RepositorySpec: QuickSpec {
|
||||
class RepositorySpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Repository.Type.at(_:)") {
|
||||
it("should work if the repo exists") {
|
||||
@@ -776,7 +776,7 @@ class RepositorySpec: QuickSpec {
|
||||
}
|
||||
|
||||
it("Should accurately report status for repositories with status") {
|
||||
let expectedCount = 5
|
||||
let expectedCount = 6
|
||||
let expectedNewFilePaths = [
|
||||
"stage-file-1",
|
||||
"stage-file-2",
|
||||
@@ -791,6 +791,9 @@ class RepositorySpec: QuickSpec {
|
||||
"stage-file-4",
|
||||
"stage-file-5",
|
||||
]
|
||||
let expectedUntrackedFiles = [
|
||||
"unstaged-file",
|
||||
]
|
||||
|
||||
let repoWithStatus = Fixtures.sharedInstance.repository(named: "repository-with-status")
|
||||
let branchWithStatus = repoWithStatus.localBranch(named: "master").value!
|
||||
@@ -800,16 +803,28 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
var newFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
newFilePaths.append((status.headToIndex?.newFile?.path)!)
|
||||
if let path = status.headToIndex?.newFile?.path {
|
||||
newFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
var oldFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
oldFilePaths.append((status.headToIndex?.oldFile?.path)!)
|
||||
if let path = status.headToIndex?.oldFile?.path {
|
||||
oldFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
|
||||
var newUntrackedFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
if let path = status.indexToWorkDir?.newFile?.path {
|
||||
newUntrackedFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
|
||||
expect(statuses.count).to(equal(expectedCount))
|
||||
expect(newFilePaths).to(equal(expectedNewFilePaths))
|
||||
expect(oldFilePaths).to(equal(expectedOldFilePaths))
|
||||
expect(newUntrackedFilePaths).to(equal(expectedUntrackedFiles))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module libgit2 {
|
||||
module Clibgit2 {
|
||||
umbrella header "git2.h"
|
||||
|
||||
export *
|
||||
|
||||
+2
-2
@@ -69,8 +69,8 @@ elif [ "$SCHEME" == "SwiftGit2-iOS" ]; then
|
||||
# "The requested device could not be found because no available devices matched the request."
|
||||
# "The requested device could not be found because multiple devices matched the request."
|
||||
SIMULATOR_NAME="Custom Simulator"
|
||||
DEVICE_ID=com.apple.CoreSimulator.SimDeviceType.iPhone-5
|
||||
RUNTIME_ID=com.apple.CoreSimulator.SimRuntime.iOS-10-2
|
||||
DEVICE_ID=com.apple.CoreSimulator.SimDeviceType.iPhone-X
|
||||
RUNTIME_ID=com.apple.CoreSimulator.SimRuntime.iOS-11-4
|
||||
DESTINATION_ID=$(xcrun simctl create "$SIMULATOR_NAME" $DEVICE_ID $RUNTIME_ID)
|
||||
|
||||
echo "*** Building and testing $SCHEME..."
|
||||
|
||||
Reference in New Issue
Block a user