Compare commits
254 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6148d1b3d4 | |||
| 27d2f38b6a | |||
| f04fe39df5 | |||
| c2e903a521 | |||
| 8a8eef6e54 | |||
| 4cee705dd9 | |||
| 77ae788bf6 | |||
| 158ba52f3d | |||
| 782a1fad2f | |||
| 386a21f46c | |||
| e77e3e17db | |||
| 3ce0d32a3b | |||
| 2adf4e1d35 | |||
| b0e94f89fe | |||
| 52b602674b | |||
| c7f4a14ae4 | |||
| 775b054be0 | |||
| 5b8f53263e | |||
| 4949d68379 | |||
| c6d8fa3b07 | |||
| 0c79b59fb0 | |||
| f69eee9b9b | |||
| 9e90f7c3ba | |||
| 71cbc53e75 | |||
| 6058febb36 | |||
| 39aca8e650 | |||
| 1e7c415fd2 | |||
| c181172606 | |||
| a7653667f4 | |||
| 3bbff975c0 | |||
| 6fb4054d38 | |||
| db091b107e | |||
| e76de59957 | |||
| e7315035df | |||
| 9343544dc9 | |||
| 2b7899198d | |||
| 11ca78320d | |||
| f00bb4699a | |||
| d176b1afaf | |||
| 3ebe0d82a8 | |||
| 8c461732df | |||
| bcccf31665 | |||
| edbd64318c | |||
| b620e0c08e | |||
| dc6a307153 | |||
| ac7f35a976 | |||
| cbb2207031 | |||
| 712cfc50ea | |||
| b253e02ac8 | |||
| 3dc0712e24 | |||
| 827ec79117 | |||
| 08c382a327 | |||
| f577819044 | |||
| 0842b80a3d | |||
| 734d25c15b | |||
| 84e7f996ae | |||
| ab0f592aed | |||
| ed618c6fbc | |||
| 17a0b7514d | |||
| 1e57a9ff00 | |||
| e78fe86a34 | |||
| c8a192f18b | |||
| e7656b1d88 | |||
| 62d0e15491 | |||
| 5ec4722a20 | |||
| c5cbf4cc17 | |||
| b87b66f11a | |||
| 571cdef3c4 | |||
| cc4833b334 | |||
| 3adf7e4205 | |||
| 80f4e60071 | |||
| cd3735cd71 | |||
| 71e9b51a52 | |||
| 9becf1cab0 | |||
| 690f6c9370 | |||
| 19e24dd7d8 | |||
| cb5567d6a5 | |||
| 452979bd64 | |||
| 3db2f74ac4 | |||
| d878fea696 | |||
| 18c4cd8598 | |||
| 00e23d3930 | |||
| df7bd3c2a3 | |||
| c452b80da3 | |||
| e41b2f92a5 | |||
| 12f7d8377d | |||
| e1acee35d6 | |||
| 743083d19d | |||
| 778596b71a | |||
| 00014ab96f | |||
| fb6020ad08 | |||
| d7699324a0 | |||
| dcf36660aa | |||
| 82e873eac8 | |||
| 3a38e20b0c | |||
| dcbbf4cc53 | |||
| 619c2bd165 | |||
| 45be21756c | |||
| 0a1a5d4174 | |||
| 31a755dd49 | |||
| 9f3f9034ee | |||
| ce2443bb3b | |||
| 6c27045ee8 | |||
| 0c9fbe19ee | |||
| 9d2b5e5b87 | |||
| cedeccf6f7 | |||
| 17ff9cf4f5 | |||
| cdfacb944b | |||
| cd9930cc1e | |||
| 56b3907ecf | |||
| 53438583ca | |||
| cf24dc9ed6 | |||
| e16d5c6baa | |||
| a8d0000168 | |||
| 7a7d9280ef | |||
| ef9a46c86b | |||
| 310e7a4167 | |||
| e65206c00c | |||
| f811db8047 | |||
| 8087272bc2 | |||
| 74fe90393f | |||
| 0cb2f8acc5 | |||
| 57cada1356 | |||
| 6d7cde7fe7 | |||
| 08d03fac7c | |||
| db5c22b3a7 | |||
| b29e18833d | |||
| 455ac1143f | |||
| c5017fc6c9 | |||
| 4111097604 | |||
| f152ad76b7 | |||
| 4c7aa2a276 | |||
| e6db3c0896 | |||
| 84d4ae1e33 | |||
| 3d6094b741 | |||
| 026548be12 | |||
| 3db2d73e6e | |||
| f229778abb | |||
| b193c80dc0 | |||
| 25f3ecc4e6 | |||
| 81d2fb210a | |||
| b6e94b291c | |||
| f9d7bd3b61 | |||
| 280ab5b473 | |||
| fb2fa2b5bc | |||
| b1d3488d4c | |||
| 814b954956 | |||
| 4d76f87912 | |||
| d35dac654c | |||
| 97ee009ac5 | |||
| 6e5703dab7 | |||
| 1f23feb0c5 | |||
| 118ba43fce | |||
| 6f59ce5cf3 | |||
| 11ac4767bb | |||
| c5f3b2ccfe | |||
| 0dab27d07b | |||
| 0397b29d24 | |||
| 1a369b7e9e | |||
| 87af7fcb32 | |||
| 98fcae405e | |||
| 28a1757dbe | |||
| 9a9b7a9be8 | |||
| 26f1bb7c86 | |||
| ecb5263f6b | |||
| f98664ecb3 | |||
| c0c382227e | |||
| 225f391171 | |||
| d7fff2c643 | |||
| d8ee830173 | |||
| c7bf00201e | |||
| 69413a0540 | |||
| 3f989ab522 | |||
| 9884657da6 | |||
| afaa96ec57 | |||
| 09ac23471b | |||
| db0a955e03 | |||
| a9f79a3b80 | |||
| e7b6e4509f | |||
| efe1d6eeeb | |||
| 6a59e6557e | |||
| 8bb6e30ff4 | |||
| d7154e6f40 | |||
| 5f4043bb0e | |||
| 3b9beac923 | |||
| 0d56e1b1ce | |||
| 2cff52a3d3 | |||
| 8730bb2d8d | |||
| 046d67ed97 | |||
| 48b804846f | |||
| bf2bc2ed88 | |||
| 42619872f8 | |||
| 99b638131c | |||
| edb1906231 | |||
| 253cf53d2e | |||
| 95c7da4e1b | |||
| f422571d38 | |||
| 6fc4a0c7bb | |||
| 2173a68e93 | |||
| b582e1e642 | |||
| c4388f0a07 | |||
| 82e90d3c75 | |||
| 1af59416d9 | |||
| c5eb8036d0 | |||
| 31680a50a3 | |||
| 593c4069b5 | |||
| f635f50b84 | |||
| 242741a950 | |||
| 5d0255b84c | |||
| 7ecfb710d3 | |||
| 18691cb4e6 | |||
| 06a3b62014 | |||
| a58f849456 | |||
| 8d1aaa672f | |||
| dfc2614cb2 | |||
| 9520fa03a6 | |||
| c4b7ce3716 | |||
| 8088f8b11f | |||
| 42d92319ef | |||
| d09d1f49b3 | |||
| 46cad0e668 | |||
| 500ae6dc90 | |||
| c7b8ae914f | |||
| 4dd24cad97 | |||
| 23194dd7a3 | |||
| 915b07f4a9 | |||
| 96e9cf61a7 | |||
| aa9f066e04 | |||
| de2984c695 | |||
| dc2edddac6 | |||
| e69e5ca153 | |||
| 23abfc6f6a | |||
| 3b04a2b94a | |||
| 66866049ee | |||
| 9eb91a8605 | |||
| 18ee34f681 | |||
| baa619520d | |||
| d6d9d77488 | |||
| 43d26912a1 | |||
| 0785b70123 | |||
| 20365249f9 | |||
| 9a2f5a5b31 | |||
| 3c5ffa2ba5 | |||
| 6257318a34 | |||
| f2d94c4322 | |||
| d1d0118bba | |||
| c57ea50b85 | |||
| 5b41c977d2 | |||
| 4cadad501e | |||
| bb387eb7ab | |||
| f10c8d03dd | |||
| 31a0a3dd30 | |||
| b074eff7d7 | |||
| e42270372c |
@@ -1,3 +1,6 @@
|
||||
.vscode/
|
||||
.build/
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
@@ -17,8 +20,10 @@ DerivedData
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
*.xcscmblueprint
|
||||
*.idea*
|
||||
|
||||
External/libgit2*.a
|
||||
External/libgit2-mac
|
||||
External/ios-openssl
|
||||
External/libgit2-ios
|
||||
External/libssh2-ios
|
||||
|
||||
+2
-6
@@ -1,9 +1,6 @@
|
||||
[submodule "External/libgit2"]
|
||||
path = External/libgit2
|
||||
url = https://github.com/libgit2/libgit2.git
|
||||
[submodule "Carthage/Checkouts/Guanaco"]
|
||||
path = Carthage/Checkouts/Guanaco
|
||||
url = https://github.com/modocache/Guanaco.git
|
||||
[submodule "Carthage/Checkouts/Nimble"]
|
||||
path = Carthage/Checkouts/Nimble
|
||||
url = https://github.com/Quick/Nimble.git
|
||||
@@ -13,9 +10,6 @@
|
||||
[submodule "Carthage/Checkouts/xcconfigs"]
|
||||
path = Carthage/Checkouts/xcconfigs
|
||||
url = https://github.com/jspahrsummers/xcconfigs.git
|
||||
[submodule "Carthage/Checkouts/Result"]
|
||||
path = Carthage/Checkouts/Result
|
||||
url = https://github.com/antitypical/Result.git
|
||||
[submodule "Carthage/Checkouts/ZipArchive"]
|
||||
path = Carthage/Checkouts/ZipArchive
|
||||
url = https://github.com/ZipArchive/ZipArchive.git
|
||||
@@ -25,3 +19,5 @@
|
||||
[submodule "External/openssl"]
|
||||
path = External/openssl
|
||||
url = https://github.com/openssl/openssl.git
|
||||
[submodule "libgit2"]
|
||||
url = https://github.com/libgit2/libgit2.git
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Configuration for Hound (https://houndci.com)
|
||||
|
||||
swiftlint:
|
||||
config_file: .swiftlint.yml
|
||||
@@ -3,26 +3,74 @@ disabled_rules:
|
||||
- force_cast
|
||||
- force_try
|
||||
- function_body_length
|
||||
- identifier_name
|
||||
- redundant_optional_initialization
|
||||
- type_body_length
|
||||
|
||||
opt_in_rules:
|
||||
- array_init
|
||||
- attributes
|
||||
- closure_end_indentation
|
||||
- closure_spacing
|
||||
- collection_alignment
|
||||
- conditional_returns_on_newline
|
||||
- contains_over_first_not_nil
|
||||
- convenience_type
|
||||
- discouraged_object_literal
|
||||
- discouraged_optional_boolean
|
||||
- discouraged_optional_collection
|
||||
- empty_count
|
||||
- empty_string
|
||||
- empty_xctest_method
|
||||
- explicit_enum_raw_value
|
||||
- explicit_init
|
||||
- extension_access_modifier
|
||||
- fallthrough
|
||||
- fatal_error_message
|
||||
- first_where
|
||||
- function_default_parameter_at_end
|
||||
- identical_operands
|
||||
- implicitly_unwrapped_optional
|
||||
- joined_default_parameter
|
||||
- last_where
|
||||
- legacy_random
|
||||
- literal_expression_end_indentation
|
||||
- lower_acl_than_parent
|
||||
- modifier_order
|
||||
- multiline_arguments
|
||||
- multiline_function_chains
|
||||
- multiline_literal_brackets
|
||||
- nslocalizedstring_key
|
||||
- overridden_super_call
|
||||
- override_in_extension
|
||||
- private_action
|
||||
- private_outlet
|
||||
- prohibited_super_call
|
||||
- quick_discouraged_call
|
||||
- quick_discouraged_focused_test
|
||||
- quick_discouraged_pending_test
|
||||
- redundant_nil_coalescing
|
||||
- redundant_type_annotation
|
||||
- sorted_first_last
|
||||
- static_operator
|
||||
- strict_fileprivate
|
||||
- switch_case_on_newline
|
||||
- toggle_bool
|
||||
- unavailable_function
|
||||
- untyped_error_in_catch
|
||||
- unused_import
|
||||
- unused_private_declaration
|
||||
- vertical_parameter_alignment_on_call
|
||||
- xct_specific_matcher
|
||||
- yoda_condition
|
||||
|
||||
excluded:
|
||||
- Carthage
|
||||
- External
|
||||
|
||||
line_length:
|
||||
ignores_function_declarations: true
|
||||
|
||||
trailing_comma:
|
||||
mandatory_comma: true
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
language: objective-c
|
||||
|
||||
osx_image: xcode8.2
|
||||
os: osx
|
||||
osx_image: xcode11.4
|
||||
|
||||
sudo: false # Enable container-based builds
|
||||
|
||||
|
||||
+4
-5
@@ -1,5 +1,4 @@
|
||||
github "jspahrsummers/xcconfigs" >= 0.10
|
||||
github "Quick/Quick" ~> 1.0
|
||||
github "Quick/Nimble" ~> 5.0
|
||||
github "modocache/Guanaco" "6b85ad93b4e7fde8a59d23f94c438a97e1696293"
|
||||
github "ZipArchive/ZipArchive" ~> 1.6
|
||||
github "jspahrsummers/xcconfigs" ~> 1.1
|
||||
github "Quick/Quick" ~> 7.0
|
||||
github "Quick/Nimble" ~> 12.0
|
||||
github "ZipArchive/ZipArchive" ~> 2.0
|
||||
|
||||
+4
-6
@@ -1,6 +1,4 @@
|
||||
github "Quick/Nimble" "v5.1.1"
|
||||
github "Quick/Quick" "v1.0.0"
|
||||
github "antitypical/Result" "3.1.0"
|
||||
github "ZipArchive/ZipArchive" "v1.6.2"
|
||||
github "jspahrsummers/xcconfigs" "0.10"
|
||||
github "modocache/Guanaco" "6b85ad93b4e7fde8a59d23f94c438a97e1696293"
|
||||
github "Quick/Nimble" "v12.3.0"
|
||||
github "Quick/Quick" "v7.3.0"
|
||||
github "ZipArchive/ZipArchive" "2.5.5"
|
||||
github "jspahrsummers/xcconfigs" "1.1"
|
||||
|
||||
Vendored
-1
Submodule Carthage/Checkouts/Guanaco deleted from 6b85ad93b4
Vendored
+1
-1
Submodule Carthage/Checkouts/Nimble updated: 3720e6b0f6...edaedc1ec8
Vendored
+1
-1
Submodule Carthage/Checkouts/Quick updated: 9c032315fa...ef9aaf3f63
Vendored
-1
Submodule Carthage/Checkouts/Result deleted from 2dd1a0c7bc
Vendored
+1
-1
Submodule Carthage/Checkouts/ZipArchive updated: 76ca4b3293...79d4dc9729
Vendored
+1
-1
Submodule Carthage/Checkouts/xcconfigs updated: cc451b08e0...4ced0ad5a9
Vendored
+1
-1
@@ -1 +1 @@
|
||||
/usr/local/opt/openssl/lib/libcrypto.a
|
||||
/opt/homebrew/opt/openssl/lib/libcrypto.a
|
||||
Vendored
+1
-1
Submodule External/libgit2 updated: 4cf1ec7cff...a2bde63741
Vendored
+1
-1
Submodule External/libssh2 updated: e16f638dca...30e9c1347e
Vendored
+1
-1
@@ -1 +1 @@
|
||||
/usr/local/opt/openssl/lib/libssl.a
|
||||
/opt/homebrew/opt/openssl/lib/libssl.a
|
||||
Vendored
+1
-1
Submodule External/openssl updated: 3df69d3aef...e71ebf275d
@@ -1,22 +1,32 @@
|
||||
# SwiftGit2
|
||||
[](https://travis-ci.org/SwiftGit2/SwiftGit2) [](#carthage) [](https://github.com/ReactiveCocoa/ReactiveSwift/releases) 
|
||||
[](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)")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -31,7 +41,21 @@ This vastly simplifies the design of long-lived applications, which are the most
|
||||
|
||||
All methods for reading from or writing to a repository are on SwiftGit’s only `class`: `Repository`. This highlights the failability and mutation of these methods, while freeing up all other instances to be immutable `struct`s and `enum`s.
|
||||
|
||||
## Importing SwiftGit2
|
||||
## Required Tools
|
||||
To build SwiftGit2, you'll need the following tools installed locally:
|
||||
|
||||
* cmake
|
||||
* libssh2
|
||||
* libtool
|
||||
* autoconf
|
||||
* 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`.
|
||||
|
||||
If you’d like, you can do things the ~~hard~~ old-fashioned way:
|
||||
@@ -42,6 +66,13 @@ If you’d like, you can do things the ~~hard~~ old-fashioned way:
|
||||
4. On the “Build Phases” tab of your application target, add `SwiftGit2.framework` to the “Link Binary With Libraries” phase. SwiftGit2 must also be added to a “Copy Frameworks” build phase.
|
||||
5. **If you added SwiftGit2 to a project (not a workspace)**, you will also need to add the appropriate SwiftGit2 target to the “Target Dependencies” of your application.
|
||||
|
||||
## Building SwiftGit2 Manually
|
||||
If you want to build a copy of SwiftGit2 without Carthage, possibly for development:
|
||||
|
||||
1. Clone SwiftGit2
|
||||
2. Run `git submodule update --init --recursive` to clone the submodules
|
||||
3. Build in Xcode
|
||||
|
||||
## Contributions
|
||||
We :heart: to receive pull requests! GitHub makes it easy:
|
||||
|
||||
|
||||
+154
-141
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXAggregateTarget section */
|
||||
@@ -21,6 +21,15 @@
|
||||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
232861431F4A3A2E00276D65 /* Diffs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 232861421F4A3A2E00276D65 /* Diffs.swift */; };
|
||||
232861451F4A3A2E00276D65 /* Diffs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 232861421F4A3A2E00276D65 /* Diffs.swift */; };
|
||||
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 */; };
|
||||
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; };
|
||||
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
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 */; };
|
||||
@@ -40,19 +49,18 @@
|
||||
621E66BF1C72958D00A0F352 /* ReferencesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */; };
|
||||
621E66C01C72958D00A0F352 /* OIDSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E61A1ACB37002C3F4E /* OIDSpec.swift */; };
|
||||
621E66C21C72958D00A0F352 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; };
|
||||
621E66C31C72958D00A0F352 /* Guanaco.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA59146C1A94549A00AED74C /* Guanaco.framework */; };
|
||||
621E66C41C72958D00A0F352 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA50239F1A969F1A004175D7 /* Nimble.framework */; };
|
||||
621E66C51C72958D00A0F352 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; };
|
||||
621E66C81C72958D00A0F352 /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; };
|
||||
621E66C91C72958D00A0F352 /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; };
|
||||
621E66CA1C72958D00A0F352 /* simple-repository.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE14AA561A198C6E0015B439 /* simple-repository.zip */; };
|
||||
621E66D91C72989A00A0F352 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66D81C72989900A0F352 /* Result.framework */; };
|
||||
621E66E61C729D9600A0F352 /* SwiftGit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66B41C72958800A0F352 /* SwiftGit2.framework */; };
|
||||
621E66FE1C72A5FF00A0F352 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66FD1C72A5FF00A0F352 /* libiconv.tbd */; };
|
||||
621E67001C72A60B00A0F352 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66FF1C72A60B00A0F352 /* libz.tbd */; };
|
||||
622726341C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; };
|
||||
622726351C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; };
|
||||
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; };
|
||||
8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; };
|
||||
BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; };
|
||||
BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; };
|
||||
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */ = {isa = PBXBuildFile; fileRef = BE14AA4F1A1974010015B439 /* SwiftGit2.m */; };
|
||||
@@ -76,9 +84,9 @@
|
||||
BECB5F6C1A56F1B400999413 /* ReferencesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */; };
|
||||
BECB5F6E1A57284700999413 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
|
||||
BECB5F701A57286200999413 /* RemotesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6F1A57286200999413 /* RemotesSpec.swift */; };
|
||||
BEE591C71ADF470500534F14 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEE591C61ADF470500534F14 /* Result.framework */; };
|
||||
C98A2BA22263FDB9007A4E3A /* ResultShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A2B9F2263E017007A4E3A /* ResultShims.swift */; };
|
||||
C98A2BA32263FDBA007A4E3A /* ResultShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A2B9F2263E017007A4E3A /* ResultShims.swift */; };
|
||||
DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA50239F1A969F1A004175D7 /* Nimble.framework */; };
|
||||
DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA59146C1A94549A00AED74C /* Guanaco.framework */; };
|
||||
DA5914761A94579000AED74C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5914751A94579000AED74C /* Errors.swift */; };
|
||||
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -119,19 +127,32 @@
|
||||
remoteGlobalIDString = BEB31F221A0D6F7A00F525B9;
|
||||
remoteInfo = "SwiftGit2-OSX";
|
||||
};
|
||||
BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = BEB31F1A1A0D6F7A00F525B9 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = BEB31F8E1A0E563900F525B9;
|
||||
remoteInfo = libgit2;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
50A682E52ADBF65F00FDB557 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
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>"; };
|
||||
50A682D82AD9901000FDB557 /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; path = script; sourceTree = "<group>"; };
|
||||
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libgit2-mac.a"; path = "External/libgit2-mac/libgit2-mac.a"; sourceTree = "<group>"; };
|
||||
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libgit2.xcframework; path = "External/libgit2-ios/libgit2.xcframework"; 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; };
|
||||
621E66D81C72989900A0F352 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = "Carthage/Checkouts/Result/build/Debug-iphoneos/Result.framework"; sourceTree = "<group>"; };
|
||||
621E66E11C729CE500A0F352 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66EC1C729EB800A0F352 /* libssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libssl.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66F21C729EBB00A0F352 /* libssh2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libssh2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -170,23 +191,21 @@
|
||||
BEB31F4F1A0D75EE00F525B9 /* iOS-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-Base.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-Framework.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Application.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F541A0D75EE00F525B9 /* Mac-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Base.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F551A0D75EE00F525B9 /* Mac-DynamicLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-DynamicLibrary.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Framework.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Application.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F541A0D75EE00F525B9 /* macOS-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Base.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F551A0D75EE00F525B9 /* macOS-DynamicLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-DynamicLibrary.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Framework.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
|
||||
BEB31F581A0D75EE00F525B9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
BEB31F6C1A0D78F300F525B9 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
|
||||
BEB31F8F1A0E563900F525B9 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
|
||||
BEB31F9F1A0E595600F525B9 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
BECB5F691A56F19900999413 /* References.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = References.swift; sourceTree = "<group>"; };
|
||||
BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReferencesSpec.swift; sourceTree = "<group>"; };
|
||||
BECB5F6D1A57284700999413 /* Remotes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Remotes.swift; sourceTree = "<group>"; };
|
||||
BECB5F6F1A57286200999413 /* RemotesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemotesSpec.swift; sourceTree = "<group>"; };
|
||||
BEE591C61ADF470500534F14 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = "../../Library/Developer/Xcode/DerivedData/SwiftGit2-cdzquzvlxdewyddxgdgxjagqvjba/Build/Products/Debug/Result.framework"; sourceTree = "<group>"; };
|
||||
C98A2B9F2263E017007A4E3A /* ResultShims.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultShims.swift; sourceTree = "<group>"; };
|
||||
DA50239F1A969F1A004175D7 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DA59146C1A94549A00AED74C /* Guanaco.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Guanaco.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DA5914751A94579000AED74C /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
|
||||
DAC8143C1A99749D0063D88C /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../../Library/Developer/Xcode/DerivedData/SwiftGit2-ezqqkevntxbroughwcioyxqriijk/Build/Products/Debug/Quick.framework"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -197,8 +216,8 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
621E67001C72A60B00A0F352 /* libz.tbd in Frameworks */,
|
||||
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */,
|
||||
621E66FE1C72A5FF00A0F352 /* libiconv.tbd in Frameworks */,
|
||||
621E66D91C72989A00A0F352 /* Result.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -208,7 +227,6 @@
|
||||
files = (
|
||||
621E66E61C729D9600A0F352 /* SwiftGit2.framework in Frameworks */,
|
||||
621E66C21C72958D00A0F352 /* ZipArchive.framework in Frameworks */,
|
||||
621E66C31C72958D00A0F352 /* Guanaco.framework in Frameworks */,
|
||||
621E66C41C72958D00A0F352 /* Nimble.framework in Frameworks */,
|
||||
621E66C51C72958D00A0F352 /* Quick.framework in Frameworks */,
|
||||
);
|
||||
@@ -218,7 +236,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BEE591C71ADF470500534F14 /* Result.framework in Frameworks */,
|
||||
BEB31FA01A0E595600F525B9 /* libz.dylib in Frameworks */,
|
||||
BEB31F9E1A0E595100F525B9 /* libiconv.dylib in Frameworks */,
|
||||
);
|
||||
@@ -229,7 +246,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */,
|
||||
DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */,
|
||||
DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */,
|
||||
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */,
|
||||
BEB31F2F1A0D6F7A00F525B9 /* SwiftGit2.framework in Frameworks */,
|
||||
@@ -239,10 +255,18 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
50A682D92AD994C500FDB557 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */,
|
||||
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
621E66D41C72965C00A0F352 /* Mac */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BEE591C61ADF470500534F14 /* Result.framework */,
|
||||
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */,
|
||||
BEB31F9F1A0E595600F525B9 /* libz.dylib */,
|
||||
);
|
||||
@@ -252,7 +276,6 @@
|
||||
621E66D51C72966000A0F352 /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
621E66D81C72989900A0F352 /* Result.framework */,
|
||||
621E66FD1C72A5FF00A0F352 /* libiconv.tbd */,
|
||||
621E66FF1C72A60B00A0F352 /* libz.tbd */,
|
||||
);
|
||||
@@ -262,6 +285,7 @@
|
||||
BE14AA531A1983520015B439 /* Fixtures */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
237731C61F46542B0020A3FE /* repository-with-status.zip */,
|
||||
BE0B1C5C1A9978890004726D /* detached-head.zip */,
|
||||
BE14AA541A1984550015B439 /* Fixtures.swift */,
|
||||
BE0991F61A578FB1007D4E6A /* Mantle.zip */,
|
||||
@@ -273,11 +297,14 @@
|
||||
BEB31F191A0D6F7A00F525B9 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50A682D82AD9901000FDB557 /* script */,
|
||||
BEB31F251A0D6F7A00F525B9 /* SwiftGit2 */,
|
||||
BEB31F261A0D6F7A00F525B9 /* Supporting Files */,
|
||||
BEB31F321A0D6F7A00F525B9 /* SwiftGit2Tests */,
|
||||
BEB31FA11A0E63C100F525B9 /* Libraries */,
|
||||
BEB31F411A0D75EE00F525B9 /* Configuration */,
|
||||
BEB31F241A0D6F7A00F525B9 /* Products */,
|
||||
50A682D92AD994C500FDB557 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
usesTabs = 1;
|
||||
@@ -287,7 +314,6 @@
|
||||
children = (
|
||||
BEB31F231A0D6F7A00F525B9 /* SwiftGit2.framework */,
|
||||
BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */,
|
||||
BEB31F8F1A0E563900F525B9 /* libgit2.a */,
|
||||
621E66B41C72958800A0F352 /* SwiftGit2.framework */,
|
||||
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */,
|
||||
621E66E11C729CE500A0F352 /* libgit2.a */,
|
||||
@@ -307,12 +333,14 @@
|
||||
DA5914751A94579000AED74C /* Errors.swift */,
|
||||
BE36354B1A632C9700D37EC8 /* Libgit2.swift */,
|
||||
BE2E3BE51A31261300C67092 /* Objects.swift */,
|
||||
232861421F4A3A2E00276D65 /* Diffs.swift */,
|
||||
BE70B3E41A1ACB1A002C3F4E /* OID.swift */,
|
||||
BE7A753E1A4A2BCC002DA7E3 /* Pointers.swift */,
|
||||
BEB31F6C1A0D78F300F525B9 /* Repository.swift */,
|
||||
BECB5F691A56F19900999413 /* References.swift */,
|
||||
BECB5F6D1A57284700999413 /* Remotes.swift */,
|
||||
BEB31F261A0D6F7A00F525B9 /* Supporting Files */,
|
||||
25499A996CA7BD416620A397 /* CommitIterator.swift */,
|
||||
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */,
|
||||
);
|
||||
path = SwiftGit2;
|
||||
sourceTree = "<group>";
|
||||
@@ -323,6 +351,7 @@
|
||||
BEB31F271A0D6F7A00F525B9 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
path = SwiftGit2;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BEB31F321A0D6F7A00F525B9 /* SwiftGit2Tests */ = {
|
||||
@@ -335,6 +364,7 @@
|
||||
BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */,
|
||||
BECB5F6F1A57286200999413 /* RemotesSpec.swift */,
|
||||
BE14AA581A1996B70015B439 /* FixturesSpec.swift */,
|
||||
C98A2B9F2263E017007A4E3A /* ResultShims.swift */,
|
||||
BEB31F331A0D6F7A00F525B9 /* Supporting Files */,
|
||||
);
|
||||
path = SwiftGit2Tests;
|
||||
@@ -346,7 +376,6 @@
|
||||
62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */,
|
||||
DA50239F1A969F1A004175D7 /* Nimble.framework */,
|
||||
DAC8143C1A99749D0063D88C /* Quick.framework */,
|
||||
DA59146C1A94549A00AED74C /* Guanaco.framework */,
|
||||
BEB31F341A0D6F7A00F525B9 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
@@ -357,7 +386,7 @@
|
||||
children = (
|
||||
BEB31F421A0D75EE00F525B9 /* Base */,
|
||||
BEB31F4D1A0D75EE00F525B9 /* iOS */,
|
||||
BEB31F521A0D75EE00F525B9 /* Mac OS X */,
|
||||
BEB31F521A0D75EE00F525B9 /* macOS */,
|
||||
BEB31F581A0D75EE00F525B9 /* README.md */,
|
||||
);
|
||||
name = Configuration;
|
||||
@@ -406,16 +435,16 @@
|
||||
path = iOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BEB31F521A0D75EE00F525B9 /* Mac OS X */ = {
|
||||
BEB31F521A0D75EE00F525B9 /* macOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */,
|
||||
BEB31F541A0D75EE00F525B9 /* Mac-Base.xcconfig */,
|
||||
BEB31F551A0D75EE00F525B9 /* Mac-DynamicLibrary.xcconfig */,
|
||||
BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */,
|
||||
BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */,
|
||||
BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */,
|
||||
BEB31F541A0D75EE00F525B9 /* macOS-Base.xcconfig */,
|
||||
BEB31F551A0D75EE00F525B9 /* macOS-DynamicLibrary.xcconfig */,
|
||||
BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */,
|
||||
BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */,
|
||||
);
|
||||
path = "Mac OS X";
|
||||
path = macOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BEB31FA11A0E63C100F525B9 /* Libraries */ = {
|
||||
@@ -456,6 +485,7 @@
|
||||
621E669F1C72958800A0F352 /* Sources */,
|
||||
621E66AA1C72958800A0F352 /* Frameworks */,
|
||||
621E66AE1C72958800A0F352 /* Headers */,
|
||||
50A682E52ADBF65F00FDB557 /* Embed Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -536,6 +566,7 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = BEB31F391A0D6F7A00F525B9 /* Build configuration list for PBXNativeTarget "SwiftGit2-OSX" */;
|
||||
buildPhases = (
|
||||
50A682DD2AD9959500FDB557 /* Update libgit2 */,
|
||||
BEB31F1E1A0D6F7A00F525B9 /* Sources */,
|
||||
BEB31F1F1A0D6F7A00F525B9 /* Frameworks */,
|
||||
BEB31F201A0D6F7A00F525B9 /* Headers */,
|
||||
@@ -543,7 +574,6 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "SwiftGit2-OSX";
|
||||
productName = "SwiftGit2-OSX";
|
||||
@@ -568,21 +598,6 @@
|
||||
productReference = BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */;
|
||||
buildPhases = (
|
||||
BEB31F931A0E567000F525B9 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "libgit2-OSX";
|
||||
productName = libgit2;
|
||||
productReference = BEB31F8F1A0E563900F525B9 /* libgit2.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
@@ -590,25 +605,22 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0810;
|
||||
LastUpgradeCheck = 1220;
|
||||
ORGANIZATIONNAME = "GitHub, Inc";
|
||||
TargetAttributes = {
|
||||
621E66611C72958800A0F352 = {
|
||||
LastSwiftMigration = 0810;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
621E66B61C72958D00A0F352 = {
|
||||
LastSwiftMigration = 0810;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
BEB31F221A0D6F7A00F525B9 = {
|
||||
CreatedOnToolsVersion = 6.1;
|
||||
LastSwiftMigration = 0810;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
BEB31F2D1A0D6F7A00F525B9 = {
|
||||
CreatedOnToolsVersion = 6.1;
|
||||
LastSwiftMigration = 0810;
|
||||
};
|
||||
BEB31F8E1A0E563900F525B9 = {
|
||||
CreatedOnToolsVersion = 6.1;
|
||||
LastSwiftMigration = 1020;
|
||||
};
|
||||
C9CE0DD21E0710BD0053205D = {
|
||||
CreatedOnToolsVersion = 8.2;
|
||||
@@ -618,10 +630,11 @@
|
||||
};
|
||||
buildConfigurationList = BEB31F1D1A0D6F7A00F525B9 /* Build configuration list for PBXProject "SwiftGit2" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = BEB31F191A0D6F7A00F525B9;
|
||||
productRefGroup = BEB31F241A0D6F7A00F525B9 /* Products */;
|
||||
@@ -632,7 +645,6 @@
|
||||
BEB31F2D1A0D6F7A00F525B9 /* SwiftGit2-OSXTests */,
|
||||
621E66611C72958800A0F352 /* SwiftGit2-iOS */,
|
||||
621E66B61C72958D00A0F352 /* SwiftGit2-iOSTests */,
|
||||
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */,
|
||||
621E66DC1C729CE500A0F352 /* libgit2-iOS */,
|
||||
621E66E71C729EB800A0F352 /* OpenSSL-iOS */,
|
||||
621E66ED1C729EBB00A0F352 /* libssh2-iOS */,
|
||||
@@ -647,6 +659,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
621E66C81C72958D00A0F352 /* detached-head.zip in Resources */,
|
||||
8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */,
|
||||
621E66C91C72958D00A0F352 /* Mantle.zip in Resources */,
|
||||
621E66CA1C72958D00A0F352 /* simple-repository.zip in Resources */,
|
||||
);
|
||||
@@ -657,6 +670,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */,
|
||||
237731C71F46542B0020A3FE /* repository-with-status.zip in Resources */,
|
||||
BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */,
|
||||
BE14AA571A198C6E0015B439 /* simple-repository.zip in Resources */,
|
||||
);
|
||||
@@ -665,21 +679,44 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
50A682DD2AD9959500FDB557 /* Update libgit2 */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Update libgit2";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(SRCROOT)/External/libgit2-mac/libgit2-mac.a",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "script/update_libgit2\n";
|
||||
};
|
||||
621E66DD1C729CE500A0F352 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(SRCROOT)/External/libgit2-ios/libgit2.xcframework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libgit2_ios;
|
||||
shellScript = "script/update_libgit2_ios\n";
|
||||
};
|
||||
621E66E81C729EB800A0F352 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
@@ -689,10 +726,11 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libssl_ios;
|
||||
shellScript = "script/update_libssl_ios\n";
|
||||
};
|
||||
621E66EE1C729EBB00A0F352 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
@@ -702,23 +740,11 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libssh2_ios;
|
||||
};
|
||||
BEB31F931A0E567000F525B9 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libgit2;
|
||||
shellScript = "script/update_libssh2_ios\n";
|
||||
};
|
||||
C9CE0DD61E0710C20053205D /* Lint Sources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
@@ -729,7 +755,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint is not installed\"\nfi";
|
||||
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --lenient\nelse\n echo \"warning: SwiftLint is not installed\"\nfi\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -744,11 +770,14 @@
|
||||
622726351C84E52500C53D17 /* Credentials.swift in Sources */,
|
||||
621E66A31C72958800A0F352 /* Repository.swift in Sources */,
|
||||
621E66A41C72958800A0F352 /* Objects.swift in Sources */,
|
||||
232861451F4A3A2E00276D65 /* Diffs.swift in Sources */,
|
||||
621E66A51C72958800A0F352 /* References.swift in Sources */,
|
||||
621E66A61C72958800A0F352 /* Libgit2.swift in Sources */,
|
||||
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;
|
||||
};
|
||||
@@ -763,6 +792,7 @@
|
||||
621E66BE1C72958D00A0F352 /* Fixtures.swift in Sources */,
|
||||
621E66BF1C72958D00A0F352 /* ReferencesSpec.swift in Sources */,
|
||||
621E66C01C72958D00A0F352 /* OIDSpec.swift in Sources */,
|
||||
C98A2BA32263FDBA007A4E3A /* ResultShims.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -776,11 +806,14 @@
|
||||
622726341C84E52500C53D17 /* Credentials.swift in Sources */,
|
||||
BEB31F6D1A0D78F300F525B9 /* Repository.swift in Sources */,
|
||||
BE2E3BE61A31261300C67092 /* Objects.swift in Sources */,
|
||||
232861431F4A3A2E00276D65 /* Diffs.swift in Sources */,
|
||||
BECB5F6A1A56F19900999413 /* References.swift in Sources */,
|
||||
BE36354C1A632C9700D37EC8 /* Libgit2.swift in Sources */,
|
||||
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;
|
||||
};
|
||||
@@ -795,6 +828,7 @@
|
||||
BE14AA551A1984550015B439 /* Fixtures.swift in Sources */,
|
||||
BECB5F6C1A56F1B400999413 /* ReferencesSpec.swift in Sources */,
|
||||
BE70B3E71A1ACB37002C3F4E /* OIDSpec.swift in Sources */,
|
||||
C98A2BA22263FDB9007A4E3A /* ResultShims.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -826,11 +860,6 @@
|
||||
target = BEB31F221A0D6F7A00F525B9 /* SwiftGit2-OSX */;
|
||||
targetProxy = BEB31F301A0D6F7A00F525B9 /* PBXContainerItemProxy */;
|
||||
};
|
||||
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = BEB31F8E1A0E563900F525B9 /* libgit2-OSX */;
|
||||
targetProxy = BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
@@ -838,8 +867,9 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
External/libgit2/include,
|
||||
"$(SRCROOT)/External/libgit2/include",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
@@ -850,9 +880,6 @@
|
||||
"$(inherited)",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-force_load",
|
||||
"External/libgit2-ios/libgit2-ios.a",
|
||||
"-lgit2-ios",
|
||||
"-lssl",
|
||||
"-lcrypto",
|
||||
"-lssh2-ios",
|
||||
@@ -867,8 +894,9 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
External/libgit2/include,
|
||||
"$(SRCROOT)/External/libgit2/include",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
@@ -879,9 +907,6 @@
|
||||
"$(inherited)",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-force_load",
|
||||
"External/libgit2-ios/libgit2-ios.a",
|
||||
"-lgit2-ios",
|
||||
"-lssl",
|
||||
"-lcrypto",
|
||||
"-lssh2-ios",
|
||||
@@ -916,6 +941,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -924,6 +950,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
@@ -964,10 +991,14 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F451A0D75EE00F525B9 /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
SWIFT_VERSION = 3.0;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -976,31 +1007,35 @@
|
||||
baseConfigurationReference = BEB31F471A0D75EE00F525B9 /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
SWIFT_VERSION = 3.0;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
BEB31F3A1A0D6F7A00F525B9 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */;
|
||||
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */;
|
||||
buildSettings = {
|
||||
HEADER_SEARCH_PATHS = (
|
||||
External/libgit2/include,
|
||||
"$(SRCROOT)/External/libgit2/include",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
External,
|
||||
"External/libgit2-mac",
|
||||
External/,
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/External/libgit2-mac",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lgit2",
|
||||
"-force_load",
|
||||
External/libgit2.a,
|
||||
/usr/local/lib/libssh2.a,
|
||||
/opt/homebrew/lib/libssh2.a,
|
||||
"-lgit2-mac",
|
||||
"-lcrypto",
|
||||
"-lssl",
|
||||
"-lcurl",
|
||||
@@ -1008,27 +1043,28 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SwiftGit2;
|
||||
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
|
||||
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
BEB31F3B1A0D6F7A00F525B9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */;
|
||||
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */;
|
||||
buildSettings = {
|
||||
HEADER_SEARCH_PATHS = (
|
||||
External/libgit2/include,
|
||||
"$(SRCROOT)/External/libgit2/include",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
External,
|
||||
"External/libgit2-mac",
|
||||
External/,
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/External/libgit2-mac",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lgit2",
|
||||
"-force_load",
|
||||
External/libgit2.a,
|
||||
/usr/local/lib/libssh2.a,
|
||||
/opt/homebrew/lib/libssh2.a,
|
||||
"-lgit2-mac",
|
||||
"-lcrypto",
|
||||
"-lssl",
|
||||
"-lcurl",
|
||||
@@ -1036,12 +1072,13 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SwiftGit2;
|
||||
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
|
||||
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
BEB31F3D1A0D6F7A00F525B9 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */;
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
@@ -1051,7 +1088,7 @@
|
||||
};
|
||||
BEB31F3E1A0D6F7A00F525B9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */;
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
@@ -1059,22 +1096,6 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
BEB31F911A0E563900F525B9 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
BEB31F921A0E563900F525B9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C9CE0DD41E0710BD0053205D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -1164,15 +1185,6 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
BEB31F911A0E563900F525B9 /* Debug */,
|
||||
BEB31F921A0E563900F525B9 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C9CE0DD31E0710BD0053205D /* Build configuration list for PBXAggregateTarget "SwiftLint" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
@@ -1180,6 +1192,7 @@
|
||||
C9CE0DD51E0710BD0053205D /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
||||
@@ -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 = "0810"
|
||||
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 = "0810"
|
||||
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
@@ -4,18 +4,12 @@
|
||||
<FileRef
|
||||
location = "group:SwiftGit2.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/Result/Result.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/Quick/Quick.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/Nimble/Nimble.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/Guanaco/Guanaco.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Carthage/Checkouts/ZipArchive/ZipArchive.xcodeproj">
|
||||
</FileRef>
|
||||
|
||||
@@ -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>
|
||||
@@ -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`.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Created by Arnon Keereena on 4/28/17.
|
||||
// Copyright (c) 2017 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Clibgit2
|
||||
|
||||
public class CommitIterator: IteratorProtocol, Sequence {
|
||||
public typealias Iterator = CommitIterator
|
||||
public typealias Element = Result<Commit, NSError>
|
||||
let repo: Repository
|
||||
private var revisionWalker: OpaquePointer?
|
||||
|
||||
private enum Next {
|
||||
case over
|
||||
case okay
|
||||
case error(NSError)
|
||||
|
||||
init(_ result: Int32, name: String) {
|
||||
switch result {
|
||||
case GIT_ITEROVER.rawValue:
|
||||
self = .over
|
||||
case GIT_OK.rawValue:
|
||||
self = .okay
|
||||
default:
|
||||
self = .error(NSError(gitError: result, pointOfFailure: name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(repo: Repository, root: git_oid) {
|
||||
self.repo = repo
|
||||
setupRevisionWalker(root: root)
|
||||
}
|
||||
|
||||
deinit {
|
||||
git_revwalk_free(self.revisionWalker)
|
||||
}
|
||||
|
||||
private func setupRevisionWalker(root: git_oid) {
|
||||
var oid = root
|
||||
git_revwalk_new(&revisionWalker, repo.pointer)
|
||||
git_revwalk_sorting(revisionWalker, GIT_SORT_TOPOLOGICAL.rawValue)
|
||||
git_revwalk_sorting(revisionWalker, GIT_SORT_TIME.rawValue)
|
||||
git_revwalk_push(revisionWalker, &oid)
|
||||
}
|
||||
|
||||
public func next() -> Element? {
|
||||
var oid = git_oid()
|
||||
let revwalkGitResult = git_revwalk_next(&oid, revisionWalker)
|
||||
let nextResult = Next(revwalkGitResult, name: "git_revwalk_next")
|
||||
switch nextResult {
|
||||
case let .error(error):
|
||||
return Result.failure(error)
|
||||
case .over:
|
||||
return nil
|
||||
case .okay:
|
||||
var unsafeCommit: OpaquePointer? = nil
|
||||
let lookupGitResult = git_commit_lookup(&unsafeCommit, repo.pointer, &oid)
|
||||
guard lookupGitResult == GIT_OK.rawValue,
|
||||
let unwrapCommit = unsafeCommit else {
|
||||
return Result.failure(NSError(gitError: lookupGitResult, pointOfFailure: "git_commit_lookup"))
|
||||
}
|
||||
let result: Element = Result.success(Commit(unwrapCommit))
|
||||
git_commit_free(unsafeCommit)
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private class Wrapper<T> {
|
||||
let value: T
|
||||
@@ -17,9 +17,10 @@ private class Wrapper<T> {
|
||||
}
|
||||
|
||||
public enum Credentials {
|
||||
case Default()
|
||||
case Plaintext(username: String, password: String)
|
||||
case SSHMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
|
||||
case `default`
|
||||
case sshAgent
|
||||
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
|
||||
@@ -33,16 +34,26 @@ 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>?>?, _: UnsafePointer<Int8>?,
|
||||
_: UnsafePointer<Int8>?, _: 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 = username.map(String.init(cString:))
|
||||
|
||||
switch Credentials.fromPointer(payload!) {
|
||||
case .Default():
|
||||
case .default:
|
||||
result = git_cred_default_new(cred)
|
||||
case .Plaintext(let username, let password):
|
||||
case .sshAgent:
|
||||
result = git_cred_ssh_key_from_agent(cred, name!)
|
||||
case .plaintext(let username, let password):
|
||||
result = git_cred_userpass_plaintext_new(cred, username, password)
|
||||
case .SSHMemory(let username, let publicKey, let privateKey, let passphrase):
|
||||
case .sshMemory(let username, let publicKey, let privateKey, let passphrase):
|
||||
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// Diffs.swift
|
||||
// SwiftGit2
|
||||
//
|
||||
// Created by Jake Van Alstyne on 8/20/17.
|
||||
// Copyright © 2017 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Clibgit2
|
||||
|
||||
public struct StatusEntry {
|
||||
public var status: Diff.Status
|
||||
public var headToIndex: Diff.Delta?
|
||||
public var indexToWorkDir: Diff.Delta?
|
||||
|
||||
public init(from statusEntry: git_status_entry) {
|
||||
self.status = Diff.Status(rawValue: statusEntry.status.rawValue)
|
||||
|
||||
if let htoi = statusEntry.head_to_index {
|
||||
self.headToIndex = Diff.Delta(htoi.pointee)
|
||||
}
|
||||
|
||||
if let itow = statusEntry.index_to_workdir {
|
||||
self.indexToWorkDir = Diff.Delta(itow.pointee)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct Diff {
|
||||
|
||||
/// The set of deltas.
|
||||
public var deltas = [Delta]()
|
||||
|
||||
public struct Delta {
|
||||
public static let type = GIT_OBJECT_REF_DELTA
|
||||
|
||||
public var status: Status
|
||||
public var flags: Flags
|
||||
public var oldFile: File?
|
||||
public var newFile: File?
|
||||
|
||||
public init(_ delta: git_diff_delta) {
|
||||
self.status = Status(rawValue: UInt32(git_diff_status_char(delta.status)))
|
||||
self.flags = Flags(rawValue: delta.flags)
|
||||
self.oldFile = File(delta.old_file)
|
||||
self.newFile = File(delta.new_file)
|
||||
}
|
||||
}
|
||||
|
||||
public struct File {
|
||||
public var oid: OID
|
||||
public var path: String
|
||||
public var size: UInt64
|
||||
public var flags: Flags
|
||||
|
||||
public init(_ diffFile: git_diff_file) {
|
||||
self.oid = OID(diffFile.id)
|
||||
let path = diffFile.path
|
||||
self.path = path.map(String.init(cString:))!
|
||||
self.size = diffFile.size
|
||||
self.flags = Flags(rawValue: diffFile.flags)
|
||||
}
|
||||
}
|
||||
|
||||
public struct Status: OptionSet {
|
||||
// This appears to be necessary due to bug in Swift
|
||||
// https://bugs.swift.org/browse/SR-3003
|
||||
public init(rawValue: UInt32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
public let rawValue: UInt32
|
||||
|
||||
public static let current = Status(rawValue: GIT_STATUS_CURRENT.rawValue)
|
||||
public static let indexNew = Status(rawValue: GIT_STATUS_INDEX_NEW.rawValue)
|
||||
public static let indexModified = Status(rawValue: GIT_STATUS_INDEX_MODIFIED.rawValue)
|
||||
public static let indexDeleted = Status(rawValue: GIT_STATUS_INDEX_DELETED.rawValue)
|
||||
public static let indexRenamed = Status(rawValue: GIT_STATUS_INDEX_RENAMED.rawValue)
|
||||
public static let indexTypeChange = Status(rawValue: GIT_STATUS_INDEX_TYPECHANGE.rawValue)
|
||||
public static let workTreeNew = Status(rawValue: GIT_STATUS_WT_NEW.rawValue)
|
||||
public static let workTreeModified = Status(rawValue: GIT_STATUS_WT_MODIFIED.rawValue)
|
||||
public static let workTreeDeleted = Status(rawValue: GIT_STATUS_WT_DELETED.rawValue)
|
||||
public static let workTreeTypeChange = Status(rawValue: GIT_STATUS_WT_TYPECHANGE.rawValue)
|
||||
public static let workTreeRenamed = Status(rawValue: GIT_STATUS_WT_RENAMED.rawValue)
|
||||
public static let workTreeUnreadable = Status(rawValue: GIT_STATUS_WT_UNREADABLE.rawValue)
|
||||
public static let ignored = Status(rawValue: GIT_STATUS_IGNORED.rawValue)
|
||||
public static let conflicted = Status(rawValue: GIT_STATUS_CONFLICTED.rawValue)
|
||||
}
|
||||
|
||||
public struct Flags: OptionSet {
|
||||
// This appears to be necessary due to bug in Swift
|
||||
// https://bugs.swift.org/browse/SR-3003
|
||||
public init(rawValue: UInt32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
public let rawValue: UInt32
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
/// Create an instance with a libgit2 `git_diff`.
|
||||
public init(_ pointer: OpaquePointer) {
|
||||
for i in 0..<git_diff_num_deltas(pointer) {
|
||||
if let delta = git_diff_get_delta(pointer, i) {
|
||||
deltas.append(Diff.Delta(delta.pointee))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public let libGit2ErrorDomain = "org.libgit2.libgit2"
|
||||
|
||||
@@ -10,7 +10,7 @@ internal extension NSError {
|
||||
/// :param: libGit2PointOfFailure The name of the libgit2 function that produced the
|
||||
/// error code.
|
||||
/// :returns: An NSError with a libgit2 error domain, code, and message.
|
||||
internal convenience init(gitError errorCode: Int32, pointOfFailure: String? = nil) {
|
||||
convenience init(gitError errorCode: Int32, pointOfFailure: String? = nil) {
|
||||
let code = Int(errorCode)
|
||||
var userInfo: [String: String] = [:]
|
||||
|
||||
@@ -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,11 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
|
||||
func == (lhs: git_otype, rhs: git_otype) -> Bool {
|
||||
return lhs.rawValue == rhs.rawValue
|
||||
}
|
||||
import Clibgit2
|
||||
|
||||
extension git_strarray {
|
||||
func filter(_ isIncluded: (String) -> Bool) -> [String] {
|
||||
|
||||
+11
-22
@@ -6,8 +6,7 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// An identifier for a Git object.
|
||||
public struct OID {
|
||||
@@ -27,12 +26,12 @@ public struct OID {
|
||||
let result = git_oid_fromstr(pointer, string)
|
||||
|
||||
if result < GIT_OK.rawValue {
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
return nil
|
||||
}
|
||||
|
||||
oid = pointer.pointee
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
}
|
||||
|
||||
/// Create an instance from a libgit2 `git_oid`.
|
||||
@@ -57,25 +56,15 @@ extension OID: CustomStringConvertible {
|
||||
}
|
||||
|
||||
extension OID: Hashable {
|
||||
public var hashValue: Int {
|
||||
let bytes = [
|
||||
self.oid.id.0,
|
||||
self.oid.id.1,
|
||||
self.oid.id.2,
|
||||
self.oid.id.3,
|
||||
self.oid.id.4,
|
||||
self.oid.id.5,
|
||||
self.oid.id.6,
|
||||
self.oid.id.7,
|
||||
]
|
||||
return bytes.reduce(0) { (hash, byte) in
|
||||
return Int(hash << 8) | Int(byte)
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
withUnsafeBytes(of: oid.id) {
|
||||
hasher.combine(bytes: $0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: OID, rhs: OID) -> Bool {
|
||||
var left = lhs.oid
|
||||
var right = rhs.oid
|
||||
return git_oid_cmp(&left, &right) == 0
|
||||
public static func == (lhs: OID, rhs: OID) -> Bool {
|
||||
var left = lhs.oid
|
||||
var right = rhs.oid
|
||||
return git_oid_cmp(&left, &right) == 0
|
||||
}
|
||||
}
|
||||
|
||||
+45
-58
@@ -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 }
|
||||
@@ -20,8 +20,14 @@ public protocol ObjectType {
|
||||
init(_ pointer: OpaquePointer)
|
||||
}
|
||||
|
||||
public func == <O: ObjectType>(lhs: O, rhs: O) -> Bool {
|
||||
return lhs.oid == rhs.oid
|
||||
public extension ObjectType {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
public struct Signature {
|
||||
@@ -37,6 +43,14 @@ public struct Signature {
|
||||
/// The time zone that `time` should be interpreted relative to.
|
||||
public let timeZone: TimeZone
|
||||
|
||||
/// Create an instance with custom name, email, dates, etc.
|
||||
public init(name: String, email: String, time: Date = Date(), timeZone: TimeZone = TimeZone.autoupdatingCurrent) {
|
||||
self.name = name
|
||||
self.email = email
|
||||
self.time = time
|
||||
self.timeZone = timeZone
|
||||
}
|
||||
|
||||
/// Create an instance with a libgit2 `git_signature`.
|
||||
public init(_ signature: git_signature) {
|
||||
name = String(validatingUTF8: signature.name)!
|
||||
@@ -44,24 +58,33 @@ public struct Signature {
|
||||
time = Date(timeIntervalSince1970: TimeInterval(signature.when.time))
|
||||
timeZone = TimeZone(secondsFromGMT: 60 * Int(signature.when.offset))!
|
||||
}
|
||||
}
|
||||
|
||||
extension Signature: Hashable {
|
||||
public var hashValue: Int {
|
||||
return name.hashValue ^ email.hashValue ^ time.timeIntervalSince1970.hashValue
|
||||
/// Return an unsafe pointer to the `git_signature` struct.
|
||||
/// Caller is responsible for freeing it with `git_signature_free`.
|
||||
func makeUnsafeSignature() -> Result<UnsafeMutablePointer<git_signature>, NSError> {
|
||||
var signature: UnsafeMutablePointer<git_signature>? = nil
|
||||
let time = git_time_t(self.time.timeIntervalSince1970) // Unix epoch time
|
||||
let offset = Int32(timeZone.secondsFromGMT(for: self.time) / 60)
|
||||
let signatureResult = git_signature_new(&signature, name, email, time, offset)
|
||||
guard signatureResult == GIT_OK.rawValue, let signatureUnwrap = signature else {
|
||||
let err = NSError(gitError: signatureResult, pointOfFailure: "git_signature_new")
|
||||
return .failure(err)
|
||||
}
|
||||
return .success(signatureUnwrap)
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Signature, rhs: Signature) -> Bool {
|
||||
return lhs.name == rhs.name
|
||||
&& lhs.email == rhs.email
|
||||
&& lhs.time == rhs.time
|
||||
&& lhs.timeZone == rhs.timeZone
|
||||
extension Signature: Hashable {
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(name)
|
||||
hasher.combine(email)
|
||||
hasher.combine(time)
|
||||
}
|
||||
}
|
||||
|
||||
/// A git commit.
|
||||
public struct Commit: ObjectType {
|
||||
public static let type = GIT_OBJ_COMMIT
|
||||
public struct Commit: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJECT_COMMIT
|
||||
|
||||
/// The OID of the commit.
|
||||
public let oid: OID
|
||||
@@ -95,18 +118,12 @@ public struct Commit: ObjectType {
|
||||
}
|
||||
}
|
||||
|
||||
extension Commit: Hashable {
|
||||
public var hashValue: Int {
|
||||
return self.oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// A git tree.
|
||||
public struct Tree: ObjectType {
|
||||
public static let type = GIT_OBJ_TREE
|
||||
public struct Tree: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJECT_TREE
|
||||
|
||||
/// An entry in a `Tree`.
|
||||
public struct Entry {
|
||||
public struct Entry: Hashable {
|
||||
/// The entry's UNIX file attributes.
|
||||
public let attributes: Int32
|
||||
|
||||
@@ -151,33 +168,15 @@ public struct Tree: ObjectType {
|
||||
}
|
||||
}
|
||||
|
||||
extension Tree.Entry: Hashable {
|
||||
public var hashValue: Int {
|
||||
return Int(attributes) ^ object.hashValue ^ name.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
extension Tree.Entry: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "\(attributes) \(object) \(name)"
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Tree.Entry, rhs: Tree.Entry) -> Bool {
|
||||
return lhs.attributes == rhs.attributes
|
||||
&& lhs.object == rhs.object
|
||||
&& lhs.name == rhs.name
|
||||
}
|
||||
|
||||
extension Tree: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// A git blob.
|
||||
public struct Blob: ObjectType {
|
||||
public static let type = GIT_OBJ_BLOB
|
||||
public struct Blob: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJECT_BLOB
|
||||
|
||||
/// The OID of the blob.
|
||||
public let oid: OID
|
||||
@@ -194,15 +193,9 @@ public struct Blob: ObjectType {
|
||||
}
|
||||
}
|
||||
|
||||
extension Blob: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// An annotated git tag.
|
||||
public struct Tag: ObjectType {
|
||||
public static let type = GIT_OBJ_TAG
|
||||
public struct Tag: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJECT_TAG
|
||||
|
||||
/// The OID of the tag.
|
||||
public let oid: OID
|
||||
@@ -229,9 +222,3 @@ public struct Tag: ObjectType {
|
||||
message = String(validatingUTF8: git_tag_message(pointer))!
|
||||
}
|
||||
}
|
||||
|
||||
extension Tag: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
+45
-50
@@ -6,87 +6,88 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A pointer to a git object.
|
||||
public protocol PointerType: Equatable, Hashable {
|
||||
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 func == <P: PointerType>(lhs: P, rhs: P) -> Bool {
|
||||
return lhs.oid == rhs.oid && lhs.type.rawValue == rhs.type.rawValue
|
||||
public extension PointerType {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.oid == rhs.oid
|
||||
&& lhs.type == rhs.type
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
/// A pointer to a git object.
|
||||
public enum Pointer: PointerType {
|
||||
case Commit(OID)
|
||||
case Tree(OID)
|
||||
case Blob(OID)
|
||||
case Tag(OID)
|
||||
case commit(OID)
|
||||
case tree(OID)
|
||||
case blob(OID)
|
||||
case tag(OID)
|
||||
|
||||
public var oid: OID {
|
||||
switch self {
|
||||
case let .Commit(oid):
|
||||
case let .commit(oid):
|
||||
return oid
|
||||
case let .Tree(oid):
|
||||
case let .tree(oid):
|
||||
return oid
|
||||
case let .Blob(oid):
|
||||
case let .blob(oid):
|
||||
return oid
|
||||
case let .Tag(oid):
|
||||
case let .tag(oid):
|
||||
return oid
|
||||
}
|
||||
}
|
||||
|
||||
public var type: git_otype {
|
||||
public var type: git_object_t {
|
||||
switch self {
|
||||
case .Commit:
|
||||
return GIT_OBJ_COMMIT
|
||||
case .Tree:
|
||||
return GIT_OBJ_TREE
|
||||
case .Blob:
|
||||
return GIT_OBJ_BLOB
|
||||
case .Tag:
|
||||
return GIT_OBJ_TAG
|
||||
case .commit:
|
||||
return GIT_OBJECT_COMMIT
|
||||
case .tree:
|
||||
return GIT_OBJECT_TREE
|
||||
case .blob:
|
||||
return GIT_OBJECT_BLOB
|
||||
case .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:
|
||||
self = .Commit(oid)
|
||||
case GIT_OBJ_TREE:
|
||||
self = .Tree(oid)
|
||||
case GIT_OBJ_BLOB:
|
||||
self = .Blob(oid)
|
||||
case GIT_OBJ_TAG:
|
||||
self = .Tag(oid)
|
||||
case GIT_OBJECT_COMMIT:
|
||||
self = .commit(oid)
|
||||
case GIT_OBJECT_TREE:
|
||||
self = .tree(oid)
|
||||
case GIT_OBJECT_BLOB:
|
||||
self = .blob(oid)
|
||||
case GIT_OBJECT_TAG:
|
||||
self = .tag(oid)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Pointer: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
extension Pointer: CustomStringConvertible {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .Commit:
|
||||
case .commit:
|
||||
return "commit(\(oid))"
|
||||
case .Tree:
|
||||
case .tree:
|
||||
return "tree(\(oid))"
|
||||
case .Blob:
|
||||
case .blob:
|
||||
return "blob(\(oid))"
|
||||
case .Tag:
|
||||
case .tag:
|
||||
return "tag(\(oid))"
|
||||
}
|
||||
}
|
||||
@@ -95,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
|
||||
}
|
||||
|
||||
@@ -103,9 +104,3 @@ public struct PointerTo<T: ObjectType>: PointerType {
|
||||
self.oid = oid
|
||||
}
|
||||
}
|
||||
|
||||
extension PointerTo: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
+25
-36
@@ -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 {
|
||||
@@ -20,9 +20,16 @@ public protocol ReferenceType {
|
||||
var oid: OID { get }
|
||||
}
|
||||
|
||||
public func ==<T: ReferenceType>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
public extension ReferenceType {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(longName)
|
||||
hasher.combine(oid)
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a Reference, Branch, or TagReference from a libgit2 `git_reference`.
|
||||
@@ -37,7 +44,7 @@ internal func referenceWithLibGit2Reference(_ pointer: OpaquePointer) -> Referen
|
||||
}
|
||||
|
||||
/// A generic reference to a git object.
|
||||
public struct Reference: ReferenceType {
|
||||
public struct Reference: ReferenceType, Hashable {
|
||||
/// The full name of the reference (e.g., `refs/heads/master`).
|
||||
public let longName: String
|
||||
|
||||
@@ -56,14 +63,8 @@ public struct Reference: ReferenceType {
|
||||
}
|
||||
}
|
||||
|
||||
extension Reference: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// A git branch.
|
||||
public struct Branch: ReferenceType {
|
||||
public struct Branch: ReferenceType, Hashable {
|
||||
/// The full name of the reference (e.g., `refs/heads/master`).
|
||||
public let longName: String
|
||||
|
||||
@@ -106,7 +107,7 @@ public struct Branch: ReferenceType {
|
||||
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 {
|
||||
@@ -121,33 +122,27 @@ public struct Branch: ReferenceType {
|
||||
}
|
||||
}
|
||||
|
||||
extension Branch: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
/// A git tag reference, which can be either a lightweight tag or a Tag object.
|
||||
public enum TagReference: ReferenceType {
|
||||
public enum TagReference: ReferenceType, Hashable {
|
||||
/// A lightweight tag, which is just a name and an OID.
|
||||
case Lightweight(String, OID)
|
||||
case lightweight(String, OID)
|
||||
|
||||
/// An annotated tag, which points to a Tag object.
|
||||
case Annotated(String, Tag)
|
||||
case annotated(String, Tag)
|
||||
|
||||
/// The full name of the reference (e.g., `refs/tags/my-tag`).
|
||||
public var longName: String {
|
||||
switch self {
|
||||
case let .Lightweight(name, _):
|
||||
case let .lightweight(name, _):
|
||||
return name
|
||||
case let .Annotated(name, _):
|
||||
case let .annotated(name, _):
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
/// The short human-readable name of the branch (e.g., `master`).
|
||||
public var name: String {
|
||||
return longName.substring(from: "refs/tags/".endIndex)
|
||||
return String(longName["refs/tags/".endIndex...])
|
||||
}
|
||||
|
||||
/// The OID of the target object.
|
||||
@@ -155,9 +150,9 @@ public enum TagReference: ReferenceType {
|
||||
/// If this is an annotated tag, the OID will be the tag's target.
|
||||
public var oid: OID {
|
||||
switch self {
|
||||
case let .Lightweight(_, oid):
|
||||
case let .lightweight(_, oid):
|
||||
return oid
|
||||
case let .Annotated(_, tag):
|
||||
case let .annotated(_, tag):
|
||||
return tag.target.oid
|
||||
}
|
||||
}
|
||||
@@ -183,18 +178,12 @@ public enum TagReference: ReferenceType {
|
||||
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!))
|
||||
self = .annotated(name, Tag(pointer!))
|
||||
} else {
|
||||
self = .Lightweight(name, OID(oid))
|
||||
self = .lightweight(name, OID(oid))
|
||||
}
|
||||
git_object_free(pointer)
|
||||
}
|
||||
}
|
||||
|
||||
extension TagReference: Hashable {
|
||||
public var hashValue: Int {
|
||||
return longName.hashValue ^ oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
+2
-12
@@ -6,10 +6,10 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A remote in a git repository.
|
||||
public struct Remote {
|
||||
public struct Remote: Hashable {
|
||||
/// The name of the remote.
|
||||
public let name: String
|
||||
|
||||
@@ -24,13 +24,3 @@ public struct Remote {
|
||||
URL = String(validatingUTF8: git_remote_url(pointer))!
|
||||
}
|
||||
}
|
||||
|
||||
extension Remote: Hashable {
|
||||
public var hashValue: Int {
|
||||
return name.hashValue ^ URL.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Remote, rhs: Remote) -> Bool {
|
||||
return lhs.name == rhs.name && lhs.URL == rhs.URL
|
||||
}
|
||||
|
||||
+511
-61
@@ -7,15 +7,14 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Result
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
|
||||
|
||||
/// Helper function used as the libgit2 progress callback in git_checkout_options.
|
||||
/// This is a function with a type signature of git_checkout_progress_cb.
|
||||
private func checkoutProgressCallback(path: UnsafePointer<Int8>?, completedSteps: Int, totalSteps: Int,
|
||||
payload: UnsafeMutableRawPointer?) -> Void {
|
||||
payload: UnsafeMutableRawPointer?) {
|
||||
if let payload = payload {
|
||||
let buffer = payload.assumingMemoryBound(to: CheckoutProgressBlock.self)
|
||||
let block: CheckoutProgressBlock
|
||||
@@ -23,7 +22,7 @@ private func checkoutProgressCallback(path: UnsafePointer<Int8>?, completedSteps
|
||||
block = buffer.pointee
|
||||
} else {
|
||||
block = buffer.move()
|
||||
buffer.deallocate(capacity: 1)
|
||||
buffer.deallocate()
|
||||
}
|
||||
block(path.flatMap(String.init(validatingUTF8:)), completedSteps, totalSteps)
|
||||
}
|
||||
@@ -40,7 +39,7 @@ private func checkoutOptions(strategy: CheckoutStrategy,
|
||||
let pointer = UnsafeMutablePointer<git_checkout_options>.allocate(capacity: 1)
|
||||
git_checkout_init_options(pointer, UInt32(GIT_CHECKOUT_OPTIONS_VERSION))
|
||||
var options = pointer.move()
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
|
||||
options.checkout_strategy = strategy.gitCheckoutStrategy.rawValue
|
||||
|
||||
@@ -60,7 +59,7 @@ private func fetchOptions(credentials: Credentials) -> git_fetch_options {
|
||||
|
||||
var options = pointer.move()
|
||||
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
|
||||
options.callbacks.payload = credentials.toPointer()
|
||||
options.callbacks.credentials = credentialsCallback
|
||||
@@ -75,7 +74,7 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
|
||||
|
||||
var options = pointer.move()
|
||||
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
|
||||
options.bare = bare ? 1 : 0
|
||||
|
||||
@@ -95,16 +94,35 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
|
||||
}
|
||||
|
||||
/// A git repository.
|
||||
final public class Repository {
|
||||
public final class Repository {
|
||||
|
||||
// MARK: - Creating Repositories
|
||||
|
||||
/// Create a new repository at the given URL.
|
||||
///
|
||||
/// URL - The URL of the repository.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
public class func create(at url: URL) -> Result<Repository, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = url.withUnsafeFileSystemRepresentation {
|
||||
git_repository_init(&pointer, $0, 0)
|
||||
}
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_init"))
|
||||
}
|
||||
|
||||
let repository = Repository(pointer!)
|
||||
return Result.success(repository)
|
||||
}
|
||||
|
||||
/// Load the repository at the given URL.
|
||||
///
|
||||
/// URL - The URL of the repository.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func at(_ url: URL) -> Result<Repository, NSError> {
|
||||
public class func at(_ url: URL) -> Result<Repository, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = url.withUnsafeFileSystemRepresentation {
|
||||
git_repository_open(&pointer, $0)
|
||||
@@ -129,26 +147,27 @@ final public class Repository {
|
||||
/// checkoutProgress - A block that's called with the progress of the checkout.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
|
||||
credentials: Credentials = .Default(), checkoutStrategy: CheckoutStrategy = .Safe,
|
||||
public class func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
|
||||
credentials: Credentials = .default, checkoutStrategy: CheckoutStrategy = .Safe,
|
||||
checkoutProgress: CheckoutProgressBlock? = nil) -> Result<Repository, NSError> {
|
||||
var options = cloneOptions(
|
||||
bare: bare, localClone: localClone,
|
||||
fetchOptions: fetchOptions(credentials: credentials),
|
||||
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
|
||||
var options = cloneOptions(
|
||||
bare: bare,
|
||||
localClone: localClone,
|
||||
fetchOptions: fetchOptions(credentials: credentials),
|
||||
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
|
||||
|
||||
var pointer: OpaquePointer? = nil
|
||||
let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString
|
||||
let result = localURL.withUnsafeFileSystemRepresentation { localPath in
|
||||
git_clone(&pointer, remoteURLString, localPath, &options)
|
||||
}
|
||||
var pointer: OpaquePointer? = nil
|
||||
let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString
|
||||
let result = localURL.withUnsafeFileSystemRepresentation { localPath in
|
||||
git_clone(&pointer, remoteURLString, localPath, &options)
|
||||
}
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_clone"))
|
||||
}
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_clone"))
|
||||
}
|
||||
|
||||
let repository = Repository(pointer!)
|
||||
return Result.success(repository)
|
||||
let repository = Repository(pointer!)
|
||||
return Result.success(repository)
|
||||
}
|
||||
|
||||
// MARK: - Initializers
|
||||
@@ -187,7 +206,7 @@ final public 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
|
||||
@@ -202,17 +221,40 @@ final public 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_object_t, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
var pointers = [OpaquePointer]()
|
||||
defer {
|
||||
for pointer in pointers {
|
||||
git_object_free(pointer)
|
||||
}
|
||||
}
|
||||
|
||||
for oid in oids {
|
||||
var pointer: OpaquePointer? = nil
|
||||
var oid = oid.oid
|
||||
let result = git_object_lookup(&pointer, self.pointer, &oid, type)
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_object_lookup"))
|
||||
}
|
||||
|
||||
pointers.append(pointer!)
|
||||
}
|
||||
|
||||
return transform(pointers)
|
||||
}
|
||||
|
||||
/// Loads the object with the given OID.
|
||||
///
|
||||
/// oid - The OID of the blob to look up.
|
||||
///
|
||||
/// 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))
|
||||
@@ -228,7 +270,7 @@ final public 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)
|
||||
@@ -241,7 +283,7 @@ final public 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.
|
||||
@@ -250,7 +292,7 @@ final public 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.
|
||||
@@ -259,7 +301,7 @@ final public 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.
|
||||
@@ -268,7 +310,7 @@ final public 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.
|
||||
@@ -287,13 +329,13 @@ final public class Repository {
|
||||
/// Returns the object if it exists, or an error.
|
||||
public func object(from pointer: Pointer) -> Result<ObjectType, NSError> {
|
||||
switch pointer {
|
||||
case let .Blob(oid):
|
||||
case let .blob(oid):
|
||||
return blob(oid).map { $0 as ObjectType }
|
||||
case let .Commit(oid):
|
||||
case let .commit(oid):
|
||||
return commit(oid).map { $0 as ObjectType }
|
||||
case let .Tag(oid):
|
||||
case let .tag(oid):
|
||||
return tag(oid).map { $0 as ObjectType }
|
||||
case let .Tree(oid):
|
||||
case let .tree(oid):
|
||||
return tree(oid).map { $0 as ObjectType }
|
||||
}
|
||||
}
|
||||
@@ -308,7 +350,7 @@ final public class Repository {
|
||||
let result = git_remote_list(pointer, self.pointer)
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_remote_list"))
|
||||
}
|
||||
|
||||
@@ -317,13 +359,22 @@ final public class Repository {
|
||||
return self.remote(named: $0)
|
||||
}
|
||||
git_strarray_free(pointer)
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
|
||||
let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error }
|
||||
if let error = error {
|
||||
return Result.failure(error)
|
||||
return remotes.aggregateResult()
|
||||
}
|
||||
|
||||
private func remoteLookup<A>(named name: String, _ callback: (Result<OpaquePointer, NSError>) -> A) -> A {
|
||||
var pointer: OpaquePointer? = nil
|
||||
defer { git_remote_free(pointer) }
|
||||
|
||||
let result = git_remote_lookup(&pointer, self.pointer, name)
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return callback(.failure(NSError(gitError: result, pointOfFailure: "git_remote_lookup")))
|
||||
}
|
||||
return Result.success(remotes.map { $0.value! })
|
||||
|
||||
return callback(.success(pointer!))
|
||||
}
|
||||
|
||||
/// Load a remote from the repository.
|
||||
@@ -332,16 +383,25 @@ final public class Repository {
|
||||
///
|
||||
/// Returns the remote if it exists, or an error.
|
||||
public func remote(named name: String) -> Result<Remote, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = git_remote_lookup(&pointer, self.pointer, name)
|
||||
return remoteLookup(named: name) { $0.map(Remote.init) }
|
||||
}
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_remote_lookup"))
|
||||
/// Download new data and update tips
|
||||
public func fetch(_ remote: Remote) -> Result<(), NSError> {
|
||||
return remoteLookup(named: remote.name) { remote in
|
||||
remote.flatMap { pointer in
|
||||
var opts = git_fetch_options()
|
||||
let resultInit = git_fetch_init_options(&opts, UInt32(GIT_FETCH_OPTIONS_VERSION))
|
||||
assert(resultInit == GIT_OK.rawValue)
|
||||
|
||||
let result = git_remote_fetch(pointer, nil, &opts, nil)
|
||||
guard result == GIT_OK.rawValue else {
|
||||
let err = NSError(gitError: result, pointOfFailure: "git_remote_fetch")
|
||||
return .failure(err)
|
||||
}
|
||||
return .success(())
|
||||
}
|
||||
}
|
||||
|
||||
let value = Remote(pointer!)
|
||||
git_remote_free(pointer)
|
||||
return Result.success(value)
|
||||
}
|
||||
|
||||
// MARK: - Reference Lookups
|
||||
@@ -352,7 +412,7 @@ final public class Repository {
|
||||
let result = git_reference_list(pointer, self.pointer)
|
||||
|
||||
guard result == GIT_OK.rawValue else {
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_reference_list"))
|
||||
}
|
||||
|
||||
@@ -365,13 +425,9 @@ final public class Repository {
|
||||
self.reference(named: $0)
|
||||
}
|
||||
git_strarray_free(pointer)
|
||||
pointer.deallocate(capacity: 1)
|
||||
pointer.deallocate()
|
||||
|
||||
let error = references.reduce(nil) { $0 == nil ? $0 : $1.error }
|
||||
if let error = error {
|
||||
return Result.failure(error)
|
||||
}
|
||||
return Result.success(references.map { $0.value! })
|
||||
return references.aggregateResult()
|
||||
}
|
||||
|
||||
/// Load the reference with the given long name (e.g. "refs/heads/master")
|
||||
@@ -457,7 +513,7 @@ final public class Repository {
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_set_head"))
|
||||
}
|
||||
return Result.success()
|
||||
return Result.success(())
|
||||
}
|
||||
|
||||
/// Set HEAD to the given reference.
|
||||
@@ -469,7 +525,7 @@ final public class Repository {
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_set_head"))
|
||||
}
|
||||
return Result.success()
|
||||
return Result.success(())
|
||||
}
|
||||
|
||||
/// Check out HEAD.
|
||||
@@ -485,7 +541,7 @@ final public class Repository {
|
||||
return Result.failure(NSError(gitError: result, pointOfFailure: "git_checkout_head"))
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
return Result.success(())
|
||||
}
|
||||
|
||||
/// Check out the given OID.
|
||||
@@ -509,4 +565,398 @@ final public class Repository {
|
||||
progress: CheckoutProgressBlock? = nil) -> Result<(), NSError> {
|
||||
return setHEAD(reference).flatMap { self.checkout(strategy: strategy, progress: progress) }
|
||||
}
|
||||
|
||||
/// Load all commits in the specified branch in topological & time order descending
|
||||
///
|
||||
/// :param: branch The branch to get all commits from
|
||||
/// :returns: Returns a result with array of branches or the error that occurred
|
||||
public func commits(in branch: Branch) -> CommitIterator {
|
||||
let iterator = CommitIterator(repo: self, root: branch.oid.oid)
|
||||
return iterator
|
||||
}
|
||||
|
||||
/// Get the index for the repo. The caller is responsible for freeing the index.
|
||||
func unsafeIndex() -> Result<OpaquePointer, NSError> {
|
||||
var index: OpaquePointer? = nil
|
||||
let result = git_repository_index(&index, self.pointer)
|
||||
guard result == GIT_OK.rawValue && index != nil else {
|
||||
let err = NSError(gitError: result, pointOfFailure: "git_repository_index")
|
||||
return .failure(err)
|
||||
}
|
||||
return .success(index!)
|
||||
}
|
||||
|
||||
/// Stage the file(s) under the specified path.
|
||||
public func add(path: String) -> Result<(), NSError> {
|
||||
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)
|
||||
guard addResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: addResult, pointOfFailure: "git_index_add_all"))
|
||||
}
|
||||
// write index to disk
|
||||
let writeResult = git_index_write(index)
|
||||
guard writeResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: writeResult, pointOfFailure: "git_index_write"))
|
||||
}
|
||||
return .success(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform a commit with arbitrary numbers of parent commits.
|
||||
public func commit(
|
||||
tree treeOID: OID,
|
||||
parents: [Commit],
|
||||
message: String,
|
||||
signature: Signature
|
||||
) -> Result<Commit, NSError> {
|
||||
// create commit signature
|
||||
return signature.makeUnsafeSignature().flatMap { signature in
|
||||
defer { git_signature_free(signature) }
|
||||
var tree: OpaquePointer? = nil
|
||||
var treeOIDCopy = treeOID.oid
|
||||
let lookupResult = git_tree_lookup(&tree, self.pointer, &treeOIDCopy)
|
||||
guard lookupResult == GIT_OK.rawValue else {
|
||||
let err = NSError(gitError: lookupResult, pointOfFailure: "git_tree_lookup")
|
||||
return .failure(err)
|
||||
}
|
||||
defer { git_tree_free(tree) }
|
||||
|
||||
var msgBuf = git_buf()
|
||||
git_message_prettify(&msgBuf, message, 0, /* ascii for # */ 35)
|
||||
defer { git_buf_free(&msgBuf) }
|
||||
|
||||
// libgit2 expects a C-like array of parent git_commit pointer
|
||||
var parentGitCommits: [OpaquePointer?] = []
|
||||
defer {
|
||||
for commit in parentGitCommits {
|
||||
git_commit_free(commit)
|
||||
}
|
||||
}
|
||||
for parentCommit in parents {
|
||||
var parent: OpaquePointer? = nil
|
||||
var oid = parentCommit.oid.oid
|
||||
let lookupResult = git_commit_lookup(&parent, self.pointer, &oid)
|
||||
guard lookupResult == GIT_OK.rawValue else {
|
||||
let err = NSError(gitError: lookupResult, pointOfFailure: "git_commit_lookup")
|
||||
return .failure(err)
|
||||
}
|
||||
parentGitCommits.append(parent!)
|
||||
}
|
||||
|
||||
let parentsContiguous = ContiguousArray(parentGitCommits)
|
||||
return parentsContiguous.withUnsafeBufferPointer { unsafeBuffer in
|
||||
var commitOID = git_oid()
|
||||
let parentsPtr = UnsafeMutablePointer(mutating: unsafeBuffer.baseAddress)
|
||||
let result = git_commit_create(
|
||||
&commitOID,
|
||||
self.pointer,
|
||||
"HEAD",
|
||||
signature,
|
||||
signature,
|
||||
"UTF-8",
|
||||
msgBuf.ptr,
|
||||
tree,
|
||||
parents.count,
|
||||
parentsPtr
|
||||
)
|
||||
guard result == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: result, pointOfFailure: "git_commit_create"))
|
||||
}
|
||||
return commit(OID(commitOID))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform a commit of the staged files with the specified message and signature,
|
||||
/// assuming we are not doing a merge and using the current tip as the parent.
|
||||
public func commit(message: String, signature: Signature) -> Result<Commit, NSError> {
|
||||
return unsafeIndex().flatMap { index in
|
||||
defer { git_index_free(index) }
|
||||
var treeOID = git_oid()
|
||||
let treeResult = git_index_write_tree(&treeOID, index)
|
||||
guard treeResult == GIT_OK.rawValue else {
|
||||
let err = NSError(gitError: treeResult, pointOfFailure: "git_index_write_tree")
|
||||
return .failure(err)
|
||||
}
|
||||
var parentID = git_oid()
|
||||
let nameToIDResult = git_reference_name_to_id(&parentID, self.pointer, "HEAD")
|
||||
guard nameToIDResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: nameToIDResult, pointOfFailure: "git_reference_name_to_id"))
|
||||
}
|
||||
return commit(OID(parentID)).flatMap { parentCommit in
|
||||
commit(tree: OID(treeOID), parents: [parentCommit], message: message, signature: signature)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Diffs
|
||||
|
||||
public func diff(for commit: Commit) -> Result<Diff, NSError> {
|
||||
guard !commit.parents.isEmpty else {
|
||||
// Initial commit in a repository
|
||||
return self.diff(from: nil, to: commit.oid)
|
||||
}
|
||||
|
||||
var mergeDiff: OpaquePointer? = nil
|
||||
defer { git_object_free(mergeDiff) }
|
||||
for parent in commit.parents {
|
||||
let error = self.diff(from: parent.oid, to: commit.oid) {
|
||||
switch $0 {
|
||||
case .failure(let error):
|
||||
return error
|
||||
|
||||
case .success(let newDiff):
|
||||
if mergeDiff == nil {
|
||||
mergeDiff = newDiff
|
||||
} else {
|
||||
let mergeResult = git_diff_merge(mergeDiff, newDiff)
|
||||
guard mergeResult == GIT_OK.rawValue else {
|
||||
return NSError(gitError: mergeResult, pointOfFailure: "git_diff_merge")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if error != nil {
|
||||
return Result<Diff, NSError>.failure(error!)
|
||||
}
|
||||
}
|
||||
|
||||
return .success(Diff(mergeDiff!))
|
||||
}
|
||||
|
||||
private func diff(from oldCommitOid: OID?, to newCommitOid: OID?, transform: (Result<OpaquePointer, NSError>) -> NSError?) -> NSError? {
|
||||
assert(oldCommitOid != nil || newCommitOid != nil, "It is an error to pass nil for both the oldOid and newOid")
|
||||
|
||||
var oldTree: OpaquePointer? = nil
|
||||
defer { git_object_free(oldTree) }
|
||||
if let oid = oldCommitOid {
|
||||
switch unsafeTreeForCommitId(oid) {
|
||||
case .failure(let error):
|
||||
return transform(.failure(error))
|
||||
case .success(let value):
|
||||
oldTree = value
|
||||
}
|
||||
}
|
||||
|
||||
var newTree: OpaquePointer? = nil
|
||||
defer { git_object_free(newTree) }
|
||||
if let oid = newCommitOid {
|
||||
switch unsafeTreeForCommitId(oid) {
|
||||
case .failure(let error):
|
||||
return transform(.failure(error))
|
||||
case .success(let value):
|
||||
newTree = value
|
||||
}
|
||||
}
|
||||
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
oldTree,
|
||||
newTree,
|
||||
nil)
|
||||
|
||||
guard diffResult == GIT_OK.rawValue else {
|
||||
return transform(.failure(NSError(gitError: diffResult,
|
||||
pointOfFailure: "git_diff_tree_to_tree")))
|
||||
}
|
||||
|
||||
return transform(Result<OpaquePointer, NSError>.success(diff!))
|
||||
}
|
||||
|
||||
/// Memory safe
|
||||
private func diff(from oldCommitOid: OID?, to newCommitOid: OID?) -> Result<Diff, NSError> {
|
||||
assert(oldCommitOid != nil || newCommitOid != nil, "It is an error to pass nil for both the oldOid and newOid")
|
||||
|
||||
var oldTree: Tree? = nil
|
||||
if let oldCommitOid = oldCommitOid {
|
||||
switch safeTreeForCommitId(oldCommitOid) {
|
||||
case .failure(let error):
|
||||
return .failure(error)
|
||||
case .success(let value):
|
||||
oldTree = value
|
||||
}
|
||||
}
|
||||
|
||||
var newTree: Tree? = nil
|
||||
if let newCommitOid = newCommitOid {
|
||||
switch safeTreeForCommitId(newCommitOid) {
|
||||
case .failure(let error):
|
||||
return .failure(error)
|
||||
case .success(let value):
|
||||
newTree = value
|
||||
}
|
||||
}
|
||||
|
||||
if oldTree != nil && newTree != nil {
|
||||
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,
|
||||
objects[0],
|
||||
objects[1],
|
||||
nil)
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
}
|
||||
} else if let tree = oldTree {
|
||||
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,
|
||||
tree,
|
||||
nil,
|
||||
nil)
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
})
|
||||
} else if let tree = newTree {
|
||||
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,
|
||||
nil,
|
||||
tree,
|
||||
nil)
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
})
|
||||
}
|
||||
|
||||
return .failure(NSError(gitError: -1, pointOfFailure: "diff(from: to:)"))
|
||||
}
|
||||
|
||||
private func processTreeToTreeDiff(_ diffResult: Int32, diff: OpaquePointer?) -> Result<Diff, NSError> {
|
||||
guard diffResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: diffResult,
|
||||
pointOfFailure: "git_diff_tree_to_tree"))
|
||||
}
|
||||
|
||||
let diffObj = Diff(diff!)
|
||||
git_diff_free(diff)
|
||||
return .success(diffObj)
|
||||
}
|
||||
|
||||
private func processDiffDeltas(_ diffResult: OpaquePointer) -> Result<[Diff.Delta], NSError> {
|
||||
var returnDict = [Diff.Delta]()
|
||||
|
||||
let count = git_diff_num_deltas(diffResult)
|
||||
|
||||
for i in 0..<count {
|
||||
let delta = git_diff_get_delta(diffResult, i)
|
||||
let gitDiffDelta = Diff.Delta((delta?.pointee)!)
|
||||
|
||||
returnDict.append(gitDiffDelta)
|
||||
}
|
||||
|
||||
let result = Result<[Diff.Delta], NSError>.success(returnDict)
|
||||
return result
|
||||
}
|
||||
|
||||
private func safeTreeForCommitId(_ oid: OID) -> Result<Tree, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { commit in
|
||||
let treeId = git_commit_tree_id(commit)
|
||||
return tree(OID(treeId!.pointee))
|
||||
}
|
||||
}
|
||||
|
||||
/// Caller responsible to free returned tree with git_object_free
|
||||
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_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_OBJECT_TREE)
|
||||
|
||||
git_object_free(commit)
|
||||
|
||||
guard treeResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: treeResult, pointOfFailure: "git_object_lookup"))
|
||||
}
|
||||
|
||||
return Result<OpaquePointer, NSError>.success(tree!)
|
||||
}
|
||||
|
||||
// MARK: - Status
|
||||
|
||||
public func status(options: StatusOptions = [.includeUntracked]) -> Result<[StatusEntry], NSError> {
|
||||
var returnArray = [StatusEntry]()
|
||||
|
||||
// Do this because GIT_STATUS_OPTIONS_INIT is unavailable in swift
|
||||
let pointer = UnsafeMutablePointer<git_status_options>.allocate(capacity: 1)
|
||||
let optionsResult = git_status_init_options(pointer, UInt32(GIT_STATUS_OPTIONS_VERSION))
|
||||
guard optionsResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options"))
|
||||
}
|
||||
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, &listOptions)
|
||||
guard statusResult == GIT_OK.rawValue, let unwrapStatusResult = unsafeStatus else {
|
||||
return .failure(NSError(gitError: statusResult, pointOfFailure: "git_status_list_new"))
|
||||
}
|
||||
|
||||
let count = git_status_list_entrycount(unwrapStatusResult)
|
||||
|
||||
for i in 0..<count {
|
||||
let s = git_status_byindex(unwrapStatusResult, i)
|
||||
if s?.pointee.status.rawValue == GIT_STATUS_CURRENT.rawValue {
|
||||
continue
|
||||
}
|
||||
|
||||
let statusEntry = StatusEntry(from: s!.pointee)
|
||||
returnArray.append(statusEntry)
|
||||
}
|
||||
|
||||
return .success(returnArray)
|
||||
}
|
||||
|
||||
// MARK: - Validity/Existence Check
|
||||
|
||||
/// - returns: `.success(true)` iff there is a git repository at `url`,
|
||||
/// `.success(false)` if there isn't,
|
||||
/// and a `.failure` if there's been an error.
|
||||
public static func isValid(url: URL) -> Result<Bool, NSError> {
|
||||
var pointer: OpaquePointer?
|
||||
|
||||
let result = url.withUnsafeFileSystemRepresentation {
|
||||
git_repository_open_ext(&pointer, $0, GIT_REPOSITORY_OPEN_NO_SEARCH.rawValue, nil)
|
||||
}
|
||||
|
||||
switch result {
|
||||
case GIT_ENOTFOUND.rawValue:
|
||||
return .success(false)
|
||||
case GIT_OK.rawValue:
|
||||
return .success(true)
|
||||
default:
|
||||
return .failure(NSError(gitError: result, pointOfFailure: "git_repository_open_ext"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension Array {
|
||||
func aggregateResult<Value, Error>() -> Result<[Value], Error> where Element == Result<Value, Error> {
|
||||
var values: [Value] = []
|
||||
for result in self {
|
||||
switch result {
|
||||
case .success(let value):
|
||||
values.append(value)
|
||||
case .failure(let error):
|
||||
return .failure(error)
|
||||
}
|
||||
}
|
||||
return .success(values)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftGit2
|
||||
import ZipArchive
|
||||
|
||||
@@ -15,7 +14,7 @@ final class Fixtures {
|
||||
// MARK: Lifecycle
|
||||
|
||||
class var sharedInstance: Fixtures {
|
||||
struct Singleton {
|
||||
enum Singleton {
|
||||
static let instance = Fixtures()
|
||||
}
|
||||
return Singleton.instance
|
||||
|
||||
Binary file not shown.
@@ -9,7 +9,7 @@
|
||||
import Quick
|
||||
|
||||
class FixturesSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
beforeSuite {
|
||||
Fixtures.sharedInstance.setUp()
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Result
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
class OIDSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("OID(string:)") {
|
||||
it("should be nil if string is too short") {
|
||||
expect(OID(string: "123456789012345678901234567890123456789")).to(beNil())
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Result
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitObject<T>(_ oid: OID, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -18,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)
|
||||
|
||||
@@ -26,8 +25,8 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class SignatureSpec: QuickSpec {
|
||||
override func spec() {
|
||||
class SignatureSpec: FixturesSpec {
|
||||
override class func spec() {
|
||||
describe("Signature(signature)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -89,7 +88,7 @@ class SignatureSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class CommitSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Commit(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -170,11 +169,11 @@ class CommitSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class TreeEntrySpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Tree.Entry(attributes:object:name:)") {
|
||||
it("should set its properties") {
|
||||
let attributes = Int32(GIT_FILEMODE_BLOB.rawValue)
|
||||
let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let object = Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let name = "README.md"
|
||||
|
||||
let entry = Tree.Entry(attributes: attributes, object: object, name: name)
|
||||
@@ -191,7 +190,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
|
||||
let entry = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
|
||||
expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.rawValue)))
|
||||
expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.object).to(equal(Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.name).to(equal("README.md"))
|
||||
}
|
||||
}
|
||||
@@ -231,7 +230,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
}
|
||||
|
||||
class TreeSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Tree(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -240,7 +239,7 @@ class TreeSpec: QuickSpec {
|
||||
let tree = repo.withGitObject(oid) { Tree($0) }
|
||||
let entries = [
|
||||
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue),
|
||||
object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
|
||||
object: .blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
|
||||
name: "README.md"),
|
||||
]
|
||||
expect(tree.entries).to(equal(entries))
|
||||
@@ -282,7 +281,7 @@ class TreeSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class BlobSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Blob(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -331,7 +330,7 @@ class BlobSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class TagSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Tag(pointer)") {
|
||||
it("should set its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -341,7 +340,7 @@ class TagSpec: QuickSpec {
|
||||
let tagger = repo.withGitObject(oid) { Signature(git_tag_tagger($0).pointee) }
|
||||
|
||||
expect(tag.oid).to(equal(oid))
|
||||
expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.target).to(equal(Pointer.commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.name).to(equal("tag-1"))
|
||||
expect(tag.tagger).to(equal(tagger))
|
||||
expect(tag.message).to(equal("tag-1\n"))
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Result
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitReference<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -25,8 +24,8 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceSpec: QuickSpec {
|
||||
override func spec() {
|
||||
class ReferenceSpec: FixturesSpec {
|
||||
override class func spec() {
|
||||
describe("Reference(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -65,7 +64,7 @@ class ReferenceSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class BranchSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("Branch(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.mantleRepository
|
||||
@@ -120,7 +119,7 @@ class BranchSpec: QuickSpec {
|
||||
}
|
||||
|
||||
class TagReferenceSpec: QuickSpec {
|
||||
override func spec() {
|
||||
override class func spec() {
|
||||
describe("TagReference(pointer)") {
|
||||
it("should work with an annotated tag") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Result
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitRemote<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -25,8 +24,8 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteSpec: QuickSpec {
|
||||
override func spec() {
|
||||
class RemoteSpec: FixturesSpec {
|
||||
override class func spec() {
|
||||
describe("Remote(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
let repo = Fixtures.mantleRepository
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Result
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import Guanaco
|
||||
|
||||
class RepositorySpec: QuickSpec {
|
||||
override func spec() {
|
||||
// swiftlint:disable cyclomatic_complexity
|
||||
|
||||
class RepositorySpec: FixturesSpec {
|
||||
override class func spec() {
|
||||
describe("Repository.Type.at(_:)") {
|
||||
it("should work if the repo exists") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
@@ -23,10 +23,61 @@ class RepositorySpec: QuickSpec {
|
||||
it("should fail if the repo doesn't exist") {
|
||||
let url = URL(fileURLWithPath: "blah")
|
||||
let result = Repository.at(url)
|
||||
expect(result).to(haveFailed(beAnError(
|
||||
domain: equal(libGit2ErrorDomain),
|
||||
localizedDescription: match("Failed to resolve path")
|
||||
)))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
expect(result.error?.localizedDescription).to(match("failed to resolve path"))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.Type.isValid(url:)") {
|
||||
it("should return true if the repo exists") {
|
||||
guard let repositoryURL = Fixtures.simpleRepository.directoryURL else {
|
||||
fail("Fixture setup broken: Repository does not exist"); return
|
||||
}
|
||||
|
||||
let result = Repository.isValid(url: repositoryURL)
|
||||
|
||||
expect(result.error).to(beNil())
|
||||
|
||||
if case .success(let isValid) = result {
|
||||
expect(isValid).to(beTruthy())
|
||||
}
|
||||
}
|
||||
|
||||
it("should return false if the directory does not contain a repo") {
|
||||
let tmpURL = URL(fileURLWithPath: "/dev/null")
|
||||
let result = Repository.isValid(url: tmpURL)
|
||||
|
||||
expect(result.error).to(beNil())
|
||||
|
||||
if case .success(let isValid) = result {
|
||||
expect(isValid).to(beFalsy())
|
||||
}
|
||||
}
|
||||
|
||||
it("should return error if .git is not readable") {
|
||||
let localURL = self.temporaryURL(forPurpose: "git-isValid-unreadable").appendingPathComponent(".git")
|
||||
let nonReadablePermissions: [FileAttributeKey: Any] = [.posixPermissions: 0o077]
|
||||
try! FileManager.default.createDirectory(
|
||||
at: localURL,
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nonReadablePermissions)
|
||||
let result = Repository.isValid(url: localURL)
|
||||
|
||||
expect(result.value).to(beNil())
|
||||
expect(result.error).notTo(beNil())
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.Type.create(at:)") {
|
||||
it("should create a new repo at the specified location") {
|
||||
let localURL = self.temporaryURL(forPurpose: "local-create")
|
||||
let result = Repository.create(at: localURL)
|
||||
|
||||
expect(result.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = result {
|
||||
expect(clonedRepo.directoryURL).notTo(beNil())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +87,7 @@ class RepositorySpec: QuickSpec {
|
||||
let localURL = self.temporaryURL(forPurpose: "local-clone")
|
||||
let result = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true)
|
||||
|
||||
expect(result).to(haveSucceeded())
|
||||
expect(result.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = result {
|
||||
expect(clonedRepo.directoryURL).notTo(beNil())
|
||||
@@ -48,7 +99,7 @@ class RepositorySpec: QuickSpec {
|
||||
let localURL = self.temporaryURL(forPurpose: "bare-clone")
|
||||
let result = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true, bare: true)
|
||||
|
||||
expect(result).to(haveSucceeded())
|
||||
expect(result.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = result {
|
||||
expect(clonedRepo.directoryURL).to(beNil())
|
||||
@@ -60,11 +111,11 @@ class RepositorySpec: QuickSpec {
|
||||
let localURL = self.temporaryURL(forPurpose: "valid-remote-clone")
|
||||
let cloneResult = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true)
|
||||
|
||||
expect(cloneResult).to(haveSucceeded())
|
||||
expect(cloneResult.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = cloneResult {
|
||||
let remoteResult = clonedRepo.remote(named: "origin")
|
||||
expect(remoteResult).to(haveSucceeded())
|
||||
expect(remoteResult.error).to(beNil())
|
||||
|
||||
if case .success(let remote) = remoteResult {
|
||||
expect(remote.URL).to(equal(remoteRepo.directoryURL?.absoluteString))
|
||||
@@ -77,11 +128,11 @@ class RepositorySpec: QuickSpec {
|
||||
let localURL = self.temporaryURL(forPurpose: "public-remote-clone")
|
||||
let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL)
|
||||
|
||||
expect(cloneResult).to(haveSucceeded())
|
||||
expect(cloneResult.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = cloneResult {
|
||||
let remoteResult = clonedRepo.remote(named: "origin")
|
||||
expect(remoteResult).to(haveSucceeded())
|
||||
expect(remoteResult.error).to(beNil())
|
||||
|
||||
if case .success(let remote) = remoteResult {
|
||||
expect(remote.URL).to(equal(remoteRepoURL?.absoluteString))
|
||||
@@ -92,26 +143,26 @@ class RepositorySpec: QuickSpec {
|
||||
let env = ProcessInfo.processInfo.environment
|
||||
|
||||
if let privateRepo = env["SG2TestPrivateRepo"],
|
||||
let gitUsername = env["SG2TestUsername"],
|
||||
let publicKey = env["SG2TestPublicKey"],
|
||||
let privateKey = env["SG2TestPrivateKey"],
|
||||
let passphrase = env["SG2TestPassphrase"] {
|
||||
let gitUsername = env["SG2TestUsername"],
|
||||
let publicKey = env["SG2TestPublicKey"],
|
||||
let privateKey = env["SG2TestPrivateKey"],
|
||||
let passphrase = env["SG2TestPassphrase"] {
|
||||
|
||||
it("should be able to clone a remote repository requiring credentials") {
|
||||
let remoteRepoURL = URL(string: privateRepo)
|
||||
let localURL = self.temporaryURL(forPurpose: "private-remote-clone")
|
||||
let credentials = Credentials.SSHMemory(username: gitUsername,
|
||||
let credentials = Credentials.sshMemory(username: gitUsername,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
passphrase: passphrase)
|
||||
|
||||
let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL, credentials: credentials)
|
||||
|
||||
expect(cloneResult).to(haveSucceeded())
|
||||
expect(cloneResult.error).to(beNil())
|
||||
|
||||
if case .success(let clonedRepo) = cloneResult {
|
||||
let remoteResult = clonedRepo.remote(named: "origin")
|
||||
expect(remoteResult).to(haveSucceeded())
|
||||
expect(remoteResult.error).to(beNil())
|
||||
|
||||
if case .success(let remote) = remoteResult {
|
||||
expect(remote.URL).to(equal(remoteRepoURL?.absoluteString))
|
||||
@@ -127,7 +178,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
|
||||
|
||||
let result = repo.blob(oid)
|
||||
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
|
||||
expect(result.map { $0.oid }.value) == oid
|
||||
}
|
||||
|
||||
it("should error if the blob doesn't exist") {
|
||||
@@ -135,7 +186,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
|
||||
|
||||
let result = repo.blob(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
|
||||
it("should error if the oid doesn't point to a blob") {
|
||||
@@ -144,7 +195,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
|
||||
let result = repo.blob(oid)
|
||||
expect(result).to(haveFailed())
|
||||
expect(result.error).notTo(beNil())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +205,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
|
||||
let result = repo.commit(oid)
|
||||
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
|
||||
expect(result.map { $0.oid }.value) == oid
|
||||
}
|
||||
|
||||
it("should error if the commit doesn't exist") {
|
||||
@@ -162,7 +213,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
|
||||
|
||||
let result = repo.commit(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
|
||||
it("should error if the oid doesn't point to a commit") {
|
||||
@@ -171,7 +222,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
|
||||
let result = repo.commit(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +232,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
|
||||
|
||||
let result = repo.tag(oid)
|
||||
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
|
||||
expect(result.map { $0.oid }.value) == oid
|
||||
}
|
||||
|
||||
it("should error if the tag doesn't exist") {
|
||||
@@ -189,7 +240,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
|
||||
|
||||
let result = repo.tag(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
|
||||
it("should error if the oid doesn't point to a tag") {
|
||||
@@ -198,7 +249,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
|
||||
let result = repo.tag(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +259,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
|
||||
let result = repo.tree(oid)
|
||||
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
|
||||
expect(result.map { $0.oid }.value) == oid
|
||||
}
|
||||
|
||||
it("should error if the tree doesn't exist") {
|
||||
@@ -216,7 +267,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
|
||||
|
||||
let result = repo.tree(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
|
||||
it("should error if the oid doesn't point to a tree") {
|
||||
@@ -225,7 +276,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
|
||||
let result = repo.tree(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +286,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
|
||||
let blob = repo.blob(oid).value
|
||||
let result = repo.object(oid)
|
||||
expect(result.map { $0 as! Blob }).to(haveSucceeded(equal(blob)))
|
||||
expect(result.map { $0 as! Blob }.value) == blob
|
||||
}
|
||||
|
||||
it("should work with a commit") {
|
||||
@@ -243,7 +294,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
let commit = repo.commit(oid).value
|
||||
let result = repo.object(oid)
|
||||
expect(result.map { $0 as! Commit }).to(haveSucceeded(equal(commit)))
|
||||
expect(result.map { $0 as! Commit }.value) == commit
|
||||
}
|
||||
|
||||
it("should work with a tag") {
|
||||
@@ -251,7 +302,7 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
|
||||
let tag = repo.tag(oid).value
|
||||
let result = repo.object(oid)
|
||||
expect(result.map { $0 as! Tag }).to(haveSucceeded(equal(tag)))
|
||||
expect(result.map { $0 as! Tag }.value) == tag
|
||||
}
|
||||
|
||||
it("should work with a tree") {
|
||||
@@ -259,14 +310,14 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
let tree = repo.tree(oid).value
|
||||
let result = repo.object(oid)
|
||||
expect(result.map { $0 as! Tree }).to(haveSucceeded(equal(tree)))
|
||||
expect(result.map { $0 as! Tree }.value) == tree
|
||||
}
|
||||
|
||||
it("should error if there's no object with that oid") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
|
||||
let result = repo.object(oid)
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +328,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
let pointer = PointerTo<Commit>(oid)
|
||||
let commit = repo.commit(oid).value!
|
||||
expect(repo.object(from: pointer)).to(haveSucceeded(equal(commit)))
|
||||
expect(repo.object(from: pointer).value) == commit
|
||||
}
|
||||
|
||||
it("should work with trees") {
|
||||
@@ -286,7 +337,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
let pointer = PointerTo<Tree>(oid)
|
||||
let tree = repo.tree(oid).value!
|
||||
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tree)))
|
||||
expect(repo.object(from: pointer).value) == tree
|
||||
}
|
||||
|
||||
it("should work with blobs") {
|
||||
@@ -295,7 +346,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
let pointer = PointerTo<Blob>(oid)
|
||||
let blob = repo.blob(oid).value!
|
||||
expect(repo.object(from: pointer)).to(haveSucceeded(equal(blob)))
|
||||
expect(repo.object(from: pointer).value) == blob
|
||||
}
|
||||
|
||||
it("should work with tags") {
|
||||
@@ -304,7 +355,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
let pointer = PointerTo<Tag>(oid)
|
||||
let tag = repo.tag(oid).value!
|
||||
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tag)))
|
||||
expect(repo.object(from: pointer).value) == tag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,40 +364,40 @@ class RepositorySpec: QuickSpec {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
|
||||
let pointer = Pointer.Commit(oid)
|
||||
let pointer = Pointer.commit(oid)
|
||||
let commit = repo.commit(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Commit }
|
||||
expect(result).to(haveSucceeded(equal(commit)))
|
||||
expect(result.value) == commit
|
||||
}
|
||||
|
||||
it("should work with trees") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
|
||||
let pointer = Pointer.Tree(oid)
|
||||
let pointer = Pointer.tree(oid)
|
||||
let tree = repo.tree(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Tree }
|
||||
expect(result).to(haveSucceeded(equal(tree)))
|
||||
expect(result.value) == tree
|
||||
}
|
||||
|
||||
it("should work with blobs") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
|
||||
|
||||
let pointer = Pointer.Blob(oid)
|
||||
let pointer = Pointer.blob(oid)
|
||||
let blob = repo.blob(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Blob }
|
||||
expect(result).to(haveSucceeded(equal(blob)))
|
||||
expect(result.value) == blob
|
||||
}
|
||||
|
||||
it("should work with tags") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
|
||||
|
||||
let pointer = Pointer.Tag(oid)
|
||||
let pointer = Pointer.tag(oid)
|
||||
let tag = repo.tag(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Tag }
|
||||
expect(result).to(haveSucceeded(equal(tag)))
|
||||
expect(result.value) == tag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,15 +405,15 @@ class RepositorySpec: QuickSpec {
|
||||
it("should return an empty list if there are no remotes") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let result = repo.allRemotes()
|
||||
expect(result).to(haveSucceeded(beEmpty()))
|
||||
expect(result.value) == []
|
||||
}
|
||||
|
||||
it("should return all the remotes") {
|
||||
let repo = Fixtures.mantleRepository
|
||||
let remotes = repo.allRemotes()
|
||||
let names = remotes.map { $0.map { $0.name } }
|
||||
expect(remotes.map { $0.count }).to(haveSucceeded(equal(2)))
|
||||
expect(names).to(haveSucceeded(contain("origin", "upstream")))
|
||||
expect(remotes.map { $0.count }.value) == 2
|
||||
expect(names.value).to(contain("origin", "upstream"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,13 +421,13 @@ class RepositorySpec: QuickSpec {
|
||||
it("should return the remote if it exists") {
|
||||
let repo = Fixtures.mantleRepository
|
||||
let result = repo.remote(named: "upstream")
|
||||
expect(result.map { $0.name }).to(haveSucceeded(equal("upstream")))
|
||||
expect(result.map { $0.name }.value) == "upstream"
|
||||
}
|
||||
|
||||
it("should error if the remote doesn't exist") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let result = repo.remote(named: "nonexistent")
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,14 +435,14 @@ class RepositorySpec: QuickSpec {
|
||||
it("should return a local branch if it exists") {
|
||||
let name = "refs/heads/master"
|
||||
let result = Fixtures.simpleRepository.reference(named: name)
|
||||
expect(result.map { $0.longName }).to(haveSucceeded(equal(name)))
|
||||
expect(result.map { $0.longName }.value) == name
|
||||
expect(result.value as? Branch).notTo(beNil())
|
||||
}
|
||||
|
||||
it("should return a remote branch if it exists") {
|
||||
let name = "refs/remotes/upstream/master"
|
||||
let result = Fixtures.mantleRepository.reference(named: name)
|
||||
expect(result.map { $0.longName }).to(haveSucceeded(equal(name)))
|
||||
expect(result.map { $0.longName }.value) == name
|
||||
expect(result.value as? Branch).notTo(beNil())
|
||||
}
|
||||
|
||||
@@ -410,7 +461,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
it("should error if the reference doesn't exist") {
|
||||
let result = Fixtures.simpleRepository.reference(named: "refs/heads/nonexistent")
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +501,7 @@ class RepositorySpec: QuickSpec {
|
||||
]
|
||||
let expected = expectedNames.map { repo.remoteBranch(named: $0).value! }
|
||||
let actual = repo.remoteBranches().value!.sorted {
|
||||
return $0.longName.characters.lexicographicallyPrecedes($1.longName.characters)
|
||||
return $0.longName.lexicographicallyPrecedes($1.longName)
|
||||
}
|
||||
expect(actual).to(equal(expected))
|
||||
expect(actual.map { $0.name }).to(equal(expectedNames))
|
||||
@@ -465,7 +516,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
it("should error if the branch doesn't exists") {
|
||||
let result = Fixtures.simpleRepository.localBranch(named: "nonexistent")
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +528,15 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
it("should error if the branch doesn't exists") {
|
||||
let result = Fixtures.simpleRepository.remoteBranch(named: "origin/nonexistent")
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.fetch(_:)") {
|
||||
it("should fetch the data") {
|
||||
let repo = Fixtures.mantleRepository
|
||||
let remote = repo.remote(named: "origin").value!
|
||||
expect(repo.fetch(remote).value).toNot(beNil())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,7 +559,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
it("should error if the branch doesn't exists") {
|
||||
let result = Fixtures.simpleRepository.tag(named: "nonexistent")
|
||||
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
|
||||
expect(result.error?.domain) == libGit2ErrorDomain
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,12 +586,12 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!
|
||||
expect(repo.HEAD().value?.shortName).to(equal("master"))
|
||||
|
||||
expect(repo.setHEAD(oid)).to(haveSucceeded())
|
||||
expect(repo.setHEAD(oid).error).to(beNil())
|
||||
let HEAD = repo.HEAD().value
|
||||
expect(HEAD?.longName).to(equal("HEAD"))
|
||||
expect(HEAD?.oid).to(equal(oid))
|
||||
|
||||
expect(repo.setHEAD(repo.localBranch(named: "master").value!)).to(haveSucceeded())
|
||||
expect(repo.setHEAD(repo.localBranch(named: "master").value!).error).to(beNil())
|
||||
expect(repo.HEAD().value?.shortName).to(equal("master"))
|
||||
}
|
||||
}
|
||||
@@ -544,10 +603,10 @@ class RepositorySpec: QuickSpec {
|
||||
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
|
||||
|
||||
let branch = repo.localBranch(named: "another-branch").value!
|
||||
expect(repo.setHEAD(branch)).to(haveSucceeded())
|
||||
expect(repo.setHEAD(branch).error).to(beNil())
|
||||
expect(repo.HEAD().value?.shortName).to(equal(branch.name))
|
||||
|
||||
expect(repo.setHEAD(oid)).to(haveSucceeded())
|
||||
expect(repo.setHEAD(oid).error).to(beNil())
|
||||
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
|
||||
}
|
||||
}
|
||||
@@ -562,12 +621,12 @@ class RepositorySpec: QuickSpec {
|
||||
let oid = OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!
|
||||
expect(repo.HEAD().value?.shortName).to(equal("master"))
|
||||
|
||||
expect(repo.checkout(oid, strategy: CheckoutStrategy.None)).to(haveSucceeded())
|
||||
expect(repo.checkout(oid, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
let HEAD = repo.HEAD().value
|
||||
expect(HEAD?.longName).to(equal("HEAD"))
|
||||
expect(HEAD?.oid).to(equal(oid))
|
||||
|
||||
expect(repo.checkout(repo.localBranch(named: "master").value!, strategy: CheckoutStrategy.None)).to(haveSucceeded())
|
||||
expect(repo.checkout(repo.localBranch(named: "master").value!, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
expect(repo.HEAD().value?.shortName).to(equal("master"))
|
||||
}
|
||||
|
||||
@@ -578,7 +637,7 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
expect(repo.checkout(oid, strategy: .None, progress: { (_, completedSteps, totalSteps) -> Void in
|
||||
expect(completedSteps).to(beLessThanOrEqualTo(totalSteps))
|
||||
})).to(haveSucceeded())
|
||||
}).error).to(beNil())
|
||||
|
||||
let HEAD = repo.HEAD().value
|
||||
expect(HEAD?.longName).to(equal("HEAD"))
|
||||
@@ -593,16 +652,335 @@ class RepositorySpec: QuickSpec {
|
||||
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
|
||||
|
||||
let branch = repo.localBranch(named: "another-branch").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None)).to(haveSucceeded())
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
expect(repo.HEAD().value?.shortName).to(equal(branch.name))
|
||||
|
||||
expect(repo.checkout(oid, strategy: CheckoutStrategy.None)).to(haveSucceeded())
|
||||
expect(repo.checkout(oid, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.allCommits(in:)") {
|
||||
it("should return all (9) commits") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let branches = repo.localBranches().value!
|
||||
let expectedCount = 9
|
||||
let expectedMessages: [String] = [
|
||||
"List branches in README\n",
|
||||
"Create a README\n",
|
||||
"Merge branch 'alphabetize'\n",
|
||||
"Alphabetize branches\n",
|
||||
"List new branches\n",
|
||||
"List branches in README\n",
|
||||
"Create a README\n",
|
||||
"List branches in README\n",
|
||||
"Create a README\n",
|
||||
]
|
||||
var commitMessages: [String] = []
|
||||
for branch in branches {
|
||||
for commit in repo.commits(in: branch) {
|
||||
commitMessages.append(commit.value!.message)
|
||||
}
|
||||
}
|
||||
expect(commitMessages.count).to(equal(expectedCount))
|
||||
expect(commitMessages).to(equal(expectedMessages))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.add") {
|
||||
it("Should add the modification under a path") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let branch = repo.localBranch(named: "master").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
// make a change to README
|
||||
let readmeURL = repo.directoryURL!.appendingPathComponent("README.md")
|
||||
let readmeData = try! Data(contentsOf: readmeURL)
|
||||
defer { try! readmeData.write(to: readmeURL) }
|
||||
|
||||
try! "different".data(using: .utf8)?.write(to: readmeURL)
|
||||
|
||||
let status = repo.status()
|
||||
expect(status.value?.count).to(equal(1))
|
||||
expect(status.value!.first!.status).to(equal(.workTreeModified))
|
||||
|
||||
expect(repo.add(path: "README.md").error).to(beNil())
|
||||
|
||||
let newStatus = repo.status()
|
||||
expect(newStatus.value?.count).to(equal(1))
|
||||
expect(newStatus.value!.first!.status).to(equal(.indexModified))
|
||||
}
|
||||
|
||||
it("Should add an untracked file under a path") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let branch = repo.localBranch(named: "master").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
// make a change to README
|
||||
let untrackedURL = repo.directoryURL!.appendingPathComponent("untracked")
|
||||
try! "different".data(using: .utf8)?.write(to: untrackedURL)
|
||||
defer { try! FileManager.default.removeItem(at: untrackedURL) }
|
||||
|
||||
expect(repo.add(path: ".").error).to(beNil())
|
||||
|
||||
let newStatus = repo.status()
|
||||
expect(newStatus.value?.count).to(equal(1))
|
||||
expect(newStatus.value!.first!.status).to(equal(.indexNew))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.commit") {
|
||||
it("Should perform a simple commit with specified signature") {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let branch = repo.localBranch(named: "master").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
// make a change to README
|
||||
let untrackedURL = repo.directoryURL!.appendingPathComponent("untrackedtest")
|
||||
try! "different".data(using: .utf8)?.write(to: untrackedURL)
|
||||
|
||||
expect(repo.add(path: ".").error).to(beNil())
|
||||
|
||||
let signature = Signature(
|
||||
name: "swiftgit2",
|
||||
email: "foobar@example.com",
|
||||
time: Date(timeIntervalSince1970: 1525200858),
|
||||
timeZone: TimeZone(secondsFromGMT: 3600)!
|
||||
)
|
||||
let message = "Test Commit"
|
||||
expect(repo.commit(message: message, signature: signature).error).to(beNil())
|
||||
let updatedBranch = repo.localBranch(named: "master").value!
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.author).to(equal(signature))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.committer).to(equal(signature))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.message).to(equal("\(message)\n"))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.oid.description)
|
||||
.to(equal("7d6b2d7492f29aee48022387f96dbfe996d435fe"))
|
||||
|
||||
// should be clean now
|
||||
let newStatus = repo.status()
|
||||
expect(newStatus.value?.count).to(equal(0))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.status") {
|
||||
it("Should accurately report status for repositories with no status") {
|
||||
let expectedCount = 0
|
||||
|
||||
let repo = Fixtures.mantleRepository
|
||||
let branch = repo.localBranch(named: "master").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
let status = repo.status()
|
||||
|
||||
expect(status.value?.count).to(equal(expectedCount))
|
||||
}
|
||||
|
||||
it("Should accurately report status for repositories with status") {
|
||||
let expectedCount = 6
|
||||
let expectedNewFilePaths = [
|
||||
"stage-file-1",
|
||||
"stage-file-2",
|
||||
"stage-file-3",
|
||||
"stage-file-4",
|
||||
"stage-file-5",
|
||||
]
|
||||
let expectedOldFilePaths = [
|
||||
"stage-file-1",
|
||||
"stage-file-2",
|
||||
"stage-file-3",
|
||||
"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!
|
||||
expect(repoWithStatus.checkout(branchWithStatus, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
let statuses = repoWithStatus.status().value!
|
||||
|
||||
var newFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
if let path = status.headToIndex?.newFile?.path {
|
||||
newFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
var oldFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
describe("Repository.diff") {
|
||||
it("Should have accurate delta information") {
|
||||
let expectedCount = 13
|
||||
let expectedNewFilePaths = [
|
||||
".gitmodules",
|
||||
"Cartfile",
|
||||
"Cartfile.lock",
|
||||
"Cartfile.private",
|
||||
"Cartfile.resolved",
|
||||
"Carthage.checkout/Nimble",
|
||||
"Carthage.checkout/Quick",
|
||||
"Carthage.checkout/xcconfigs",
|
||||
"Carthage/Checkouts/Nimble",
|
||||
"Carthage/Checkouts/Quick",
|
||||
"Carthage/Checkouts/xcconfigs",
|
||||
"Mantle.xcodeproj/project.pbxproj",
|
||||
"Mantle.xcworkspace/contents.xcworkspacedata",
|
||||
]
|
||||
let expectedOldFilePaths = [
|
||||
".gitmodules",
|
||||
"Cartfile",
|
||||
"Cartfile.lock",
|
||||
"Cartfile.private",
|
||||
"Cartfile.resolved",
|
||||
"Carthage.checkout/Nimble",
|
||||
"Carthage.checkout/Quick",
|
||||
"Carthage.checkout/xcconfigs",
|
||||
"Carthage/Checkouts/Nimble",
|
||||
"Carthage/Checkouts/Quick",
|
||||
"Carthage/Checkouts/xcconfigs",
|
||||
"Mantle.xcodeproj/project.pbxproj",
|
||||
"Mantle.xcworkspace/contents.xcworkspacedata",
|
||||
]
|
||||
|
||||
let repo = Fixtures.mantleRepository
|
||||
let branch = repo.localBranch(named: "master").value!
|
||||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
|
||||
let head = repo.HEAD().value!
|
||||
let commit = repo.object(head.oid).value! as! Commit
|
||||
let diff = repo.diff(for: commit).value!
|
||||
|
||||
let newFilePaths = diff.deltas.map { $0.newFile!.path }
|
||||
let oldFilePaths = diff.deltas.map { $0.oldFile!.path }
|
||||
|
||||
expect(diff.deltas.count).to(equal(expectedCount))
|
||||
expect(newFilePaths).to(equal(expectedNewFilePaths))
|
||||
expect(oldFilePaths).to(equal(expectedOldFilePaths))
|
||||
}
|
||||
|
||||
it("Should handle initial commit well") {
|
||||
let expectedCount = 2
|
||||
let expectedNewFilePaths = [
|
||||
".gitignore",
|
||||
"README.md",
|
||||
]
|
||||
let expectedOldFilePaths = [
|
||||
".gitignore",
|
||||
"README.md",
|
||||
]
|
||||
|
||||
let repo = Fixtures.mantleRepository
|
||||
expect(repo.checkout(OID(string: "047b931bd7f5478340cef5885a6fff713005f4d6")!,
|
||||
strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
let head = repo.HEAD().value!
|
||||
let initalCommit = repo.object(head.oid).value! as! Commit
|
||||
let diff = repo.diff(for: initalCommit).value!
|
||||
|
||||
var newFilePaths: [String] = []
|
||||
for delta in diff.deltas {
|
||||
newFilePaths.append((delta.newFile?.path)!)
|
||||
}
|
||||
var oldFilePaths: [String] = []
|
||||
for delta in diff.deltas {
|
||||
oldFilePaths.append((delta.oldFile?.path)!)
|
||||
}
|
||||
|
||||
expect(diff.deltas.count).to(equal(expectedCount))
|
||||
expect(newFilePaths).to(equal(expectedNewFilePaths))
|
||||
expect(oldFilePaths).to(equal(expectedOldFilePaths))
|
||||
}
|
||||
|
||||
it("Should handle merge commits well") {
|
||||
let expectedCount = 20
|
||||
let expectedNewFilePaths = [
|
||||
"Mantle.xcodeproj/project.pbxproj",
|
||||
"Mantle/MTLModel+NSCoding.m",
|
||||
"Mantle/Mantle.h",
|
||||
"Mantle/NSArray+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSArray+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSArray+MTLManipulationAdditions.m",
|
||||
"Mantle/NSDictionary+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSDictionary+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSDictionary+MTLManipulationAdditions.m",
|
||||
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.h",
|
||||
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.m",
|
||||
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSSet+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSSet+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.m",
|
||||
"MantleTests/MTLHigherOrderAdditionsSpec.m",
|
||||
"MantleTests/MTLNotificationCenterAdditionsSpec.m",
|
||||
"MantleTests/MTLPredefinedTransformerAdditionsSpec.m",
|
||||
"README.md",
|
||||
]
|
||||
let expectedOldFilePaths = [
|
||||
"Mantle.xcodeproj/project.pbxproj",
|
||||
"Mantle/MTLModel+NSCoding.m",
|
||||
"Mantle/Mantle.h",
|
||||
"Mantle/NSArray+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSArray+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSArray+MTLManipulationAdditions.m",
|
||||
"Mantle/NSDictionary+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSDictionary+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSDictionary+MTLManipulationAdditions.m",
|
||||
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.h",
|
||||
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.m",
|
||||
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSSet+MTLHigherOrderAdditions.h",
|
||||
"Mantle/NSSet+MTLHigherOrderAdditions.m",
|
||||
"Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.m",
|
||||
"MantleTests/MTLHigherOrderAdditionsSpec.m",
|
||||
"MantleTests/MTLNotificationCenterAdditionsSpec.m",
|
||||
"MantleTests/MTLPredefinedTransformerAdditionsSpec.m",
|
||||
"README.md",
|
||||
]
|
||||
|
||||
let repo = Fixtures.mantleRepository
|
||||
expect(repo.checkout(OID(string: "d0d9c13da5eb5f9e8cf2a9f1f6ca3bdbe975b57d")!,
|
||||
strategy: CheckoutStrategy.None).error).to(beNil())
|
||||
let head = repo.HEAD().value!
|
||||
let initalCommit = repo.object(head.oid).value! as! Commit
|
||||
let diff = repo.diff(for: initalCommit).value!
|
||||
|
||||
var newFilePaths: [String] = []
|
||||
for delta in diff.deltas {
|
||||
newFilePaths.append((delta.newFile?.path)!)
|
||||
}
|
||||
var oldFilePaths: [String] = []
|
||||
for delta in diff.deltas {
|
||||
oldFilePaths.append((delta.oldFile?.path)!)
|
||||
}
|
||||
|
||||
expect(diff.deltas.count).to(equal(expectedCount))
|
||||
expect(newFilePaths).to(equal(expectedNewFilePaths))
|
||||
expect(oldFilePaths).to(equal(expectedOldFilePaths))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func temporaryURL(forPurpose purpose: String) -> URL {
|
||||
static func temporaryURL(forPurpose purpose: String) -> URL {
|
||||
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
|
||||
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
|
||||
return URL(fileURLWithPath: path)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Once Nimble adds matchers for the Result type, remove these shims and refactor the tests that use them.
|
||||
extension Result {
|
||||
var value: Success? {
|
||||
guard case .success(let value) = self else {
|
||||
return nil
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
var error: Failure? {
|
||||
guard case .failure(let error) = self else {
|
||||
return nil
|
||||
}
|
||||
return error
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
module libgit2 {
|
||||
module Clibgit2 {
|
||||
umbrella header "git2.h"
|
||||
|
||||
export *
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ check_deps ()
|
||||
done
|
||||
|
||||
brew_prefix=`brew --prefix`
|
||||
expected_prefix=/usr/local
|
||||
expected_prefix=/opt/homebrew
|
||||
|
||||
if [ "$brew_prefix" != "$expected_prefix" ]
|
||||
then
|
||||
|
||||
+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..."
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# augment path to help it find cmake via homebrew
|
||||
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
source "${SCRIPT_DIR}/xcode_functions.sh"
|
||||
|
||||
function setup_build_environment ()
|
||||
{
|
||||
# augment path to help it find cmake installed in /usr/local/bin,
|
||||
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
|
||||
# ~/.MacOSX/environment.plist
|
||||
PATH="/usr/local/bin:/opt/boxen/homebrew/bin:$PATH"
|
||||
|
||||
pushd "$SCRIPT_DIR/.." > /dev/null
|
||||
ROOT_PATH="$PWD"
|
||||
popd > /dev/null
|
||||
@@ -22,7 +20,7 @@ function setup_build_environment ()
|
||||
MACOSX_DEPLOYMENT_TARGET=""
|
||||
|
||||
XCODE_MAJOR_VERSION=$(xcode_major_version)
|
||||
|
||||
|
||||
CAN_BUILD_64BIT="0"
|
||||
|
||||
# If IPHONEOS_DEPLOYMENT_TARGET has not been specified
|
||||
@@ -30,28 +28,30 @@ function setup_build_environment ()
|
||||
# directly (ie not from an Xcode proj)
|
||||
if [ -z "${IPHONEOS_DEPLOYMENT_TARGET}" ]
|
||||
then
|
||||
IPHONEOS_DEPLOYMENT_TARGET="6.0"
|
||||
IPHONEOS_DEPLOYMENT_TARGET="12.0"
|
||||
fi
|
||||
|
||||
|
||||
# Determine if we can be building 64-bit binaries
|
||||
if [ "${XCODE_MAJOR_VERSION}" -ge "5" ] && [ $(echo ${IPHONEOS_DEPLOYMENT_TARGET} '>=' 6.0 | bc -l) == "1" ]
|
||||
then
|
||||
CAN_BUILD_64BIT="1"
|
||||
fi
|
||||
|
||||
ARCHS="i386 armv7 armv7s"
|
||||
ARCHS=""
|
||||
if [ "${CAN_BUILD_64BIT}" -eq "1" ]
|
||||
then
|
||||
# For some stupid reason cmake needs simulator
|
||||
# builds to be first
|
||||
ARCHS="x86_64 ${ARCHS} arm64"
|
||||
else
|
||||
ARCHS="i386 ${ARCHS} armv7 armv7s"
|
||||
fi
|
||||
}
|
||||
|
||||
function build_all_archs ()
|
||||
{
|
||||
setup_build_environment
|
||||
|
||||
|
||||
local setup=$1
|
||||
local build_arch=$2
|
||||
local finish_build=$3
|
||||
@@ -63,11 +63,15 @@ function build_all_archs ()
|
||||
|
||||
for ARCH in ${ARCHS}
|
||||
do
|
||||
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ]
|
||||
PLATFORMS=""
|
||||
if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] || [ "${ARCH}" == "arm64" ]
|
||||
then
|
||||
PLATFORM="iphonesimulator"
|
||||
else
|
||||
PLATFORM="iphoneos"
|
||||
PLATFORMS="${PLATFORMS} iphonesimulator"
|
||||
fi
|
||||
|
||||
if [ "${ARCH}" == "arm64" ]
|
||||
then
|
||||
PLATFORMS="${PLATFORMS} iphoneos"
|
||||
fi
|
||||
|
||||
SDKVERSION=$(ios_sdk_version)
|
||||
@@ -79,17 +83,21 @@ function build_all_archs ()
|
||||
HOST="${ARCH}-apple-darwin"
|
||||
fi
|
||||
|
||||
SDKNAME="${PLATFORM}${SDKVERSION}"
|
||||
SDKROOT="$(ios_sdk_path ${SDKNAME})"
|
||||
|
||||
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH}"
|
||||
echo "Please stand by..."
|
||||
echo "Building ${ARCH} for ${PLATFORMS}"
|
||||
|
||||
# run the per arch build command
|
||||
eval $build_arch
|
||||
for PLATFORM in ${PLATFORMS}
|
||||
do
|
||||
SDKNAME="${PLATFORM}${SDKVERSION}"
|
||||
SDKROOT="$(sdk_path ${SDKNAME})"
|
||||
|
||||
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH} on ${PLATFORM}"
|
||||
echo "Please stand by..."
|
||||
|
||||
# run the per arch build command
|
||||
eval $build_arch
|
||||
done
|
||||
done
|
||||
|
||||
# finish the build (usually lipo)
|
||||
eval $finish_build
|
||||
}
|
||||
|
||||
|
||||
+102
-26
@@ -1,38 +1,114 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# augment path to help it find cmake installed in /usr/local/bin,
|
||||
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
|
||||
# ~/.MacOSX/environment.plist
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
# augment path to help it find cmake via homebrew
|
||||
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||
|
||||
if [ "External/libgit2.a" -nt "External/libgit2" ]
|
||||
then
|
||||
echo "No update needed."
|
||||
exit 0
|
||||
fi
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
source "${SCRIPT_DIR}/xcode_functions.sh"
|
||||
|
||||
cd "External/libgit2"
|
||||
function setup_build_environment ()
|
||||
{
|
||||
pushd "$SCRIPT_DIR/.." > /dev/null
|
||||
ROOT_PATH="$PWD"
|
||||
popd > /dev/null
|
||||
|
||||
if [ -d "build" ]; then
|
||||
CLANG="/usr/bin/xcrun clang"
|
||||
CC="${CLANG}"
|
||||
CPP="${CLANG} -E"
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET="10.13"
|
||||
|
||||
XCODE_MAJOR_VERSION=$(xcode_major_version)
|
||||
XCODE_MINOR_VERSION=$(xcode_minor_version)
|
||||
|
||||
if [ "${XCODE_MAJOR_VERSION}" -lt "14" ]
|
||||
then
|
||||
echo "Requires Xcode 14 or newer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ARCHS="x86_64 arm64"
|
||||
}
|
||||
|
||||
function setup ()
|
||||
{
|
||||
if [ "${ROOT_PATH}/External/libgit2-mac/libgit2-mac.a" -nt "${ROOT_PATH}/External/libgit2" ]
|
||||
then
|
||||
echo "No update needed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LIBRARY_NAME="libgit2"
|
||||
LIB_PATH="${ROOT_PATH}/External/libgit2-mac"
|
||||
rm -rf "${LIB_PATH}"
|
||||
|
||||
pushd "${ROOT_PATH}/External/libgit2" > /dev/null
|
||||
}
|
||||
|
||||
function build_libgit2 ()
|
||||
{
|
||||
rm -rf "build"
|
||||
fi
|
||||
mkdir "build"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
pushd "build" > /dev/null
|
||||
|
||||
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||
-DLIBSSH2_INCLUDE_DIRS:PATH=/usr/local/include/ \
|
||||
-DBUILD_CLAR:BOOL=OFF \
|
||||
-DTHREADSAFE:BOOL=ON \
|
||||
..
|
||||
cmake --build .
|
||||
# install the each built arch somewhere sane
|
||||
INSTALL_PREFIX="${LIB_PATH}/${SDKNAME}-${ARCH}.sdk"
|
||||
|
||||
product="libgit2.a"
|
||||
install_path="../../${product}"
|
||||
if [ "${product}" -nt "${install_path}" ]; then
|
||||
cp -v "${product}" "${install_path}"
|
||||
fi
|
||||
mkdir -p "${INSTALL_PREFIX}"
|
||||
|
||||
LOG="${INSTALL_PREFIX}/build-libgit2.log"
|
||||
echo "$LOG"
|
||||
|
||||
cmake \
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||
-DCMAKE_PREFIX_PATH:PATH="${ROOT_PATH}/External/libssh2-mac/bin/${SDKNAME}-${ARCH}.sdk" \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}/" \
|
||||
-DBUILD_CLAR:BOOL=OFF \
|
||||
-DTHREADSAFE:BOOL=ON \
|
||||
-DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${MACOSX_DEPLOYMENT_TARGET}" \
|
||||
.. >> "${LOG}" 2>&1
|
||||
cmake --build . --target install >> "${LOG}" 2>&1
|
||||
|
||||
# push the built library into the list
|
||||
BUILT_LIB_PATHS+=("${INSTALL_PREFIX}/lib/libgit2.a")
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function fat_binary ()
|
||||
{
|
||||
echo "Building fat binary..."
|
||||
|
||||
lipo -create "${BUILT_LIB_PATHS[@]}" -output "${ROOT_PATH}/External/libgit2-mac/libgit2-mac.a"
|
||||
|
||||
echo "Building done."
|
||||
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
setup_build_environment
|
||||
setup
|
||||
|
||||
echo "Building for ${ARCHS}"
|
||||
|
||||
for ARCH in ${ARCHS}
|
||||
do
|
||||
PLATFORM="macosx"
|
||||
SDKVERSION=$(macos_sdk_version)
|
||||
|
||||
SDKNAME="${PLATFORM}${SDKVERSION}"
|
||||
SDKROOT="$(sdk_path ${SDKNAME})"
|
||||
|
||||
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH}"
|
||||
echo "Please stand by..."
|
||||
|
||||
# run the per arch build command
|
||||
build_libgit2
|
||||
done
|
||||
|
||||
fat_binary
|
||||
|
||||
echo "libgit2 has been updated."
|
||||
|
||||
@@ -8,7 +8,7 @@ source "${SCRIPT_DIR}/ios_build_functions.sh"
|
||||
|
||||
function setup ()
|
||||
{
|
||||
if [ "${ROOT_PATH}/External/libgit2-ios/libgit2-ios.a" -nt "${ROOT_PATH}/External/libgit2" ]
|
||||
if [ "${ROOT_PATH}/External/libgit2-ios/libgit2.xcframework" -nt "${ROOT_PATH}/External/libgit2" ]
|
||||
then
|
||||
echo "No update needed."
|
||||
exit 0
|
||||
@@ -49,11 +49,14 @@ function build_libgit2 ()
|
||||
-DPKG_CONFIG_USE_CMAKE_PREFIX_PATH:BOOL=ON \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}/" \
|
||||
-DBUILD_CLAR:BOOL=OFF \
|
||||
-DBUILD_TESTS:BOOL=OFF \
|
||||
-DREGEX_BACKEND:STRING="builtin" \
|
||||
-DTHREADSAFE:BOOL=ON \
|
||||
-DCURL:BOOL=OFF \
|
||||
-DCMAKE_C_FLAGS:STRING="-fembed-bitcode" \
|
||||
"${SYS_ROOT}" \
|
||||
-DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${IPHONEOS_DEPLOYMENT_TARGET}" \
|
||||
.. >> "${LOG}" 2>&1
|
||||
cmake --build . --target install >> "${LOG}" 2>&1
|
||||
|
||||
@@ -64,13 +67,72 @@ function build_libgit2 ()
|
||||
|
||||
function fat_binary ()
|
||||
{
|
||||
echo "Building fat binary..."
|
||||
echo "Building fat binary for simulator..."
|
||||
|
||||
lipo -create "${BUILT_LIB_PATHS[@]}" -output "${ROOT_PATH}/External/libgit2-ios/libgit2-ios.a"
|
||||
# Collect all simulator build paths
|
||||
for path in "${BUILT_LIB_PATHS[@]}"
|
||||
do
|
||||
case "$path" in
|
||||
*libgit2-ios/iphonesimulator* )
|
||||
SIMULATOR_LIB_PATHS+=("$path")
|
||||
# Remember one header location (headers are the same, so overwriting doesn't matter)
|
||||
base_dir=$(dirname $(dirname "${path}"))
|
||||
HEADER_PATH="${base_dir}/include/git2.h"
|
||||
;;
|
||||
* )
|
||||
# Ignore libs build for the actual phone
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
SIMULATOR_LIB_DIR="${ROOT_PATH}/External/libgit2-ios/iphonesimulator"
|
||||
mkdir -p "${SIMULATOR_LIB_DIR}"
|
||||
|
||||
echo "... from ${SIMULATOR_LIB_PATHS[@]}"
|
||||
lipo -create "${SIMULATOR_LIB_PATHS[@]}" -output "${SIMULATOR_LIB_DIR}/libgit2.a"
|
||||
|
||||
echo "Copying shared simulator header from ${HEADER_PATH}"
|
||||
cp "${HEADER_PATH}" "${SIMULATOR_LIB_DIR}/libgit2.h"
|
||||
|
||||
echo "Building done."
|
||||
}
|
||||
|
||||
function xcframework ()
|
||||
{
|
||||
echo "Building XCFramework..."
|
||||
|
||||
for path in "${BUILT_LIB_PATHS[@]}"
|
||||
do
|
||||
case "$path" in
|
||||
*libgit2-ios/iphonesimulator* )
|
||||
# Skip simulator library binaries
|
||||
;;
|
||||
* )
|
||||
args+=("-library" "${path}")
|
||||
base_dir=$(dirname $(dirname "${path}"))
|
||||
args+=("-headers" "${base_dir}/include/git2.h")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
args+=("-library" "${SIMULATOR_LIB_DIR}/libgit2.a")
|
||||
args+=("-headers" "${SIMULATOR_LIB_DIR}/libgit2.h")
|
||||
|
||||
echo "... from ${args[@]}"
|
||||
xcodebuild -create-xcframework \
|
||||
"${args[@]}" \
|
||||
-output "${ROOT_PATH}/External/libgit2-ios/libgit2.xcframework"
|
||||
|
||||
echo "Building done."
|
||||
}
|
||||
|
||||
|
||||
function combine_all_the_binaries ()
|
||||
{
|
||||
fat_binary
|
||||
xcframework
|
||||
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
build_all_archs setup build_libgit2 fat_binary
|
||||
build_all_archs setup build_libgit2 combine_all_the_binaries
|
||||
|
||||
@@ -16,7 +16,7 @@ function setup ()
|
||||
LIBRARY_NAME="libssh2"
|
||||
}
|
||||
|
||||
function build_ssh2 ()
|
||||
function build_ssh2 ()
|
||||
{
|
||||
mkdir -p "${ROOT_PATH}/External/libssh2-ios/lib" "${ROOT_PATH}/External/libssh2-ios/lib" "${ROOT_PATH}/External/libssh2-ios/src"
|
||||
|
||||
@@ -47,7 +47,7 @@ function fat_binary ()
|
||||
|
||||
lipo -create "${BUILT_LIBS[@]}" -output "${ROOT_PATH}/External/libssh2-ios/lib/libssh2-ios.a"
|
||||
mkdir -p "${ROOT_PATH}/External/libssh2-ios/include/libssh2"
|
||||
cp -R "${ROOT_PATH}/External/libssh2-ios/bin/iphonesimulator${SDKVERSION}-i386.sdk/include/libssh2.h" "${ROOT_PATH}/External/libssh2-ios/include/libssh2/"
|
||||
cp -R "${ROOT_PATH}/External/libssh2-ios/bin/iphonesimulator${SDKVERSION}-x86_64.sdk/include/libssh2.h" "${ROOT_PATH}/External/libssh2-ios/include/libssh2/"
|
||||
|
||||
echo "Building done."
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ function xcode_major_version ()
|
||||
xcode_version | awk -F '.' '{ print $1 }'
|
||||
}
|
||||
|
||||
function xcode_minor_version ()
|
||||
{
|
||||
xcode_version | awk -F '.' '{ print $2 }'
|
||||
}
|
||||
|
||||
# Returns the latest iOS SDK version available via xcodebuild.
|
||||
function ios_sdk_version ()
|
||||
{
|
||||
@@ -26,11 +31,22 @@ function ios_sdk_version ()
|
||||
# iPhoneSimulator9.0.sdk - Simulator - iOS 9.0 (iphonesimulator9.0)
|
||||
# SDKVersion: 9.0
|
||||
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
function macos_sdk_version ()
|
||||
{
|
||||
# The grep command produces output like the following, singling out the
|
||||
# SDKVersion of just the Mac SDKs:
|
||||
#
|
||||
# MacOSX11.0.sdk - macOS 11.0 (macosx11.0)
|
||||
# SDKVersion: 11.0
|
||||
# ...
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^MacOSX' | tail -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
# Returns the path to the specified iOS SDK name
|
||||
function ios_sdk_path ()
|
||||
function sdk_path ()
|
||||
{
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -i $1 | grep 'Path:' | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user