148 Commits

Author SHA1 Message Date
Christian Tietze 6148d1b3d4 re-import XCFramework to make xcode shut up about file not being found 2023-10-17 16:43:58 +02:00
Christian Tietze 27d2f38b6a change lib paths to produce libgit2.a for both simulator and device 2023-10-17 16:43:58 +02:00
Christian Tietze f04fe39df5 combine fat binaries for simulator with XCFramework for sim + iphone 2023-10-17 16:43:58 +02:00
Christian Tietze c2e903a521 Revert "emit .xcframework for iOS instead of fat binary"
abec246c334ee7e201077de5af98275abd300074
2023-10-17 16:43:58 +02:00
Christian Tietze 8a8eef6e54 use CMAKE_OSX_DEPLOYMENT_TARGET setting 2023-10-17 16:43:58 +02:00
Christian Tietze 4cee705dd9 fix IPHONEOS_DEPLOYMENT_TARGET 2023-10-17 16:43:58 +02:00
Christian Tietze 77ae788bf6 fix libgit2-ios framework search path 2023-10-17 16:43:58 +02:00
Christian Tietze 158ba52f3d try removing libgit2-mac.a references in the OSX target 2023-10-17 16:43:58 +02:00
Christian Tietze 782a1fad2f require Xcode 14+ to simplify the build script for Mac 2023-10-17 16:43:58 +02:00
Christian Tietze 386a21f46c remove arm64e from macOS 2023-10-17 16:43:58 +02:00
Christian Tietze e77e3e17db statically link libgit-mac.a 2023-10-17 16:43:58 +02:00
Christian Tietze 3ce0d32a3b update homebrew path discovery 2023-10-17 16:43:58 +02:00
Christian Tietze 2adf4e1d35 add IOS_DEPLOYMENT_TARGET 2023-10-17 16:43:58 +02:00
Christian Tietze b0e94f89fe use Xcode 15's lowest iOS deployment target (12) 2023-10-17 16:43:58 +02:00
Christian Tietze 52b602674b re-wire SwifGit2-iOS to use XCFramework 2023-10-17 16:43:58 +02:00
Christian Tietze c7f4a14ae4 emit .xcframework for iOS instead of fat binary
Avoids overlapping architectures for ARM Simulator and ARM iOS
2023-10-17 16:43:58 +02:00
Christian Tietze 775b054be0 expand build matrix for all simulator platforms 2023-10-17 16:43:58 +02:00
Christian Tietze 5b8f53263e update iOS build script
- ignore tests (`system` calls are not supported on iOS anymore)
- use built-in regex instead of looking for PCRE (new to libgit2)
- drop i386 simulator architecture
2023-10-17 16:43:58 +02:00
Christian Tietze 4949d68379 inline build_all_archs function to remove indirection 2023-10-17 16:43:58 +02:00
Christian Tietze c6d8fa3b07 bump libgit2 to v1.7.1 2023-10-17 16:43:58 +02:00
Christian Tietze 0c79b59fb0 fix libgit2 url 2023-10-17 16:43:58 +02:00
Christian Tietze f69eee9b9b replace libgit2-OSX target with inline build phase 2023-10-17 16:43:58 +02:00
Christian Tietze 9e90f7c3ba reference build scripts in Xcode project for editing 2023-10-17 16:43:58 +02:00
Christian Tietze 71cbc53e75 bump macOS deployment target in build script 2023-10-17 16:43:58 +02:00
Christian Tietze 6058febb36 update Spec namespace which nowadays starts statically 2023-10-17 16:43:58 +02:00
Christian Tietze 39aca8e650 silence script running build phase warnings 2023-10-17 16:43:58 +02:00
Christian Tietze 1e7c415fd2 update Nimble/Quick/ZipArchive 2023-10-17 16:43:58 +02:00
Christian Tietze c181172606 bump deployment target for Xcode 14 2023-10-17 16:43:58 +02:00
Christian Tietze a7653667f4 use /opt/homebrew 2023-10-17 16:43:58 +02:00
Christian Tietze 3bbff975c0 use ARM homebrew paths 2023-10-17 16:43:58 +02:00
Christian Tietze 6fb4054d38 Merge pull request #193 from DivineDominion/mac-arm-framework
Fix Mac ARM framework creation
2023-10-09 17:44:41 +02:00
Christian Tietze db091b107e fix Xcode 13 can-build-for-ARM test 2021-09-29 08:44:27 +02:00
Christian Tietze e76de59957 Xcode now enquotes the script paths 2021-06-02 08:28:02 +02:00
Christian Tietze e7315035df override VALID_ARCHS to allow ARM 2021-06-01 11:38:38 +02:00
Christian Tietze 9343544dc9 set deployment target to 10.9 2021-06-01 11:38:38 +02:00
Christian Tietze 2b7899198d use similar paths to iOS 2021-06-01 11:38:38 +02:00
Christian Tietze 11ca78320d reference macOS SDK path properly 2021-06-01 11:38:38 +02:00
Christian Tietze f00bb4699a ignore libgit-mac directories 2021-06-01 11:38:38 +02:00
Christian Tietze d176b1afaf slim down the mac build script 2021-06-01 11:38:38 +02:00
Christian Tietze 3ebe0d82a8 change to libgit-mac.a fat library requirement 2021-06-01 11:38:38 +02:00
Christian Tietze 8c461732df build fat libgit2 library for mac 2021-06-01 11:38:38 +02:00
Christian Tietze bcccf31665 add xcode_minor_version helper 2021-06-01 11:38:38 +02:00
Manuel Gauto edbd64318c Merge pull request #173 from spekke/support_status_options
Add support for status options
2021-02-05 18:22:49 -05:00
André Stenvall b620e0c08e Extract StatusOptions to a separate file 2020-12-20 21:44:16 +01:00
André Stenvall dc6a307153 Fix hound length warning 2020-12-20 21:44:16 +01:00
André Stenvall ac7f35a976 Add support for status options 2020-12-20 21:44:16 +01:00
Bilal Karim Reffas cbb2207031 Merge pull request #183 from DivineDominion/xcodeconfigs
update xcconfigs to support arm64 (& update other dev dependencies)
2020-12-15 22:43:20 +01:00
Bilal Karim Reffas 712cfc50ea Merge pull request #181 from DivineDominion/libgit2-v1-1-0
Update to libgit2 v1.1.0
2020-12-15 22:42:07 +01:00
Christian Tietze b253e02ac8 update other dev packages 2020-12-03 18:45:32 +01:00
Christian Tietze 3dc0712e24 update xcconfigs to support ARM 2020-12-03 18:45:25 +01:00
Christian Tietze 827ec79117 replace outdated symbol in tests 2020-12-01 08:52:06 +01:00
Christian Tietze 08c382a327 don't treat warnings as errors globally because it overrides libgit2 2020-12-01 08:33:57 +01:00
Christian Tietze f577819044 stop treating warnings as errors in libgit2
Documentation warning about the @deprecated syntax would otherwise
stop compilation. libgit2 is not our responsibility to check.
2020-12-01 08:33:57 +01:00
Christian Tietze 0842b80a3d update code to libgit2 v1.1.0 2020-12-01 08:33:56 +01:00
Christian Tietze 734d25c15b xcode12 2020-11-29 19:32:09 +01:00
Bilal Karim Reffas 84e7f996ae Update README.md 2020-10-09 14:08:15 +02:00
Bilal Karim Reffas ab0f592aed Update README.md 2020-10-09 14:07:28 +02:00
Bilal Karim Reffas ed618c6fbc Merge pull request #176 from belkadan/pointer-to-pointer
Fix misunderstanding of pointer-to-pointer lifetime
2020-10-08 16:46:51 +02:00
Jordan Rose 17a0b7514d Fix misunderstanding of pointer-to-pointer lifetime.
Fixes #175
2020-07-23 13:00:01 -07:00
Bilal Karim Reffas 1e57a9ff00 Update README.md 2020-04-28 21:08:23 +02:00
Bilal Karim Reffas e78fe86a34 Update README.md 2020-04-28 21:02:20 +02:00
Bilal Karim Reffas c8a192f18b Merge pull request #169 from SwiftGit2/feature/swift5.2
Updated to Swift 5.2 & Xcode 11.4
2020-04-28 14:39:45 +02:00
Bilal Reffas e7656b1d88 Change to a device which should be valid 2020-04-28 09:42:02 +02:00
Bilal Reffas 62d0e15491 Update CI Build script to latest device and runtime 2020-04-28 09:06:42 +02:00
Bilal Reffas 5ec4722a20 Updated to Swift 5.2 2020-04-27 22:05:20 +02:00
Matt Diephouse c5cbf4cc17 Merge pull request #158 from pondok-programmer/master
Swift Package Manager support without changing dependency.
2019-07-22 07:36:24 -04:00
PondokiOS (Muhammmad Muizzsuddin) b87b66f11a Change libgit2 to Clibgit2 2019-07-14 11:06:36 +07:00
Matt Diephouse 571cdef3c4 Merge pull request #155 from DivineDominion/fixture-spec
fix running single specs
2019-06-10 17:11:11 -04:00
Christian Tietze cc4833b334 use FixturesSpec as the spec base class 2019-06-10 16:18:13 +02:00
Matt Diephouse 3adf7e4205 Merge pull request #151 from mattrubin/result
Switch to the standard library Result type
2019-04-15 06:12:52 -07:00
Matt Rubin 80f4e60071 Move the Result shims out of the library and into the test target 2019-04-14 19:53:00 -04:00
Matt Rubin cd3735cd71 Fix error handling when aggregating an array of Results
The previous implementation never handled failure properly and would crash when attempting to force-unwrap a nonexistent success value.
2019-04-14 19:45:52 -04:00
Matt Rubin 71e9b51a52 Remove unnecessary failure mapping 2019-04-14 18:36:16 -04:00
Matt Rubin 9becf1cab0 Refactor to reduce Repository's use of Result shims 2019-04-14 18:28:28 -04:00
Matt Rubin 690f6c9370 Refactor to reduce Repository's use of Result shims 2019-04-14 18:20:36 -04:00
Matt Rubin 19e24dd7d8 Replace antitypical/Result with the standard library Result type 2019-04-14 17:42:37 -04:00
Matt Diephouse cb5567d6a5 Merge pull request #150 from mattrubin/commit-iterator-sequence-methods
Default Sequence methods on CommitIterator
2019-04-14 13:18:23 -07:00
Matt Rubin 452979bd64 Delete Sequence methods from CommitIterator
Default implementations are available via standard library extensions on Sequence.
2019-04-12 23:38:42 -04:00
Matt Rubin 3db2f74ac4 Delete unimplemented Sequence methods from CommitIterator
Implementing these methods is not required to conform to the Sequence protocol, and default implementations are available via standard library extensions on Sequence.
2019-04-12 22:57:22 -04:00
Matt Rubin d878fea696 Return Never from notImplemented() to avoid needing dummy return values 2019-04-12 22:27:12 -04:00
Matt Rubin 18c4cd8598 Replace assert(false) with fatalError() 2019-04-12 22:24:32 -04:00
Matt Diephouse 00e23d3930 Merge pull request #149 from mattrubin/equatable-and-hashable
Simplify Equatable and Hashable implementations
2019-04-12 14:02:19 -07:00
Matt Rubin df7bd3c2a3 Synthesize Equatable conformance for Signature 2019-04-12 16:08:18 -04:00
Matt Rubin c452b80da3 Refactor ObjectType's Equatable implementation to be a static method 2019-04-12 15:59:37 -04:00
Matt Rubin e41b2f92a5 Unify the Hashable implementation for all ObjectTypes 2019-04-12 15:58:15 -04:00
Matt Rubin 12f7d8377d Synthesize Equatable and Hashable conformance for Tree.Entry 2019-04-12 15:45:46 -04:00
Matt Rubin e1acee35d6 Refactor OID Equatable conformance to be a static method 2019-04-12 15:41:58 -04:00
Matt Rubin 743083d19d Refactor Equatable implementations on ReferenceType and PointerType 2019-04-12 15:38:20 -04:00
Matt Rubin 778596b71a Unify the Hashable implementation for all PointerTypes 2019-04-12 15:21:33 -04:00
Matt Rubin 00014ab96f Unify the Hashable implementation for all ReferenceTypes 2019-04-12 15:15:20 -04:00
Matt Rubin fb6020ad08 Use default == implementation for git_otype 2019-04-12 15:08:10 -04:00
Matt Rubin d7699324a0 Synthesize Equatable and Hashable conformance for Remote 2019-04-12 14:59:30 -04:00
Matt Rubin dcf36660aa Merge pull request #148 from mattrubin/lint
SwiftLint fixes and updates
2019-04-12 14:50:56 -04:00
Matt Rubin 82e873eac8 Configure Hound to use the project's SwiftLint config file
http://help.houndci.com/configuration/swiftlint
2019-04-12 13:58:30 -04:00
Matt Rubin 3a38e20b0c [Lint] Remove redundant type annotation 2019-04-12 13:35:38 -04:00
Matt Rubin dcbbf4cc53 [Lint] Enable various new SwiftLint rules 2019-04-12 13:12:42 -04:00
Matt Rubin 619c2bd165 [Lint] Temporarily disable two default warnings 2019-04-12 12:29:39 -04:00
Matt Rubin 45be21756c [Lint] Disable cyclomatic_complexity warnings in RepositorySpec 2019-04-12 12:05:58 -04:00
Matt Rubin 0a1a5d4174 [Lint] Clean up indentation 2019-04-12 11:51:42 -04:00
Matt Rubin 31a755dd49 [Lint] Arguments should be either all on the same line, or one per line 2019-04-12 11:46:21 -04:00
Matt Rubin 9f3f9034ee [Lint] Enforce consistent modifier order 2019-04-12 11:45:52 -04:00
Matt Rubin ce2443bb3b [Lint] Use a case-less enum for a type used only to host static members 2019-04-12 11:45:09 -04:00
Matt Rubin 6c27045ee8 [Lint] Align function parameters when wrapped over multiple lines 2019-04-12 11:43:32 -04:00
Matt Rubin 0c9fbe19ee [Lint] Remove unnecessary nested typealiases 2019-04-12 11:40:34 -04:00
Matt Rubin 9d2b5e5b87 [Lint] Wrap long lines, ignoring function declarations 2019-04-12 11:39:13 -04:00
Matt Rubin cedeccf6f7 [Lint] Remove trailing whitespace on empty lines 2019-04-12 11:37:50 -04:00
Matt Diephouse 17ff9cf4f5 Merge pull request #146 from mattrubin/swift-5
Swift 5 and Xcode 10.2
2019-04-12 05:37:35 -07:00
Matt Diephouse cdfacb944b Merge pull request #145 from mattrubin/swift-4.2
Swift 4.2 and Xcode 10.1
2019-04-12 05:19:39 -07:00
Matt Rubin cd9930cc1e Configure Travis CI to build with Xcode 10.2 2019-04-12 00:37:59 -04:00
Matt Rubin 56b3907ecf Upgrade xcconfigs 2019-04-12 00:31:09 -04:00
Matt Rubin 53438583ca Migrate all targets to Swift 5 2019-04-12 00:22:04 -04:00
Matt Rubin cf24dc9ed6 Migrate to the new method for Hashable conformance 2019-04-11 20:58:09 -04:00
Matt Rubin e16d5c6baa Remove redundant internal access modifier 2019-04-11 20:32:40 -04:00
Matt Rubin a8d0000168 Update project localization settings as recommended by Xcode 10.2 2019-04-11 20:21:04 -04:00
Matt Rubin 7a7d9280ef Configure Travis CI to build with Xcode 10.1 2019-04-11 20:20:50 -04:00
Matt Rubin ef9a46c86b Upgrade xcconfigs to include Xcode 10.1's recommended build settings 2019-04-11 19:56:04 -04:00
Matt Rubin 310e7a4167 Remove the migrator-added helper function from the file permissions test 2019-04-11 19:50:15 -04:00
Matt Rubin e65206c00c Migrate all targets to Swift 4.2 2019-04-11 19:42:48 -04:00
Matt Rubin f811db8047 Bump the macOS tests deployment target to match the Nimble dependency 2019-04-11 19:33:56 -04:00
Matt Rubin 8087272bc2 Upgrade ZipArchive to the latest version 2019-04-11 19:22:53 -04:00
Matt Rubin 74fe90393f Upgrade Quick and Nimble to the latest versions 2019-04-11 19:16:51 -04:00
Matt Rubin 0cb2f8acc5 Upgrade Result to the latest version 2019-04-11 19:14:04 -04:00
Matt Diephouse 57cada1356 Merge pull request #139 from tiennou/update-dependencies
Update dependencies
2018-10-27 13:19:33 -04:00
Etienne Samson 6d7cde7fe7 Update libgit2 to 0.27.7 2018-10-27 03:34:54 +02:00
Etienne Samson 08d03fac7c Update libssh2 to 1.8.0 2018-10-27 03:04:23 +02:00
Etienne Samson db5c22b3a7 Update OpenSSL to 1.0.2p 2018-10-27 03:04:14 +02:00
Matt Diephouse b29e18833d Merge pull request #136 from DivineDominion/repo-isvalid
add Repository.isValid
2018-09-28 08:56:20 -04:00
Christian Tietze 455ac1143f add specs for Repository.isValid 2018-09-26 08:43:09 +02:00
Christian Tietze c5017fc6c9 add Repository.isValid, untested 😱 2018-09-26 07:41:38 +02:00
Matt Diephouse 4111097604 Merge pull request #128 from Maaimusic/git-commit
Git commit
2018-05-04 13:37:40 -04:00
Yifei Teng f152ad76b7 free parentGitCommits 2018-05-04 12:10:57 -05:00
Yifei Teng 4c7aa2a276 do not expose libgit2 objects on the public API 2018-05-02 11:33:34 -05:00
Yifei Teng e6db3c0896 unsafeSignature -> makeUnsafeSignature() 2018-05-02 11:31:49 -05:00
Yifei Teng 84d4ae1e33 cleanup and persist index to disk during add() so that commit() can pick up the new index 2018-05-02 11:28:07 -05:00
Yifei Teng 3d6094b741 add test for commit 2018-05-02 11:28:07 -05:00
Yifei Teng 026548be12 correctly determine timezone offset 2018-05-02 11:28:07 -05:00
Yifei Teng 3db2d73e6e be more clear with naming and additional guard 2018-05-02 11:28:07 -05:00
Yifei Teng f229778abb tabbing 2018-05-02 11:28:07 -05:00
Yifei Teng b193c80dc0 implement git commit 2018-05-02 11:28:07 -05:00
Matt Diephouse 25f3ecc4e6 Merge pull request #127 from Maaimusic/git-add
Git Add
2018-05-02 08:23:49 -04:00
Yifei Teng 81d2fb210a make unsafe functions internal 2018-05-01 13:00:12 -05:00
Yifei Teng b6e94b291c add tests for git-add 2018-04-30 19:43:40 -05:00
Yifei Teng f9d7bd3b61 add support for unsafeIndex and git-add 2018-04-30 19:43:35 -05:00
Matt Diephouse 280ab5b473 Merge pull request #126 from Maaimusic/swift-4.1
update to Swift 4
2018-04-30 20:36:50 -04:00
Yifei Teng fb2fa2b5bc fix iOS test failure due to one of the test fixture not being included in the build 2018-04-30 18:07:34 -05:00
Yifei Teng b1d3488d4c update to Swift 4
Travis does not recognize 9.3?

fix swift 4.1 deprecations

fix more swift 4.1 deprecation

use Xcode 9.3 in CI
2018-04-30 17:30:28 -05:00
Matt Diephouse 814b954956 Merge pull request #120 from utahwithak/Issue/119-bad-types
Fix mismatched status types
2018-03-28 08:22:51 -04:00
Carl Wieland 4d76f87912 Fix mismatched status types
Fixes this issue:
https://github.com/SwiftGit2/SwiftGit2/issues/119

Uses the libgit2 values to ensure no future problems arise.
2018-03-26 16:01:05 -04:00
54 changed files with 1111 additions and 664 deletions
+4
View File
@@ -1,3 +1,6 @@
.vscode/
.build/
# Xcode
#
build/
@@ -20,6 +23,7 @@ DerivedData
*.idea*
External/libgit2*.a
External/libgit2-mac
External/ios-openssl
External/libgit2-ios
External/libssh2-ios
+2 -3
View File
@@ -10,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
@@ -22,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
+4
View File
@@ -0,0 +1,4 @@
# Configuration for Hound (https://houndci.com)
swiftlint:
config_file: .swiftlint.yml
+46
View File
@@ -3,28 +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
View File
@@ -1,6 +1,7 @@
language: objective-c
osx_image: xcode9.2
os: osx
osx_image: xcode11.4
sudo: false # Enable container-based builds
-1
View File
@@ -1 +0,0 @@
github "antitypical/Result" ~> 3.0
+4 -4
View File
@@ -1,4 +1,4 @@
github "jspahrsummers/xcconfigs" >= 0.10
github "Quick/Quick" ~> 1.0
github "Quick/Nimble" ~> 7.0
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 -5
View File
@@ -1,5 +1,4 @@
github "Quick/Nimble" "v7.0.3"
github "Quick/Quick" "v1.2.0"
github "ZipArchive/ZipArchive" "v1.8.1"
github "antitypical/Result" "3.2.4"
github "jspahrsummers/xcconfigs" "0.10"
github "Quick/Nimble" "v12.3.0"
github "Quick/Quick" "v7.3.0"
github "ZipArchive/ZipArchive" "2.5.5"
github "jspahrsummers/xcconfigs" "1.1"
+1 -1
View File
@@ -1 +1 @@
/usr/local/opt/openssl/lib/libcrypto.a
/opt/homebrew/opt/openssl/lib/libcrypto.a
+1 -1
View File
@@ -1 +1 @@
/usr/local/opt/openssl/lib/libssl.a
/opt/homebrew/opt/openssl/lib/libssl.a
+22 -11
View File
@@ -2,24 +2,31 @@
[![Build Status](https://travis-ci.org/SwiftGit2/SwiftGit2.svg)](https://travis-ci.org/SwiftGit2/SwiftGit2)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage)
[![GitHub release](https://img.shields.io/github/release/SwiftGit2/SwiftGit2.svg)](https://github.com/SwiftGit2/SwiftGit2/releases)
![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg)
![Swift 5.3.x](https://img.shields.io/badge/Swift-5.3.x-orange.svg)
Swift bindings to [libgit2](https://github.com/libgit2/libgit2).
```swift
let URL: NSURL = ...
let repo = Repository.at(URL)
if let repo = repo.value {
let latestCommit: Result<Commit, NSError> = repo
let URL: URL = ...
let result = Repository.at(URL)
switch result {
case let .success(repo):
let latestCommit = repo
.HEAD()
.flatMap { repo.commit($0.oid) }
if let commit = latestCommit.value {
.flatMap {
repo.commit($0.oid)
}
switch latestCommit {
case let .success(commit):
print("Latest Commit: \(commit.message) by \(commit.author.name)")
} else {
print("Could not get commit: \(latestCommit.error)")
case let .failure(error):
print("Could not get commit: \(error)")
}
} else {
println("Could not open repository: \(repo.error)")
case let .failure(error):
print("Could not open repository: \(error)")
}
```
@@ -44,6 +51,10 @@ To build SwiftGit2, you'll need the following tools installed locally:
* automake
* pkg-config
```
brew install cmake libssh2 libtool autoconf automake pkg-config
```
## Adding SwiftGit2 to your Project
The easiest way to add SwiftGit2 to your project is to use [Carthage](https://github.com/Carthage/Carthage). Simply add `github "SwiftGit2/SwiftGit2"` to your `Cartfile` and run `carthage update`.
+125 -132
View File
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {
/* Begin PBXAggregateTarget section */
@@ -26,6 +26,10 @@
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 */; };
@@ -50,13 +54,13 @@
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 */; };
@@ -80,7 +84,8 @@
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 */; };
DA5914761A94579000AED74C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5914751A94579000AED74C /* Errors.swift */; };
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; };
@@ -122,22 +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; };
@@ -176,21 +191,20 @@
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; };
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>"; };
@@ -202,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;
};
@@ -222,7 +236,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BEE591C71ADF470500534F14 /* Result.framework in Frameworks */,
BEB31FA01A0E595600F525B9 /* libz.dylib in Frameworks */,
BEB31F9E1A0E595100F525B9 /* libiconv.dylib in Frameworks */,
);
@@ -242,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 */,
);
@@ -255,7 +276,6 @@
621E66D51C72966000A0F352 /* iOS */ = {
isa = PBXGroup;
children = (
621E66D81C72989900A0F352 /* Result.framework */,
621E66FD1C72A5FF00A0F352 /* libiconv.tbd */,
621E66FF1C72A60B00A0F352 /* libz.tbd */,
);
@@ -277,12 +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;
@@ -292,7 +314,6 @@
children = (
BEB31F231A0D6F7A00F525B9 /* SwiftGit2.framework */,
BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */,
BEB31F8F1A0E563900F525B9 /* libgit2.a */,
621E66B41C72958800A0F352 /* SwiftGit2.framework */,
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */,
621E66E11C729CE500A0F352 /* libgit2.a */,
@@ -319,6 +340,7 @@
BECB5F691A56F19900999413 /* References.swift */,
BECB5F6D1A57284700999413 /* Remotes.swift */,
25499A996CA7BD416620A397 /* CommitIterator.swift */,
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */,
);
path = SwiftGit2;
sourceTree = "<group>";
@@ -342,6 +364,7 @@
BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */,
BECB5F6F1A57286200999413 /* RemotesSpec.swift */,
BE14AA581A1996B70015B439 /* FixturesSpec.swift */,
C98A2B9F2263E017007A4E3A /* ResultShims.swift */,
BEB31F331A0D6F7A00F525B9 /* Supporting Files */,
);
path = SwiftGit2Tests;
@@ -363,7 +386,7 @@
children = (
BEB31F421A0D75EE00F525B9 /* Base */,
BEB31F4D1A0D75EE00F525B9 /* iOS */,
BEB31F521A0D75EE00F525B9 /* Mac OS X */,
BEB31F521A0D75EE00F525B9 /* macOS */,
BEB31F581A0D75EE00F525B9 /* README.md */,
);
name = Configuration;
@@ -412,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 */ = {
@@ -462,6 +485,7 @@
621E669F1C72958800A0F352 /* Sources */,
621E66AA1C72958800A0F352 /* Frameworks */,
621E66AE1C72958800A0F352 /* Headers */,
50A682E52ADBF65F00FDB557 /* Embed Frameworks */,
);
buildRules = (
);
@@ -542,6 +566,7 @@
isa = PBXNativeTarget;
buildConfigurationList = BEB31F391A0D6F7A00F525B9 /* Build configuration list for PBXNativeTarget "SwiftGit2-OSX" */;
buildPhases = (
50A682DD2AD9959500FDB557 /* Update libgit2 */,
BEB31F1E1A0D6F7A00F525B9 /* Sources */,
BEB31F1F1A0D6F7A00F525B9 /* Frameworks */,
BEB31F201A0D6F7A00F525B9 /* Headers */,
@@ -549,7 +574,6 @@
buildRules = (
);
dependencies = (
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */,
);
name = "SwiftGit2-OSX";
productName = "SwiftGit2-OSX";
@@ -574,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 */
@@ -596,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;
@@ -624,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 */;
@@ -638,7 +645,6 @@
BEB31F2D1A0D6F7A00F525B9 /* SwiftGit2-OSXTests */,
621E66611C72958800A0F352 /* SwiftGit2-iOS */,
621E66B61C72958D00A0F352 /* SwiftGit2-iOSTests */,
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */,
621E66DC1C729CE500A0F352 /* libgit2-iOS */,
621E66E71C729EB800A0F352 /* OpenSSL-iOS */,
621E66ED1C729EBB00A0F352 /* libssh2-iOS */,
@@ -653,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 */,
);
@@ -672,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 = (
);
@@ -696,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 = (
);
@@ -709,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 = (
);
@@ -736,7 +755,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --lenient\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 */
@@ -757,6 +776,7 @@
621E66A71C72958800A0F352 /* Pointers.swift in Sources */,
621E66A81C72958800A0F352 /* Errors.swift in Sources */,
621E66A91C72958800A0F352 /* SwiftGit2.m in Sources */,
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */,
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -772,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;
};
@@ -791,6 +812,7 @@
BE7A753F1A4A2BCC002DA7E3 /* Pointers.swift in Sources */,
DA5914761A94579000AED74C /* Errors.swift in Sources */,
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */,
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */,
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -806,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;
};
@@ -837,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 */
@@ -849,6 +867,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
@@ -861,9 +880,6 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -878,6 +894,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
@@ -890,9 +907,6 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -927,6 +941,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Debug;
@@ -935,6 +950,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Release;
@@ -975,13 +991,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F451A0D75EE00F525B9 /* Debug.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 3.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -990,19 +1007,20 @@
baseConfigurationReference = BEB31F471A0D75EE00F525B9 /* Release.xcconfig */;
buildSettings = {
ENABLE_NS_ASSERTIONS = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 3.0;
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 = (
"$(SRCROOT)/External/libgit2/include",
@@ -1010,14 +1028,14 @@
);
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",
@@ -1025,13 +1043,13 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
SWIFT_VERSION = 4.0;
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 = (
"$(SRCROOT)/External/libgit2/include",
@@ -1039,14 +1057,14 @@
);
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",
@@ -1054,13 +1072,13 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
SWIFT_VERSION = 4.0;
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)";
@@ -1070,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)";
@@ -1078,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 = {
@@ -1183,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 = (
@@ -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"
-3
View File
@@ -4,9 +4,6 @@
<FileRef
location = "group:SwiftGit2.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Result/Result.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Quick/Quick.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>
+1 -1
View File
@@ -6,7 +6,7 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import libgit2
import Clibgit2
/// The flags defining how a checkout should be performed.
/// More detail is available in the libgit2 documentation for `git_checkout_strategy_t`.
+4 -76
View File
@@ -3,8 +3,8 @@
// Copyright (c) 2017 GitHub, Inc. All rights reserved.
//
import Result
import libgit2
import Foundation
import Clibgit2
public class CommitIterator: IteratorProtocol, Sequence {
public typealias Iterator = CommitIterator
@@ -59,84 +59,12 @@ public class CommitIterator: IteratorProtocol, Sequence {
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 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
}
}
public func makeIterator() -> CommitIterator {
return self
}
public private(set) var underestimatedCount: Int = 0
public func map<T>(_ transform: (Result<Commit, NSError>) throws -> T) rethrows -> [T] {
var new: [T] = []
for item in self {
new += [try transform(item)]
}
return new
}
public func filter(_ isIncluded: (Result<Commit, NSError>) throws -> Bool) rethrows -> [Result<Commit, NSError>] {
var new: [Result<Commit, NSError>] = []
for item in self {
if try isIncluded(item) {
new += [item]
}
}
return new
}
public func forEach(_ body: (Result<Commit, NSError>) throws -> Void) rethrows {
for item in self {
try body(item)
}
}
private func notImplemented(functionName: Any) {
assert(false, "CommitIterator does not implement \(functionName)")
}
private init(repo: Repository) {
self.repo = repo
}
public func dropFirst(_ num: Int) -> AnySequence<Iterator.Element> {
notImplemented(functionName: self.dropFirst)
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func dropLast(_ num: Int) -> AnySequence<Iterator.Element> {
notImplemented(functionName: self.dropLast)
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func drop(while predicate: (Result<Commit, NSError>) throws -> Bool) rethrows -> AnySequence<Iterator.Element> {
notImplemented(functionName: self.drop)
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func prefix(_ maxLength: Int) -> AnySequence<Iterator.Element> {
notImplemented(functionName: "prefix(_ maxLength:")
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func prefix(while predicate: (Result<Commit, NSError>) throws -> Bool) rethrows -> AnySequence<Iterator.Element> {
notImplemented(functionName: "prefix(with predicate:")
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func suffix(_ maxLength: Int) -> AnySequence<Iterator.Element> {
notImplemented(functionName: self.suffix)
return AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }
}
public func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator isSeparator: (Result<Commit, NSError>) throws -> Bool) rethrows -> [AnySequence<Iterator.Element>] {
notImplemented(functionName: self.split)
return [AnySequence<Iterator.Element> { return CommitIterator(repo: self.repo) }]
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
// Copyright © 2016 GitHub, Inc. All rights reserved.
//
import libgit2
import Clibgit2
private class Wrapper<T> {
let value: T
+19 -19
View File
@@ -5,8 +5,8 @@
// Created by Jake Van Alstyne on 8/20/17.
// Copyright © 2017 GitHub, Inc. All rights reserved.
//
import Foundation
import libgit2
import Clibgit2
public struct StatusEntry {
public var status: Diff.Status
@@ -32,7 +32,7 @@ public struct Diff {
public var deltas = [Delta]()
public struct Delta {
public static let type = GIT_OBJ_REF_DELTA
public static let type = GIT_OBJECT_REF_DELTA
public var status: Status
public var flags: Flags
@@ -50,7 +50,7 @@ public struct Diff {
public struct File {
public var oid: OID
public var path: String
public var size: Int64
public var size: UInt64
public var flags: Flags
public init(_ diffFile: git_diff_file) {
@@ -70,20 +70,20 @@ public struct Diff {
}
public let rawValue: UInt32
public static let current = Status(rawValue: 0)
public static let indexNew = Status(rawValue: 1 << 0)
public static let indexModified = Status(rawValue: 1 << 1)
public static let indexDeleted = Status(rawValue: 1 << 2)
public static let indexRenamed = Status(rawValue: 1 << 3)
public static let indexTypeChange = Status(rawValue: 1 << 4)
public static let workTreeNew = Status(rawValue: 1 << 5)
public static let workTreeModified = Status(rawValue: 1 << 6)
public static let workTreeDeleted = Status(rawValue: 1 << 7)
public static let workTreeTypeChange = Status(rawValue: 1 << 8)
public static let workTreeRenamed = Status(rawValue: 1 << 9)
public static let workTreeUnreadable = Status(rawValue: 1 << 10)
public static let ignored = Status(rawValue: 1 << 11)
public static let conflicted = Status(rawValue: 1 << 12)
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 {
@@ -94,7 +94,7 @@ public struct Diff {
}
public let rawValue: UInt32
public static let binary = Flags(rawValue: 0)
public static let binary = Flags([])
public static let notBinary = Flags(rawValue: 1 << 0)
public static let validId = Flags(rawValue: 1 << 1)
public static let exists = Flags(rawValue: 1 << 2)
+3 -3
View File
@@ -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
+1 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
}
}
+24 -29
View File
@@ -6,19 +6,26 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import libgit2
import Clibgit2
/// A pointer to a git object.
public protocol PointerType: Hashable {
/// The OID of the referenced object.
var oid: OID { get }
/// The libgit2 `git_otype` of the referenced object.
var type: git_otype { get }
/// The libgit2 `git_object_t` of the referenced object.
var type: git_object_t { get }
}
public 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.
@@ -41,29 +48,29 @@ public enum Pointer: PointerType {
}
}
public var type: git_otype {
public var type: git_object_t {
switch self {
case .commit:
return GIT_OBJ_COMMIT
return GIT_OBJECT_COMMIT
case .tree:
return GIT_OBJ_TREE
return GIT_OBJECT_TREE
case .blob:
return GIT_OBJ_BLOB
return GIT_OBJECT_BLOB
case .tag:
return GIT_OBJ_TAG
return GIT_OBJECT_TAG
}
}
/// Create an instance with an OID and a libgit2 `git_otype`.
init?(oid: OID, type: git_otype) {
/// Create an instance with an OID and a libgit2 `git_object_t`.
init?(oid: OID, type: git_object_t) {
switch type {
case GIT_OBJ_COMMIT:
case GIT_OBJECT_COMMIT:
self = .commit(oid)
case GIT_OBJ_TREE:
case GIT_OBJECT_TREE:
self = .tree(oid)
case GIT_OBJ_BLOB:
case GIT_OBJECT_BLOB:
self = .blob(oid)
case GIT_OBJ_TAG:
case GIT_OBJECT_TAG:
self = .tag(oid)
default:
return nil
@@ -71,12 +78,6 @@ public enum Pointer: PointerType {
}
}
extension Pointer: Hashable {
public var hashValue: Int {
return oid.hashValue
}
}
extension Pointer: CustomStringConvertible {
public var description: String {
switch self {
@@ -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
}
}
+17 -28
View File
@@ -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,14 +122,8 @@ 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)
@@ -147,7 +142,7 @@ public enum TagReference: ReferenceType {
/// 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.
@@ -183,7 +178,7 @@ 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!))
} else {
@@ -192,9 +187,3 @@ public enum TagReference: ReferenceType {
git_object_free(pointer)
}
}
extension TagReference: Hashable {
public var hashValue: Int {
return longName.hashValue ^ oid.hashValue
}
}
+2 -12
View File
@@ -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
}
+261 -115
View File
@@ -7,8 +7,7 @@
//
import Foundation
import Result
import libgit2
import Clibgit2
public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
@@ -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,7 +94,7 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
}
/// A git repository.
final public class Repository {
public final class Repository {
// MARK: - Creating Repositories
@@ -104,7 +103,7 @@ final public class Repository {
/// URL - The URL of the repository.
///
/// Returns a `Result` with a `Repository` or an error.
class public func create(at url: URL) -> Result<Repository, NSError> {
public class func create(at url: URL) -> Result<Repository, NSError> {
var pointer: OpaquePointer? = nil
let result = url.withUnsafeFileSystemRepresentation {
git_repository_init(&pointer, $0, 0)
@@ -123,7 +122,7 @@ final public class Repository {
/// 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)
@@ -148,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,
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
@@ -206,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
@@ -221,11 +221,11 @@ 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_otype, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
private func withGitObjects<T>(_ oids: [OID], type: git_object_t, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
var pointers = [OpaquePointer]()
defer {
for pointer in pointers {
@@ -254,7 +254,7 @@ final public class Repository {
///
/// Returns a `Blob`, `Commit`, `Tag`, or `Tree` if one exists, or an error.
public func object(_ oid: OID) -> Result<ObjectType, NSError> {
return withGitObject(oid, type: GIT_OBJ_ANY) { object in
return withGitObject(oid, type: GIT_OBJECT_ANY) { object in
let type = git_object_type(object)
if type == Blob.type {
return Result.success(Blob(object))
@@ -270,7 +270,7 @@ 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)
@@ -283,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.
@@ -292,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.
@@ -301,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.
@@ -310,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.
@@ -350,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"))
}
@@ -359,13 +359,9 @@ 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 Result.success(remotes.map { $0.value! })
return remotes.aggregateResult()
}
private func remoteLookup<A>(named name: String, _ callback: (Result<OpaquePointer, NSError>) -> A) -> A {
@@ -416,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"))
}
@@ -429,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")
@@ -583,11 +575,128 @@ final public class Repository {
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> {
typealias Delta = Diff.Delta
guard !commit.parents.isEmpty else {
// Initial commit in a repository
return self.diff(from: nil, to: commit.oid)
@@ -596,20 +705,22 @@ final public class Repository {
var mergeDiff: OpaquePointer? = nil
defer { git_object_free(mergeDiff) }
for parent in commit.parents {
let error = self.diff(from: parent.oid, to: commit.oid) { (diff: Result<OpaquePointer, NSError>) -> NSError? in
guard diff.error == nil else {
return diff.error!
}
let error = self.diff(from: parent.oid, to: commit.oid) {
switch $0 {
case .failure(let error):
return error
if mergeDiff == nil {
mergeDiff = diff.value!
} else {
let mergeResult = git_diff_merge(mergeDiff, diff.value)
guard mergeResult == GIT_OK.rawValue else {
return NSError(gitError: mergeResult, pointOfFailure: "git_diff_merge")
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
}
return nil
}
if error != nil {
@@ -626,35 +737,35 @@ final public class Repository {
var oldTree: OpaquePointer? = nil
defer { git_object_free(oldTree) }
if let oid = oldCommitOid {
let result = unsafeTreeForCommitId(oid)
guard result.error == nil else {
return transform(Result.failure(result.error!))
switch unsafeTreeForCommitId(oid) {
case .failure(let error):
return transform(.failure(error))
case .success(let value):
oldTree = value
}
oldTree = result.value
}
var newTree: OpaquePointer? = nil
defer { git_object_free(newTree) }
if let oid = newCommitOid {
let result = unsafeTreeForCommitId(oid)
guard result.error == nil else {
return transform(Result.failure(result.error!))
switch unsafeTreeForCommitId(oid) {
case .failure(let error):
return transform(.failure(error))
case .success(let value):
newTree = value
}
newTree = result.value
}
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
oldTree,
newTree,
nil)
self.pointer,
oldTree,
newTree,
nil)
guard diffResult == GIT_OK.rawValue else {
return transform(.failure(NSError(gitError: diffResult,
pointOfFailure: "git_diff_tree_to_tree")))
pointOfFailure: "git_diff_tree_to_tree")))
}
return transform(Result<OpaquePointer, NSError>.success(diff!))
@@ -665,51 +776,53 @@ final public class Repository {
assert(oldCommitOid != nil || newCommitOid != nil, "It is an error to pass nil for both the oldOid and newOid")
var oldTree: Tree? = nil
if oldCommitOid != nil {
let result = safeTreeForCommitId(oldCommitOid!)
guard result.error == nil else {
return Result<Diff, NSError>.failure(result.error!)
if let oldCommitOid = oldCommitOid {
switch safeTreeForCommitId(oldCommitOid) {
case .failure(let error):
return .failure(error)
case .success(let value):
oldTree = value
}
oldTree = result.value
}
var newTree: Tree? = nil
if newCommitOid != nil {
let result = self.safeTreeForCommitId(newCommitOid!)
guard result.error == nil else {
return Result<Diff, NSError>.failure(result.error!)
if let newCommitOid = newCommitOid {
switch safeTreeForCommitId(newCommitOid) {
case .failure(let error):
return .failure(error)
case .success(let value):
newTree = value
}
newTree = result.value!
}
if oldTree != nil && newTree != nil {
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJ_TREE) { objects in
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJECT_TREE) { objects in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
objects[0],
objects[1],
nil)
self.pointer,
objects[0],
objects[1],
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
}
} else if let tree = oldTree {
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
tree,
nil,
nil)
self.pointer,
tree,
nil,
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
})
} else if let tree = newTree {
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
nil,
tree,
nil)
self.pointer,
nil,
tree,
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
})
}
@@ -720,7 +833,7 @@ final public class Repository {
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"))
pointOfFailure: "git_diff_tree_to_tree"))
}
let diffObj = Diff(diff!)
@@ -729,8 +842,7 @@ final public class Repository {
}
private func processDiffDeltas(_ diffResult: OpaquePointer) -> Result<[Diff.Delta], NSError> {
typealias Delta = Diff.Delta
var returnDict = [Delta]()
var returnDict = [Diff.Delta]()
let count = git_diff_num_deltas(diffResult)
@@ -746,13 +858,9 @@ final public class Repository {
}
private func safeTreeForCommitId(_ oid: OID) -> Result<Tree, NSError> {
return withGitObject(oid, type: GIT_OBJ_COMMIT) { commit in
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { commit in
let treeId = git_commit_tree_id(commit)
let tree = self.tree(OID(treeId!.pointee))
guard tree.error == nil else {
return .failure(tree.error!)
}
return tree
return tree(OID(treeId!.pointee))
}
}
@@ -760,14 +868,14 @@ final public class Repository {
private func unsafeTreeForCommitId(_ oid: OID) -> Result<OpaquePointer, NSError> {
var commit: OpaquePointer? = nil
var oid = oid.oid
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJ_COMMIT)
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJECT_COMMIT)
guard commitResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: commitResult, pointOfFailure: "git_object_lookup"))
}
var tree: OpaquePointer? = nil
let treeId = git_commit_tree_id(commit)
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJ_TREE)
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJECT_TREE)
git_object_free(commit)
@@ -780,7 +888,7 @@ final public class Repository {
// MARK: - Status
public func status() -> Result<[StatusEntry], NSError> {
public func status(options: StatusOptions = [.includeUntracked]) -> Result<[StatusEntry], NSError> {
var returnArray = [StatusEntry]()
// Do this because GIT_STATUS_OPTIONS_INIT is unavailable in swift
@@ -789,12 +897,13 @@ final public class Repository {
guard optionsResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options"))
}
var options = pointer.move()
pointer.deallocate(capacity: 1)
var listOptions = pointer.move()
listOptions.flags = options.rawValue
pointer.deallocate()
var unsafeStatus: OpaquePointer? = nil
defer { git_status_list_free(unsafeStatus) }
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &options)
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &listOptions)
guard statusResult == GIT_OK.rawValue, let unwrapStatusResult = unsafeStatus else {
return .failure(NSError(gitError: statusResult, pointOfFailure: "git_status_list_new"))
}
@@ -813,4 +922,41 @@ final public class Repository {
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)
}
}
+63
View File
@@ -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
)
}
+1 -2
View File
@@ -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
+1 -1
View File
@@ -9,7 +9,7 @@
import Quick
class FixturesSpec: QuickSpec {
override func spec() {
override class func spec() {
beforeSuite {
Fixtures.sharedInstance.setUp()
}
+1 -2
View File
@@ -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())
+9 -10
View File
@@ -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,7 +169,7 @@ 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)
@@ -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
@@ -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
+5 -6
View File
@@ -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
+3 -4
View File
@@ -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
+143 -12
View File
@@ -6,13 +6,14 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Result
import SwiftGit2
import Nimble
import Quick
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,7 +24,47 @@ class RepositorySpec: QuickSpec {
let url = URL(fileURLWithPath: "blah")
let result = Repository.at(url)
expect(result.error?.domain) == libGit2ErrorDomain
expect(result.error?.localizedDescription).to(match("Failed to resolve path"))
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())
}
}
@@ -111,9 +152,9 @@ class RepositorySpec: QuickSpec {
let remoteRepoURL = URL(string: privateRepo)
let localURL = self.temporaryURL(forPurpose: "private-remote-clone")
let credentials = Credentials.sshMemory(username: gitUsername,
publicKey: publicKey,
privateKey: privateKey,
passphrase: passphrase)
publicKey: publicKey,
privateKey: privateKey,
passphrase: passphrase)
let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL, credentials: credentials)
@@ -646,10 +687,85 @@ class RepositorySpec: QuickSpec {
}
}
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())
@@ -660,7 +776,7 @@ class RepositorySpec: QuickSpec {
}
it("Should accurately report status for repositories with status") {
let expectedCount = 5
let expectedCount = 6
let expectedNewFilePaths = [
"stage-file-1",
"stage-file-2",
@@ -675,6 +791,9 @@ class RepositorySpec: QuickSpec {
"stage-file-4",
"stage-file-5",
]
let expectedUntrackedFiles = [
"unstaged-file",
]
let repoWithStatus = Fixtures.sharedInstance.repository(named: "repository-with-status")
let branchWithStatus = repoWithStatus.localBranch(named: "master").value!
@@ -684,16 +803,28 @@ class RepositorySpec: QuickSpec {
var newFilePaths: [String] = []
for status in statuses {
newFilePaths.append((status.headToIndex?.newFile?.path)!)
if let path = status.headToIndex?.newFile?.path {
newFilePaths.append(path)
}
}
var oldFilePaths: [String] = []
for status in statuses {
oldFilePaths.append((status.headToIndex?.oldFile?.path)!)
if let path = status.headToIndex?.oldFile?.path {
oldFilePaths.append(path)
}
}
var newUntrackedFilePaths: [String] = []
for status in statuses {
if let path = status.indexToWorkDir?.newFile?.path {
newUntrackedFilePaths.append(path)
}
}
expect(statuses.count).to(equal(expectedCount))
expect(newFilePaths).to(equal(expectedNewFilePaths))
expect(oldFilePaths).to(equal(expectedOldFilePaths))
expect(newUntrackedFilePaths).to(equal(expectedUntrackedFiles))
}
}
@@ -849,7 +980,7 @@ class RepositorySpec: QuickSpec {
}
}
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)
+16
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
module libgit2 {
module Clibgit2 {
umbrella header "git2.h"
export *
+1 -1
View File
@@ -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
View File
@@ -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..."
+30 -22
View File
@@ -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
View File
@@ -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."
+66 -4
View File
@@ -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
+2 -2
View File
@@ -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."
}
+18 -2
View File
@@ -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 }'
}