254 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
Jake Van Alstyne d35dac654c Merge pull request #102 from jakeva/develop
Implement git status and diffs
2018-02-09 15:53:45 -07:00
Jake Van Alstyne 🎩 97ee009ac5 Defer release status list 2018-02-09 14:29:51 -07:00
Jake Van Alstyne 🎩 6e5703dab7 another deferred release 2018-02-08 14:09:38 -07:00
Jake Van Alstyne 🎩 1f23feb0c5 move one more defer 2018-02-07 18:22:05 -07:00
Jake Van Alstyne 🎩 118ba43fce Move deferred memory releases to avoid leaks in case of an error 2018-02-07 18:16:58 -07:00
Jake Van Alstyne 🎩 6f59ce5cf3 Factor out common diff processing code for simplicity 2018-02-02 11:45:21 -07:00
Matt Diephouse 11ac4767bb Merge pull request #115 from SwiftGit2/archiving
Don't set custom permissions or ownership for deployment
2018-01-25 16:43:41 -05:00
Matt Diephouse c5f3b2ccfe Don't set custom permissions or ownership for deployment 2018-01-25 14:32:22 -05:00
Jake Van Alstyne 🎩 0dab27d07b Remove the necessity of the caller of diff to clean up memory and address other PR comments 2018-01-11 19:44:29 -07:00
Jake Van Alstyne 🎩 0397b29d24 refactor diff calls to be memory safe
- use existing `withGitObject` method
- introduce extended version that can handle multiple git objects for the purpose of handling multiple parents
2018-01-08 20:38:32 -07:00
Jake Van Alstyne 🎩 1a369b7e9e Refactor method for calculating diffs to read more cleanly and be safer with memory. 2018-01-05 17:09:01 -07:00
Jake Van Alstyne 🎩 87af7fcb32 Address lint in method calls 2018-01-05 17:08:12 -07:00
Matt Diephouse 98fcae405e Merge pull request #113 from SwiftGit2/fix-header-interface-generation
Fix header interface generation
2017-12-20 06:52:30 -05:00
Matt Diephouse 28a1757dbe Fix header interface generation
https://twitter.com/benlangmuir/status/943239006627684352
2017-12-19 16:58:51 -05:00
Jake Van Alstyne 🎩 9a9b7a9be8 More detailed tests 2017-12-17 14:33:01 -07:00
Jake Van Alstyne 🎩 26f1bb7c86 Fix for spec failing because only the diff for the first parent was calculated. 2017-12-17 14:06:24 -07:00
Jake Van Alstyne 🎩 ecb5263f6b fixes to tests that used guanaco 2017-12-16 15:01:06 -07:00
Jake Van Alstyne 🎩 f98664ecb3 Merge branch 'master' into develop
Conflicts:
	SwiftGit2/CommitIterator.swift
	SwiftGit2Tests/RepositorySpec.swift
2017-12-16 14:41:06 -07:00
Matt Diephouse c0c382227e Merge pull request #111 from chriseidhof/remote-fetching
Remote fetching
2017-12-16 12:15:22 -05:00
Chris Eidhof 225f391171 Fetching remotes 2017-12-16 15:06:54 +01:00
Matt Diephouse d7fff2c643 Merge pull request #112 from SwiftGit2/remove-trailing-whitespace
Remove trailing whitespace
2017-12-15 18:05:09 -05:00
Jake Van Alstyne 🎩 d8ee830173 Merge branch 'master' into develop 2017-12-15 13:40:42 -07:00
Matt Diephouse c7bf00201e Remove trailing whitespace 2017-12-15 15:02:34 -05:00
Matt Diephouse 69413a0540 Merge pull request #109 from SwiftGit2/fix-build
Fix build with Xcode 9.2
2017-12-15 14:42:21 -05:00
Matt Diephouse 3f989ab522 Merge pull request #110 from SwiftGit2/building-swiftgit2
Add instructions for building manually
2017-12-15 14:42:09 -05:00
Matt Diephouse 9884657da6 Use Xcode 9.2 on CI 2017-12-14 18:57:21 -05:00
Matt Diephouse afaa96ec57 Add instructions for building manually 2017-12-14 15:13:55 -05:00
Matt Diephouse 09ac23471b Fix build with Xcode 9.2 2017-12-14 15:08:17 -05:00
Jake Van Alstyne 🎩 db0a955e03 clean up various xcode warnings 2017-11-17 16:49:16 -07:00
Jake Van Alstyne 🎩 a9f79a3b80 address some PR comments 2017-11-17 16:22:37 -07:00
Jake Van Alstyne 🎩 e7b6e4509f for some reason the wrong commit of result got used 2017-11-17 16:12:32 -07:00
Jake Van Alstyne 🎩 efe1d6eeeb update for swift 4.0 nuances 2017-11-10 15:21:35 -07:00
Jake Van Alstyne 🎩 6a59e6557e split out diff tests into a separate describe, rename status describe 2017-09-15 19:32:13 -06:00
Jake Van Alstyne 🎩 8bb6e30ff4 refactor the repository diff to rely on flatmaps to propogate errors 2017-09-15 19:26:31 -06:00
Jake Van Alstyne 🎩 d7154e6f40 init a StatusEntry with an initializer that takes in a git_status_entry 2017-09-08 17:19:05 -06:00
Jake Van Alstyne 🎩 5f4043bb0e On second thought, I believe StatusEntry should not be a sub struct of Diff since it has references to two Diff Deltas but itself is not a Diff and not used by anything contained within Diff. It is conceptually different. 2017-09-08 17:13:05 -06:00
Jake Van Alstyne 🎩 3b9beac923 simplify things by extracting difficult to read libgit2 interactions into helper functions and nest the various Diff structs inside a struct named Diff 2017-09-08 17:10:06 -06:00
Jake Van Alstyne 🎩 0d56e1b1ce these evidently need to be explicitly public since they are internal by default 2017-09-01 17:52:22 -06:00
Jake Van Alstyne 🎩 2cff52a3d3 create an initializer for DiffFile 2017-09-01 17:25:59 -06:00
Jake Van Alstyne 🎩 8730bb2d8d refactor how we initialize Status, let the consumer of this library decide what the different statuses returned by libgit2 mean rather than imposing our own assumptions 2017-09-01 17:22:20 -06:00
Jake Van Alstyne 🎩 046d67ed97 use the DiffFlag struct instead of a UInt32 2017-09-01 17:16:25 -06:00
Jake Van Alstyne 🎩 48b804846f refactor how we initialize a DiffDelta using an initializer 2017-09-01 17:14:15 -06:00
Jake Van Alstyne 🎩 bf2bc2ed88 also should check success of git_status_init_options 2017-09-01 16:45:48 -06:00
Jake Van Alstyne 🎩 42619872f8 simpler function name for getting status 2017-09-01 16:43:33 -06:00
Jake Van Alstyne 🎩 99b638131c simpler function name for getting diffs 2017-09-01 16:42:37 -06:00
Jake Van Alstyne 🎩 edb1906231 validate success of git_status_list_new 2017-09-01 16:39:07 -06:00
Jake Van Alstyne 🎩 253cf53d2e no need to have three different private functions doing nearly the same thing, factor them out completely 2017-09-01 16:33:25 -06:00
Jake Van Alstyne 🎩 95c7da4e1b remove 'git' from type names, convert types that should be an optionset 2017-09-01 16:20:00 -06:00
Jake Van Alstyne 🎩 f422571d38 fix whitespace indentation issue 2017-08-22 13:47:55 -06:00
Jake Van Alstyne 🎩 6fc4a0c7bb improve tests, make clear some of the status/diff data is optional, clearer naming 2017-08-22 13:42:06 -06:00
Jake Van Alstyne 🎩 2173a68e93 these properties need to be made explicitly public 2017-08-20 15:55:36 -06:00
Jake Van Alstyne 🎩 b582e1e642 Add diff structs for parsing git_diff_deltas into Swift, more testing 2017-08-20 15:48:17 -06:00
Jake Van Alstyne 🎩 c4388f0a07 stub out getting the status of a commit compared with its parent, including basic testing 2017-08-18 15:36:40 -06:00
Jake Van Alstyne 🎩 82e90d3c75 stub out status testing 2017-08-17 16:48:58 -06:00
Jake Van Alstyne 🎩 1af59416d9 stub out getting repository status 2017-08-17 16:08:44 -06:00
Matt Diephouse c5eb8036d0 Merge pull request #101 from jakeva/add-agent-auth
add ssh agent authentication
2017-08-14 09:09:54 -04:00
Jake Van Alstyne 🎩 31680a50a3 rename it sshAgent 2017-08-10 14:53:35 -06:00
Matt Diephouse 593c4069b5 Merge pull request #98 from jakeva/create-new-repository
Create new repository
2017-08-10 08:35:56 -04:00
Jake Van Alstyne 🎩 f635f50b84 incorporate requested changes 2017-08-09 14:52:57 -06:00
Jake Van Alstyne 🎩 242741a950 add ssh agent authentication 2017-08-09 14:17:56 -06:00
Jake Van Alstyne 5d0255b84c Merge branch 'master' into create-new-repository 2017-08-09 14:01:22 -06:00
Jake Van Alstyne 🎩 7ecfb710d3 rename createAt to be in line with modern swift coding style and add a test 2017-08-09 13:58:55 -06:00
Jake Van Alstyne 🎩 18691cb4e6 update comment regarding createAt method of Repository 2017-08-05 15:37:44 -06:00
Matt Diephouse 06a3b62014 Merge pull request #89 from myste1tainn/master
Add ability to get all commits from a branch
2017-05-04 20:26:18 -04:00
Arnon Keereena a58f849456 Merge develop to master 2017-05-04 22:41:38 +02:00
Arnon Keereena 8d1aaa672f Changing from using if to evaluates returned enum
to switch case syntax instead
2017-05-04 22:41:32 +02:00
Arnon Keereena dfc2614cb2 Merge develop to master 2017-05-04 09:36:33 +02:00
Arnon Keereena 9520fa03a6 Adjust weird indentation 2017-05-04 09:36:02 +02:00
Arnon Keereena c4b7ce3716 Remove branch iterator caching
Add support for sequencing to allow syntax
for commit in repo.commits(in: branch)
2017-05-04 09:33:14 +02:00
Arnon Keereena 8088f8b11f Return error here because something is happening
but not running out of commits
2017-05-04 08:26:31 +02:00
Arnon Keereena 42d92319ef Remove unnecessary function 2017-05-04 08:22:23 +02:00
Arnon Keereena d09d1f49b3 Merge develop to master 2017-05-02 21:35:17 +02:00
Arnon Keereena 46cad0e668 Remove unnecessary property, use the OID as should be 2017-05-02 21:34:57 +02:00
Arnon Keereena 500ae6dc90 Remove unnecessary property, use the OID as should be 2017-05-02 21:27:48 +02:00
Arnon Keereena c7b8ae914f Merge develop to master 2017-05-01 17:20:38 +02:00
Arnon Keereena 4dd24cad97 CommitIterator now not hold branch as reference.
Make private var instead to prevent unexpected state change
from external influence. Uses enum instead of tuple
of stop and error to indicate state of Git command result.
2017-05-01 17:19:05 +02:00
Arnon Keereena 23194dd7a3 Merge develop into master 2017-04-29 08:56:05 +02:00
Arnon Keereena 915b07f4a9 Remove warnings that causes CI to fail 2017-04-29 08:55:56 +02:00
Arnon Keereena 96e9cf61a7 Merge develop to master 2017-04-28 22:20:01 +02:00
Arnon Keereena aa9f066e04 Passing pointer through block doesn't work as expected
turns back to normal procedural calls, iterator tested.
2017-04-28 22:19:45 +02:00
Arnon Keereena de2984c695 Move CommitIterator to its own file, untested 2017-04-28 09:44:10 +02:00
Arnon Keereena dc2edddac6 Remove the old allCommits function 2017-04-28 09:42:19 +02:00
Arnon Keereena e69e5ca153 Refactor allCommits to return CommitIterator instead,
as loading all commits in one go is not good for
repository with a lot of commits
2017-04-28 09:41:46 +02:00
Arnon Keereena 23abfc6f6a Merge develop to master 2017-04-27 08:29:06 +02:00
Arnon Keereena 3b04a2b94a Add comment 2017-04-27 08:29:03 +02:00
Arnon Keereena 66866049ee Merge develop to master 2017-04-27 08:26:47 +02:00
Arnon Keereena 9eb91a8605 Add tests for modified code.
Fix some errors.
2017-04-27 08:26:34 +02:00
Arnon Keereena 18ee34f681 Fix per comment
- Move allCommits to Repository class
- Remove unwanted spaces
- Restore --lenient flag, even though it still produce compile error
2017-04-27 07:56:56 +02:00
Matt Rubin baa619520d Merge pull request #90 from SwiftGit2/dependencies
Update dependencies
2017-04-26 00:20:23 -04:00
Matt Rubin d6d9d77488 Update dependencies to the latest versions 2017-04-25 23:49:02 -04:00
Arnon Keereena 43d26912a1 Update Quick, Result & ZipArchive 2017-04-25 21:17:33 +02:00
Arnon Keereena 0785b70123 Merge develop into master 2017-04-25 20:53:21 +02:00
Arnon Keereena 20365249f9 Add ability to get all commits from a branch 2017-04-25 20:52:59 +02:00
Matt Rubin 9a2f5a5b31 Merge pull request #88 from mattrubin/lower-case-enum-cases
Convert enum case names to lower camel case
2017-04-24 14:13:34 -04:00
Matt Rubin 3c5ffa2ba5 Re-enable the identifier_name SwiftLint rule 2017-04-24 12:52:30 -04:00
Matt Rubin 6257318a34 Merge origin/master into lower-case-enum-cases 2017-04-24 12:50:33 -04:00
Matt Rubin f2d94c4322 Merge pull request #86 from mattrubin/swiftlint
Improvements for SwiftLint 0.18
2017-04-24 12:49:51 -04:00
Matt Rubin d1d0118bba Remove the empty associated value on Credentials.default
The empty payload is unnecessary, and it will be removed in a future version of Swift:
https://github.com/apple/swift-evolution/blob/master/proposals/0155-normalize-enum-case-representation.md#alternative-payload-less-case-declaration
2017-04-24 11:48:06 -04:00
Matt Rubin c57ea50b85 Use the Xcode 8.3 Travis image, which has SwiftLint 0.18.1 installed
https://blog.travis-ci.com/2017-04-19-xcode-832-is-here
2017-04-24 11:24:46 -04:00
Matt Rubin 5b41c977d2 Convert enum case names to lower camel case
https://swift.org/documentation/api-design-guidelines/#follow-case-conventions
2017-04-24 00:19:27 -04:00
Matt Rubin 4cadad501e Disable Swiftlint identifier_name rule, and enable several other rules 2017-04-23 23:54:16 -04:00
Matt Rubin bb387eb7ab SwiftLint: Returning Void in a function declaration is redundant 2017-04-23 23:25:36 -04:00
Matt Rubin f10c8d03dd Run the SwiftLint build phase with the --lenient flag
Running SwiftLint in "lenient" mode will only generate warnings, preventing the linter from causing the build to fail.
https://github.com/realm/SwiftLint/issues/1322
2017-04-23 23:24:53 -04:00
Jake Van Alstyne 31a0a3dd30 add an implementation of git_repository_init 2017-01-21 14:53:13 -07:00
Matt Rubin b074eff7d7 Merge pull request #83 from SwiftGit2/release-badge
Fix the release badge in the README
2017-01-07 17:56:49 -05:00
Matt Rubin e42270372c Fix the release badge in the README 2017-01-07 16:41:39 -05:00
56 changed files with 1931 additions and 635 deletions
+5
View File
@@ -1,3 +1,6 @@
.vscode/
.build/
# Xcode
#
build/
@@ -17,8 +20,10 @@ DerivedData
*.ipa
*.xcuserstate
*.xcscmblueprint
*.idea*
External/libgit2*.a
External/libgit2-mac
External/ios-openssl
External/libgit2-ios
External/libssh2-ios
+2 -6
View File
@@ -1,9 +1,6 @@
[submodule "External/libgit2"]
path = External/libgit2
url = https://github.com/libgit2/libgit2.git
[submodule "Carthage/Checkouts/Guanaco"]
path = Carthage/Checkouts/Guanaco
url = https://github.com/modocache/Guanaco.git
[submodule "Carthage/Checkouts/Nimble"]
path = Carthage/Checkouts/Nimble
url = https://github.com/Quick/Nimble.git
@@ -13,9 +10,6 @@
[submodule "Carthage/Checkouts/xcconfigs"]
path = Carthage/Checkouts/xcconfigs
url = https://github.com/jspahrsummers/xcconfigs.git
[submodule "Carthage/Checkouts/Result"]
path = Carthage/Checkouts/Result
url = https://github.com/antitypical/Result.git
[submodule "Carthage/Checkouts/ZipArchive"]
path = Carthage/Checkouts/ZipArchive
url = https://github.com/ZipArchive/ZipArchive.git
@@ -25,3 +19,5 @@
[submodule "External/openssl"]
path = External/openssl
url = https://github.com/openssl/openssl.git
[submodule "libgit2"]
url = https://github.com/libgit2/libgit2.git
+4
View File
@@ -0,0 +1,4 @@
# Configuration for Hound (https://houndci.com)
swiftlint:
config_file: .swiftlint.yml
+48
View File
@@ -3,26 +3,74 @@ disabled_rules:
- force_cast
- force_try
- function_body_length
- identifier_name
- redundant_optional_initialization
- type_body_length
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
- contains_over_first_not_nil
- convenience_type
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_count
- empty_string
- empty_xctest_method
- explicit_enum_raw_value
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- first_where
- function_default_parameter_at_end
- identical_operands
- implicitly_unwrapped_optional
- joined_default_parameter
- last_where
- legacy_random
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_function_chains
- multiline_literal_brackets
- nslocalizedstring_key
- overridden_super_call
- override_in_extension
- private_action
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- redundant_nil_coalescing
- redundant_type_annotation
- sorted_first_last
- static_operator
- strict_fileprivate
- switch_case_on_newline
- toggle_bool
- unavailable_function
- untyped_error_in_catch
- unused_import
- unused_private_declaration
- vertical_parameter_alignment_on_call
- xct_specific_matcher
- yoda_condition
excluded:
- Carthage
- External
line_length:
ignores_function_declarations: true
trailing_comma:
mandatory_comma: true
+2 -1
View File
@@ -1,6 +1,7 @@
language: objective-c
osx_image: xcode8.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 -5
View File
@@ -1,5 +1,4 @@
github "jspahrsummers/xcconfigs" >= 0.10
github "Quick/Quick" ~> 1.0
github "Quick/Nimble" ~> 5.0
github "modocache/Guanaco" "6b85ad93b4e7fde8a59d23f94c438a97e1696293"
github "ZipArchive/ZipArchive" ~> 1.6
github "jspahrsummers/xcconfigs" ~> 1.1
github "Quick/Quick" ~> 7.0
github "Quick/Nimble" ~> 12.0
github "ZipArchive/ZipArchive" ~> 2.0
+4 -6
View File
@@ -1,6 +1,4 @@
github "Quick/Nimble" "v5.1.1"
github "Quick/Quick" "v1.0.0"
github "antitypical/Result" "3.1.0"
github "ZipArchive/ZipArchive" "v1.6.2"
github "jspahrsummers/xcconfigs" "0.10"
github "modocache/Guanaco" "6b85ad93b4e7fde8a59d23f94c438a97e1696293"
github "Quick/Nimble" "v12.3.0"
github "Quick/Quick" "v7.3.0"
github "ZipArchive/ZipArchive" "2.5.5"
github "jspahrsummers/xcconfigs" "1.1"
+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
+43 -12
View File
@@ -1,22 +1,32 @@
# SwiftGit2
[![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/ReactiveCocoa/ReactiveSwift.svg)](https://github.com/ReactiveCocoa/ReactiveSwift/releases) ![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg)
[![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 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)")
}
```
@@ -31,7 +41,21 @@ This vastly simplifies the design of long-lived applications, which are the most
All methods for reading from or writing to a repository are on SwiftGits only `class`: `Repository`. This highlights the failability and mutation of these methods, while freeing up all other instances to be immutable `struct`s and `enum`s.
## Importing SwiftGit2
## Required Tools
To build SwiftGit2, you'll need the following tools installed locally:
* cmake
* libssh2
* libtool
* autoconf
* automake
* pkg-config
```
brew install cmake libssh2 libtool autoconf automake pkg-config
```
## Adding SwiftGit2 to your Project
The easiest way to add SwiftGit2 to your project is to use [Carthage](https://github.com/Carthage/Carthage). Simply add `github "SwiftGit2/SwiftGit2"` to your `Cartfile` and run `carthage update`.
If youd like, you can do things the ~~hard~~ old-fashioned way:
@@ -42,6 +66,13 @@ If youd like, you can do things the ~~hard~~ old-fashioned way:
4. On the “Build Phases” tab of your application target, add `SwiftGit2.framework` to the “Link Binary With Libraries” phase. SwiftGit2 must also be added to a “Copy Frameworks” build phase.
5. **If you added SwiftGit2 to a project (not a workspace)**, you will also need to add the appropriate SwiftGit2 target to the “Target Dependencies” of your application.
## Building SwiftGit2 Manually
If you want to build a copy of SwiftGit2 without Carthage, possibly for development:
1. Clone SwiftGit2
2. Run `git submodule update --init --recursive` to clone the submodules
3. Build in Xcode
## Contributions
We :heart: to receive pull requests! GitHub makes it easy:
+154 -141
View File
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {
/* Begin PBXAggregateTarget section */
@@ -21,6 +21,15 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
232861431F4A3A2E00276D65 /* Diffs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 232861421F4A3A2E00276D65 /* Diffs.swift */; };
232861451F4A3A2E00276D65 /* Diffs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 232861421F4A3A2E00276D65 /* Diffs.swift */; };
237731C71F46542B0020A3FE /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; };
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; };
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
621E66A01C72958800A0F352 /* OID.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E41A1ACB1A002C3F4E /* OID.swift */; };
621E66A11C72958800A0F352 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
621E66A21C72958800A0F352 /* CheckoutStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE276B281ACCD3CF00D6DAD7 /* CheckoutStrategy.swift */; };
@@ -40,19 +49,18 @@
621E66BF1C72958D00A0F352 /* ReferencesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */; };
621E66C01C72958D00A0F352 /* OIDSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E61A1ACB37002C3F4E /* OIDSpec.swift */; };
621E66C21C72958D00A0F352 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; };
621E66C31C72958D00A0F352 /* Guanaco.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA59146C1A94549A00AED74C /* Guanaco.framework */; };
621E66C41C72958D00A0F352 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA50239F1A969F1A004175D7 /* Nimble.framework */; };
621E66C51C72958D00A0F352 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; };
621E66C81C72958D00A0F352 /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; };
621E66C91C72958D00A0F352 /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; };
621E66CA1C72958D00A0F352 /* simple-repository.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE14AA561A198C6E0015B439 /* simple-repository.zip */; };
621E66D91C72989A00A0F352 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66D81C72989900A0F352 /* Result.framework */; };
621E66E61C729D9600A0F352 /* SwiftGit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66B41C72958800A0F352 /* SwiftGit2.framework */; };
621E66FE1C72A5FF00A0F352 /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66FD1C72A5FF00A0F352 /* libiconv.tbd */; };
621E67001C72A60B00A0F352 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 621E66FF1C72A60B00A0F352 /* libz.tbd */; };
622726341C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; };
622726351C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; };
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; };
8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; };
BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; };
BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; };
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */ = {isa = PBXBuildFile; fileRef = BE14AA4F1A1974010015B439 /* SwiftGit2.m */; };
@@ -76,9 +84,9 @@
BECB5F6C1A56F1B400999413 /* ReferencesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */; };
BECB5F6E1A57284700999413 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
BECB5F701A57286200999413 /* RemotesSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6F1A57286200999413 /* RemotesSpec.swift */; };
BEE591C71ADF470500534F14 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEE591C61ADF470500534F14 /* Result.framework */; };
C98A2BA22263FDB9007A4E3A /* ResultShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A2B9F2263E017007A4E3A /* ResultShims.swift */; };
C98A2BA32263FDBA007A4E3A /* ResultShims.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A2B9F2263E017007A4E3A /* ResultShims.swift */; };
DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA50239F1A969F1A004175D7 /* Nimble.framework */; };
DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA59146C1A94549A00AED74C /* Guanaco.framework */; };
DA5914761A94579000AED74C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5914751A94579000AED74C /* Errors.swift */; };
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; };
/* End PBXBuildFile section */
@@ -119,19 +127,32 @@
remoteGlobalIDString = BEB31F221A0D6F7A00F525B9;
remoteInfo = "SwiftGit2-OSX";
};
BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = BEB31F1A1A0D6F7A00F525B9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = BEB31F8E1A0E563900F525B9;
remoteInfo = libgit2;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
50A682E52ADBF65F00FDB557 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
50A6835F2ADE7C2B00FDB557 /* libgit2.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
232861421F4A3A2E00276D65 /* Diffs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diffs.swift; sourceTree = "<group>"; };
237731C61F46542B0020A3FE /* repository-with-status.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "repository-with-status.zip"; sourceTree = "<group>"; };
25499A996CA7BD416620A397 /* CommitIterator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommitIterator.swift; sourceTree = "<group>"; };
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusOptions.swift; sourceTree = "<group>"; };
50A682D82AD9901000FDB557 /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; path = script; sourceTree = "<group>"; };
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libgit2-mac.a"; path = "External/libgit2-mac/libgit2-mac.a"; sourceTree = "<group>"; };
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = libgit2.xcframework; path = "External/libgit2-ios/libgit2.xcframework"; sourceTree = "<group>"; };
621E66B41C72958800A0F352 /* SwiftGit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftGit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SwiftGit2-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
621E66D81C72989900A0F352 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = "Carthage/Checkouts/Result/build/Debug-iphoneos/Result.framework"; sourceTree = "<group>"; };
621E66E11C729CE500A0F352 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
621E66EC1C729EB800A0F352 /* libssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libssl.a; sourceTree = BUILT_PRODUCTS_DIR; };
621E66F21C729EBB00A0F352 /* libssh2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libssh2.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -170,23 +191,21 @@
BEB31F4F1A0D75EE00F525B9 /* iOS-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-Base.xcconfig"; sourceTree = "<group>"; };
BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-Framework.xcconfig"; sourceTree = "<group>"; };
BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Application.xcconfig"; sourceTree = "<group>"; };
BEB31F541A0D75EE00F525B9 /* Mac-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Base.xcconfig"; sourceTree = "<group>"; };
BEB31F551A0D75EE00F525B9 /* Mac-DynamicLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-DynamicLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-Framework.xcconfig"; sourceTree = "<group>"; };
BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Application.xcconfig"; sourceTree = "<group>"; };
BEB31F541A0D75EE00F525B9 /* macOS-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Base.xcconfig"; sourceTree = "<group>"; };
BEB31F551A0D75EE00F525B9 /* macOS-DynamicLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-DynamicLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-Framework.xcconfig"; sourceTree = "<group>"; };
BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "macOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F581A0D75EE00F525B9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BEB31F6C1A0D78F300F525B9 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
BEB31F8F1A0E563900F525B9 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
BEB31F9F1A0E595600F525B9 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
BECB5F691A56F19900999413 /* References.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = References.swift; sourceTree = "<group>"; };
BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReferencesSpec.swift; sourceTree = "<group>"; };
BECB5F6D1A57284700999413 /* Remotes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Remotes.swift; sourceTree = "<group>"; };
BECB5F6F1A57286200999413 /* RemotesSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemotesSpec.swift; sourceTree = "<group>"; };
BEE591C61ADF470500534F14 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = "../../Library/Developer/Xcode/DerivedData/SwiftGit2-cdzquzvlxdewyddxgdgxjagqvjba/Build/Products/Debug/Result.framework"; sourceTree = "<group>"; };
C98A2B9F2263E017007A4E3A /* ResultShims.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultShims.swift; sourceTree = "<group>"; };
DA50239F1A969F1A004175D7 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA59146C1A94549A00AED74C /* Guanaco.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Guanaco.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA5914751A94579000AED74C /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
DAC8143C1A99749D0063D88C /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../../Library/Developer/Xcode/DerivedData/SwiftGit2-ezqqkevntxbroughwcioyxqriijk/Build/Products/Debug/Quick.framework"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -197,8 +216,8 @@
buildActionMask = 2147483647;
files = (
621E67001C72A60B00A0F352 /* libz.tbd in Frameworks */,
50A6835E2ADE7C2B00FDB557 /* libgit2.xcframework in Frameworks */,
621E66FE1C72A5FF00A0F352 /* libiconv.tbd in Frameworks */,
621E66D91C72989A00A0F352 /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -208,7 +227,6 @@
files = (
621E66E61C729D9600A0F352 /* SwiftGit2.framework in Frameworks */,
621E66C21C72958D00A0F352 /* ZipArchive.framework in Frameworks */,
621E66C31C72958D00A0F352 /* Guanaco.framework in Frameworks */,
621E66C41C72958D00A0F352 /* Nimble.framework in Frameworks */,
621E66C51C72958D00A0F352 /* Quick.framework in Frameworks */,
);
@@ -218,7 +236,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BEE591C71ADF470500534F14 /* Result.framework in Frameworks */,
BEB31FA01A0E595600F525B9 /* libz.dylib in Frameworks */,
BEB31F9E1A0E595100F525B9 /* libiconv.dylib in Frameworks */,
);
@@ -229,7 +246,6 @@
buildActionMask = 2147483647;
files = (
62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */,
DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */,
DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */,
DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */,
BEB31F2F1A0D6F7A00F525B9 /* SwiftGit2.framework in Frameworks */,
@@ -239,10 +255,18 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
50A682D92AD994C500FDB557 /* Frameworks */ = {
isa = PBXGroup;
children = (
50A6835C2ADE7C2300FDB557 /* libgit2.xcframework */,
50A6835A2ADD33CE00FDB557 /* libgit2-mac.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
621E66D41C72965C00A0F352 /* Mac */ = {
isa = PBXGroup;
children = (
BEE591C61ADF470500534F14 /* Result.framework */,
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */,
BEB31F9F1A0E595600F525B9 /* libz.dylib */,
);
@@ -252,7 +276,6 @@
621E66D51C72966000A0F352 /* iOS */ = {
isa = PBXGroup;
children = (
621E66D81C72989900A0F352 /* Result.framework */,
621E66FD1C72A5FF00A0F352 /* libiconv.tbd */,
621E66FF1C72A60B00A0F352 /* libz.tbd */,
);
@@ -262,6 +285,7 @@
BE14AA531A1983520015B439 /* Fixtures */ = {
isa = PBXGroup;
children = (
237731C61F46542B0020A3FE /* repository-with-status.zip */,
BE0B1C5C1A9978890004726D /* detached-head.zip */,
BE14AA541A1984550015B439 /* Fixtures.swift */,
BE0991F61A578FB1007D4E6A /* Mantle.zip */,
@@ -273,11 +297,14 @@
BEB31F191A0D6F7A00F525B9 = {
isa = PBXGroup;
children = (
50A682D82AD9901000FDB557 /* script */,
BEB31F251A0D6F7A00F525B9 /* SwiftGit2 */,
BEB31F261A0D6F7A00F525B9 /* Supporting Files */,
BEB31F321A0D6F7A00F525B9 /* SwiftGit2Tests */,
BEB31FA11A0E63C100F525B9 /* Libraries */,
BEB31F411A0D75EE00F525B9 /* Configuration */,
BEB31F241A0D6F7A00F525B9 /* Products */,
50A682D92AD994C500FDB557 /* Frameworks */,
);
sourceTree = "<group>";
usesTabs = 1;
@@ -287,7 +314,6 @@
children = (
BEB31F231A0D6F7A00F525B9 /* SwiftGit2.framework */,
BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */,
BEB31F8F1A0E563900F525B9 /* libgit2.a */,
621E66B41C72958800A0F352 /* SwiftGit2.framework */,
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */,
621E66E11C729CE500A0F352 /* libgit2.a */,
@@ -307,12 +333,14 @@
DA5914751A94579000AED74C /* Errors.swift */,
BE36354B1A632C9700D37EC8 /* Libgit2.swift */,
BE2E3BE51A31261300C67092 /* Objects.swift */,
232861421F4A3A2E00276D65 /* Diffs.swift */,
BE70B3E41A1ACB1A002C3F4E /* OID.swift */,
BE7A753E1A4A2BCC002DA7E3 /* Pointers.swift */,
BEB31F6C1A0D78F300F525B9 /* Repository.swift */,
BECB5F691A56F19900999413 /* References.swift */,
BECB5F6D1A57284700999413 /* Remotes.swift */,
BEB31F261A0D6F7A00F525B9 /* Supporting Files */,
25499A996CA7BD416620A397 /* CommitIterator.swift */,
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */,
);
path = SwiftGit2;
sourceTree = "<group>";
@@ -323,6 +351,7 @@
BEB31F271A0D6F7A00F525B9 /* Info.plist */,
);
name = "Supporting Files";
path = SwiftGit2;
sourceTree = "<group>";
};
BEB31F321A0D6F7A00F525B9 /* SwiftGit2Tests */ = {
@@ -335,6 +364,7 @@
BECB5F6B1A56F1B400999413 /* ReferencesSpec.swift */,
BECB5F6F1A57286200999413 /* RemotesSpec.swift */,
BE14AA581A1996B70015B439 /* FixturesSpec.swift */,
C98A2B9F2263E017007A4E3A /* ResultShims.swift */,
BEB31F331A0D6F7A00F525B9 /* Supporting Files */,
);
path = SwiftGit2Tests;
@@ -346,7 +376,6 @@
62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */,
DA50239F1A969F1A004175D7 /* Nimble.framework */,
DAC8143C1A99749D0063D88C /* Quick.framework */,
DA59146C1A94549A00AED74C /* Guanaco.framework */,
BEB31F341A0D6F7A00F525B9 /* Info.plist */,
);
name = "Supporting Files";
@@ -357,7 +386,7 @@
children = (
BEB31F421A0D75EE00F525B9 /* Base */,
BEB31F4D1A0D75EE00F525B9 /* iOS */,
BEB31F521A0D75EE00F525B9 /* Mac OS X */,
BEB31F521A0D75EE00F525B9 /* macOS */,
BEB31F581A0D75EE00F525B9 /* README.md */,
);
name = Configuration;
@@ -406,16 +435,16 @@
path = iOS;
sourceTree = "<group>";
};
BEB31F521A0D75EE00F525B9 /* Mac OS X */ = {
BEB31F521A0D75EE00F525B9 /* macOS */ = {
isa = PBXGroup;
children = (
BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */,
BEB31F541A0D75EE00F525B9 /* Mac-Base.xcconfig */,
BEB31F551A0D75EE00F525B9 /* Mac-DynamicLibrary.xcconfig */,
BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */,
BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */,
BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */,
BEB31F541A0D75EE00F525B9 /* macOS-Base.xcconfig */,
BEB31F551A0D75EE00F525B9 /* macOS-DynamicLibrary.xcconfig */,
BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */,
BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */,
);
path = "Mac OS X";
path = macOS;
sourceTree = "<group>";
};
BEB31FA11A0E63C100F525B9 /* Libraries */ = {
@@ -456,6 +485,7 @@
621E669F1C72958800A0F352 /* Sources */,
621E66AA1C72958800A0F352 /* Frameworks */,
621E66AE1C72958800A0F352 /* Headers */,
50A682E52ADBF65F00FDB557 /* Embed Frameworks */,
);
buildRules = (
);
@@ -536,6 +566,7 @@
isa = PBXNativeTarget;
buildConfigurationList = BEB31F391A0D6F7A00F525B9 /* Build configuration list for PBXNativeTarget "SwiftGit2-OSX" */;
buildPhases = (
50A682DD2AD9959500FDB557 /* Update libgit2 */,
BEB31F1E1A0D6F7A00F525B9 /* Sources */,
BEB31F1F1A0D6F7A00F525B9 /* Frameworks */,
BEB31F201A0D6F7A00F525B9 /* Headers */,
@@ -543,7 +574,6 @@
buildRules = (
);
dependencies = (
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */,
);
name = "SwiftGit2-OSX";
productName = "SwiftGit2-OSX";
@@ -568,21 +598,6 @@
productReference = BEB31F2E1A0D6F7A00F525B9 /* SwiftGit2-OSXTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */ = {
isa = PBXNativeTarget;
buildConfigurationList = BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */;
buildPhases = (
BEB31F931A0E567000F525B9 /* ShellScript */,
);
buildRules = (
);
dependencies = (
);
name = "libgit2-OSX";
productName = libgit2;
productReference = BEB31F8F1A0E563900F525B9 /* libgit2.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -590,25 +605,22 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1220;
ORGANIZATIONNAME = "GitHub, Inc";
TargetAttributes = {
621E66611C72958800A0F352 = {
LastSwiftMigration = 0810;
LastSwiftMigration = 1020;
};
621E66B61C72958D00A0F352 = {
LastSwiftMigration = 0810;
LastSwiftMigration = 1020;
};
BEB31F221A0D6F7A00F525B9 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 1020;
};
BEB31F2D1A0D6F7A00F525B9 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0810;
};
BEB31F8E1A0E563900F525B9 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 1020;
};
C9CE0DD21E0710BD0053205D = {
CreatedOnToolsVersion = 8.2;
@@ -618,10 +630,11 @@
};
buildConfigurationList = BEB31F1D1A0D6F7A00F525B9 /* Build configuration list for PBXProject "SwiftGit2" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = BEB31F191A0D6F7A00F525B9;
productRefGroup = BEB31F241A0D6F7A00F525B9 /* Products */;
@@ -632,7 +645,6 @@
BEB31F2D1A0D6F7A00F525B9 /* SwiftGit2-OSXTests */,
621E66611C72958800A0F352 /* SwiftGit2-iOS */,
621E66B61C72958D00A0F352 /* SwiftGit2-iOSTests */,
BEB31F8E1A0E563900F525B9 /* libgit2-OSX */,
621E66DC1C729CE500A0F352 /* libgit2-iOS */,
621E66E71C729EB800A0F352 /* OpenSSL-iOS */,
621E66ED1C729EBB00A0F352 /* libssh2-iOS */,
@@ -647,6 +659,7 @@
buildActionMask = 2147483647;
files = (
621E66C81C72958D00A0F352 /* detached-head.zip in Resources */,
8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */,
621E66C91C72958D00A0F352 /* Mantle.zip in Resources */,
621E66CA1C72958D00A0F352 /* simple-repository.zip in Resources */,
);
@@ -657,6 +670,7 @@
buildActionMask = 2147483647;
files = (
BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */,
237731C71F46542B0020A3FE /* repository-with-status.zip in Resources */,
BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */,
BE14AA571A198C6E0015B439 /* simple-repository.zip in Resources */,
);
@@ -665,21 +679,44 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
50A682DD2AD9959500FDB557 /* Update libgit2 */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Update libgit2";
outputFileListPaths = (
);
outputPaths = (
"$(SRCROOT)/External/libgit2-mac/libgit2-mac.a",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "script/update_libgit2\n";
};
621E66DD1C729CE500A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
"$(SRCROOT)/External/libgit2-ios/libgit2.xcframework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = script/update_libgit2_ios;
shellScript = "script/update_libgit2_ios\n";
};
621E66E81C729EB800A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -689,10 +726,11 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = script/update_libssl_ios;
shellScript = "script/update_libssl_ios\n";
};
621E66EE1C729EBB00A0F352 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -702,23 +740,11 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = script/update_libssh2_ios;
};
BEB31F931A0E567000F525B9 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = script/update_libgit2;
shellScript = "script/update_libssh2_ios\n";
};
C9CE0DD61E0710C20053205D /* Lint Sources */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -729,7 +755,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint is not installed\"\nfi";
shellScript = "if which swiftlint >/dev/null; then\n swiftlint --lenient\nelse\n echo \"warning: SwiftLint is not installed\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */
@@ -744,11 +770,14 @@
622726351C84E52500C53D17 /* Credentials.swift in Sources */,
621E66A31C72958800A0F352 /* Repository.swift in Sources */,
621E66A41C72958800A0F352 /* Objects.swift in Sources */,
232861451F4A3A2E00276D65 /* Diffs.swift in Sources */,
621E66A51C72958800A0F352 /* References.swift in Sources */,
621E66A61C72958800A0F352 /* Libgit2.swift in Sources */,
621E66A71C72958800A0F352 /* Pointers.swift in Sources */,
621E66A81C72958800A0F352 /* Errors.swift in Sources */,
621E66A91C72958800A0F352 /* SwiftGit2.m in Sources */,
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */,
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -763,6 +792,7 @@
621E66BE1C72958D00A0F352 /* Fixtures.swift in Sources */,
621E66BF1C72958D00A0F352 /* ReferencesSpec.swift in Sources */,
621E66C01C72958D00A0F352 /* OIDSpec.swift in Sources */,
C98A2BA32263FDBA007A4E3A /* ResultShims.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -776,11 +806,14 @@
622726341C84E52500C53D17 /* Credentials.swift in Sources */,
BEB31F6D1A0D78F300F525B9 /* Repository.swift in Sources */,
BE2E3BE61A31261300C67092 /* Objects.swift in Sources */,
232861431F4A3A2E00276D65 /* Diffs.swift in Sources */,
BECB5F6A1A56F19900999413 /* References.swift in Sources */,
BE36354C1A632C9700D37EC8 /* Libgit2.swift in Sources */,
BE7A753F1A4A2BCC002DA7E3 /* Pointers.swift in Sources */,
DA5914761A94579000AED74C /* Errors.swift in Sources */,
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */,
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */,
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -795,6 +828,7 @@
BE14AA551A1984550015B439 /* Fixtures.swift in Sources */,
BECB5F6C1A56F1B400999413 /* ReferencesSpec.swift in Sources */,
BE70B3E71A1ACB37002C3F4E /* OIDSpec.swift in Sources */,
C98A2BA22263FDB9007A4E3A /* ResultShims.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -826,11 +860,6 @@
target = BEB31F221A0D6F7A00F525B9 /* SwiftGit2-OSX */;
targetProxy = BEB31F301A0D6F7A00F525B9 /* PBXContainerItemProxy */;
};
BEB31F951A0E56E200F525B9 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = BEB31F8E1A0E563900F525B9 /* libgit2-OSX */;
targetProxy = BEB31F941A0E56E200F525B9 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@@ -838,8 +867,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
External/libgit2/include,
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
@@ -850,9 +880,6 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -867,8 +894,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F501A0D75EE00F525B9 /* iOS-Framework.xcconfig */;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/External/libgit2-ios";
HEADER_SEARCH_PATHS = (
External/libgit2/include,
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
@@ -879,9 +907,6 @@
"$(inherited)",
);
OTHER_LDFLAGS = (
"-force_load",
"External/libgit2-ios/libgit2-ios.a",
"-lgit2-ios",
"-lssl",
"-lcrypto",
"-lssh2-ios",
@@ -916,6 +941,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Debug;
@@ -924,6 +950,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
PRODUCT_NAME = git2;
};
name = Release;
@@ -964,10 +991,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F451A0D75EE00F525B9 /* Debug.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 3.0;
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -976,31 +1007,35 @@
baseConfigurationReference = BEB31F471A0D75EE00F525B9 /* Release.xcconfig */;
buildSettings = {
ENABLE_NS_ASSERTIONS = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
SWIFT_VERSION = 3.0;
INSTALL_GROUP = "";
INSTALL_MODE_FLAG = "";
INSTALL_OWNER = "";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
SWIFT_VERSION = 5.0;
};
name = Release;
};
BEB31F3A1A0D6F7A00F525B9 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */;
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */;
buildSettings = {
HEADER_SEARCH_PATHS = (
External/libgit2/include,
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
LIBRARY_SEARCH_PATHS = (
External,
"External/libgit2-mac",
External/,
"$(inherited)",
"$(PROJECT_DIR)/External/libgit2-mac",
);
OTHER_LDFLAGS = (
"-lgit2",
"-force_load",
External/libgit2.a,
/usr/local/lib/libssh2.a,
/opt/homebrew/lib/libssh2.a,
"-lgit2-mac",
"-lcrypto",
"-lssl",
"-lcurl",
@@ -1008,27 +1043,28 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
};
name = Debug;
};
BEB31F3B1A0D6F7A00F525B9 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* Mac-Framework.xcconfig */;
baseConfigurationReference = BEB31F561A0D75EE00F525B9 /* macOS-Framework.xcconfig */;
buildSettings = {
HEADER_SEARCH_PATHS = (
External/libgit2/include,
"$(SRCROOT)/External/libgit2/include",
"$(inherited)",
);
INFOPLIST_FILE = SwiftGit2/Info.plist;
LIBRARY_SEARCH_PATHS = (
External,
"External/libgit2-mac",
External/,
"$(inherited)",
"$(PROJECT_DIR)/External/libgit2-mac",
);
OTHER_LDFLAGS = (
"-lgit2",
"-force_load",
External/libgit2.a,
/usr/local/lib/libssh2.a,
/opt/homebrew/lib/libssh2.a,
"-lgit2-mac",
"-lcrypto",
"-lssl",
"-lcurl",
@@ -1036,12 +1072,13 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SwiftGit2;
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
};
name = Release;
};
BEB31F3D1A0D6F7A00F525B9 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */;
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
@@ -1051,7 +1088,7 @@
};
BEB31F3E1A0D6F7A00F525B9 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* Mac-Application.xcconfig */;
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
buildSettings = {
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
@@ -1059,22 +1096,6 @@
};
name = Release;
};
BEB31F911A0E563900F525B9 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
PRODUCT_NAME = git2;
};
name = Debug;
};
BEB31F921A0E563900F525B9 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
PRODUCT_NAME = git2;
};
name = Release;
};
C9CE0DD41E0710BD0053205D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -1164,15 +1185,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
BEB31F901A0E563900F525B9 /* Build configuration list for PBXNativeTarget "libgit2-OSX" */ = {
isa = XCConfigurationList;
buildConfigurations = (
BEB31F911A0E563900F525B9 /* Debug */,
BEB31F921A0E563900F525B9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C9CE0DD31E0710BD0053205D /* Build configuration list for PBXAggregateTarget "SwiftLint" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -1180,6 +1192,7 @@
C9CE0DD51E0710BD0053205D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1220"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-OSX"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@@ -53,17 +62,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-OSX"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@@ -84,8 +82,6 @@
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1220"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66611C72958800A0F352"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-iOS"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@@ -53,17 +62,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66611C72958800A0F352"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-iOS"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@@ -84,8 +82,6 @@
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
-6
View File
@@ -4,18 +4,12 @@
<FileRef
location = "group:SwiftGit2.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Result/Result.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Quick/Quick.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Nimble/Nimble.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Guanaco/Guanaco.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/ZipArchive/ZipArchive.xcodeproj">
</FileRef>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+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`.
+70
View File
@@ -0,0 +1,70 @@
//
// Created by Arnon Keereena on 4/28/17.
// Copyright (c) 2017 GitHub, Inc. All rights reserved.
//
import Foundation
import Clibgit2
public class CommitIterator: IteratorProtocol, Sequence {
public typealias Iterator = CommitIterator
public typealias Element = Result<Commit, NSError>
let repo: Repository
private var revisionWalker: OpaquePointer?
private enum Next {
case over
case okay
case error(NSError)
init(_ result: Int32, name: String) {
switch result {
case GIT_ITEROVER.rawValue:
self = .over
case GIT_OK.rawValue:
self = .okay
default:
self = .error(NSError(gitError: result, pointOfFailure: name))
}
}
}
init(repo: Repository, root: git_oid) {
self.repo = repo
setupRevisionWalker(root: root)
}
deinit {
git_revwalk_free(self.revisionWalker)
}
private func setupRevisionWalker(root: git_oid) {
var oid = root
git_revwalk_new(&revisionWalker, repo.pointer)
git_revwalk_sorting(revisionWalker, GIT_SORT_TOPOLOGICAL.rawValue)
git_revwalk_sorting(revisionWalker, GIT_SORT_TIME.rawValue)
git_revwalk_push(revisionWalker, &oid)
}
public func next() -> Element? {
var oid = git_oid()
let revwalkGitResult = git_revwalk_next(&oid, revisionWalker)
let nextResult = Next(revwalkGitResult, name: "git_revwalk_next")
switch nextResult {
case let .error(error):
return Result.failure(error)
case .over:
return nil
case .okay:
var unsafeCommit: OpaquePointer? = nil
let lookupGitResult = git_commit_lookup(&unsafeCommit, repo.pointer, &oid)
guard lookupGitResult == GIT_OK.rawValue,
let unwrapCommit = unsafeCommit else {
return Result.failure(NSError(gitError: lookupGitResult, pointOfFailure: "git_commit_lookup"))
}
let result: Element = Result.success(Commit(unwrapCommit))
git_commit_free(unsafeCommit)
return result
}
}
}
+20 -9
View File
@@ -6,7 +6,7 @@
// Copyright © 2016 GitHub, Inc. All rights reserved.
//
import libgit2
import Clibgit2
private class Wrapper<T> {
let value: T
@@ -17,9 +17,10 @@ private class Wrapper<T> {
}
public enum Credentials {
case Default()
case Plaintext(username: String, password: String)
case SSHMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
case `default`
case sshAgent
case plaintext(username: String, password: String)
case sshMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials {
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
@@ -33,16 +34,26 @@ public enum Credentials {
/// Handle the request of credentials, passing through to a wrapped block after converting the arguments.
/// Converts the result to the correct error code required by libgit2 (0 = success, 1 = rejected setting creds,
/// -1 = error)
internal func credentialsCallback(cred: UnsafeMutablePointer<UnsafeMutablePointer<git_cred>?>?, _: UnsafePointer<Int8>?,
_: UnsafePointer<Int8>?, _: UInt32, payload: UnsafeMutableRawPointer?) -> Int32 {
internal func credentialsCallback(
cred: UnsafeMutablePointer<UnsafeMutablePointer<git_cred>?>?,
url: UnsafePointer<CChar>?,
username: UnsafePointer<CChar>?,
_: UInt32,
payload: UnsafeMutableRawPointer? ) -> Int32 {
let result: Int32
// Find username_from_url
let name = username.map(String.init(cString:))
switch Credentials.fromPointer(payload!) {
case .Default():
case .default:
result = git_cred_default_new(cred)
case .Plaintext(let username, let password):
case .sshAgent:
result = git_cred_ssh_key_from_agent(cred, name!)
case .plaintext(let username, let password):
result = git_cred_userpass_plaintext_new(cred, username, password)
case .SSHMemory(let username, let publicKey, let privateKey, let passphrase):
case .sshMemory(let username, let publicKey, let privateKey, let passphrase):
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
}
+111
View File
@@ -0,0 +1,111 @@
//
// Diffs.swift
// SwiftGit2
//
// Created by Jake Van Alstyne on 8/20/17.
// Copyright © 2017 GitHub, Inc. All rights reserved.
//
import Clibgit2
public struct StatusEntry {
public var status: Diff.Status
public var headToIndex: Diff.Delta?
public var indexToWorkDir: Diff.Delta?
public init(from statusEntry: git_status_entry) {
self.status = Diff.Status(rawValue: statusEntry.status.rawValue)
if let htoi = statusEntry.head_to_index {
self.headToIndex = Diff.Delta(htoi.pointee)
}
if let itow = statusEntry.index_to_workdir {
self.indexToWorkDir = Diff.Delta(itow.pointee)
}
}
}
public struct Diff {
/// The set of deltas.
public var deltas = [Delta]()
public struct Delta {
public static let type = GIT_OBJECT_REF_DELTA
public var status: Status
public var flags: Flags
public var oldFile: File?
public var newFile: File?
public init(_ delta: git_diff_delta) {
self.status = Status(rawValue: UInt32(git_diff_status_char(delta.status)))
self.flags = Flags(rawValue: delta.flags)
self.oldFile = File(delta.old_file)
self.newFile = File(delta.new_file)
}
}
public struct File {
public var oid: OID
public var path: String
public var size: UInt64
public var flags: Flags
public init(_ diffFile: git_diff_file) {
self.oid = OID(diffFile.id)
let path = diffFile.path
self.path = path.map(String.init(cString:))!
self.size = diffFile.size
self.flags = Flags(rawValue: diffFile.flags)
}
}
public struct Status: OptionSet {
// This appears to be necessary due to bug in Swift
// https://bugs.swift.org/browse/SR-3003
public init(rawValue: UInt32) {
self.rawValue = rawValue
}
public let rawValue: UInt32
public static let current = Status(rawValue: GIT_STATUS_CURRENT.rawValue)
public static let indexNew = Status(rawValue: GIT_STATUS_INDEX_NEW.rawValue)
public static let indexModified = Status(rawValue: GIT_STATUS_INDEX_MODIFIED.rawValue)
public static let indexDeleted = Status(rawValue: GIT_STATUS_INDEX_DELETED.rawValue)
public static let indexRenamed = Status(rawValue: GIT_STATUS_INDEX_RENAMED.rawValue)
public static let indexTypeChange = Status(rawValue: GIT_STATUS_INDEX_TYPECHANGE.rawValue)
public static let workTreeNew = Status(rawValue: GIT_STATUS_WT_NEW.rawValue)
public static let workTreeModified = Status(rawValue: GIT_STATUS_WT_MODIFIED.rawValue)
public static let workTreeDeleted = Status(rawValue: GIT_STATUS_WT_DELETED.rawValue)
public static let workTreeTypeChange = Status(rawValue: GIT_STATUS_WT_TYPECHANGE.rawValue)
public static let workTreeRenamed = Status(rawValue: GIT_STATUS_WT_RENAMED.rawValue)
public static let workTreeUnreadable = Status(rawValue: GIT_STATUS_WT_UNREADABLE.rawValue)
public static let ignored = Status(rawValue: GIT_STATUS_IGNORED.rawValue)
public static let conflicted = Status(rawValue: GIT_STATUS_CONFLICTED.rawValue)
}
public struct Flags: OptionSet {
// This appears to be necessary due to bug in Swift
// https://bugs.swift.org/browse/SR-3003
public init(rawValue: UInt32) {
self.rawValue = rawValue
}
public let rawValue: UInt32
public static let binary = Flags([])
public static let notBinary = Flags(rawValue: 1 << 0)
public static let validId = Flags(rawValue: 1 << 1)
public static let exists = Flags(rawValue: 1 << 2)
}
/// Create an instance with a libgit2 `git_diff`.
public init(_ pointer: OpaquePointer) {
for i in 0..<git_diff_num_deltas(pointer) {
if let delta = git_diff_get_delta(pointer, i) {
deltas.append(Diff.Delta(delta.pointee))
}
}
}
}
+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
}
}
+45 -50
View File
@@ -6,87 +6,88 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import libgit2
import Clibgit2
/// A pointer to a git object.
public protocol PointerType: Equatable, Hashable {
public protocol PointerType: Hashable {
/// The OID of the referenced object.
var oid: OID { get }
/// The libgit2 `git_otype` of the referenced object.
var type: git_otype { get }
/// The libgit2 `git_object_t` of the referenced object.
var type: git_object_t { get }
}
public func == <P: PointerType>(lhs: P, rhs: P) -> Bool {
return lhs.oid == rhs.oid && lhs.type.rawValue == rhs.type.rawValue
public extension PointerType {
static func == (lhs: Self, rhs: Self) -> Bool {
return lhs.oid == rhs.oid
&& lhs.type == rhs.type
}
func hash(into hasher: inout Hasher) {
hasher.combine(oid)
}
}
/// A pointer to a git object.
public enum Pointer: PointerType {
case Commit(OID)
case Tree(OID)
case Blob(OID)
case Tag(OID)
case commit(OID)
case tree(OID)
case blob(OID)
case tag(OID)
public var oid: OID {
switch self {
case let .Commit(oid):
case let .commit(oid):
return oid
case let .Tree(oid):
case let .tree(oid):
return oid
case let .Blob(oid):
case let .blob(oid):
return oid
case let .Tag(oid):
case let .tag(oid):
return oid
}
}
public var type: git_otype {
public var type: git_object_t {
switch self {
case .Commit:
return GIT_OBJ_COMMIT
case .Tree:
return GIT_OBJ_TREE
case .Blob:
return GIT_OBJ_BLOB
case .Tag:
return GIT_OBJ_TAG
case .commit:
return GIT_OBJECT_COMMIT
case .tree:
return GIT_OBJECT_TREE
case .blob:
return GIT_OBJECT_BLOB
case .tag:
return GIT_OBJECT_TAG
}
}
/// Create an instance with an OID and a libgit2 `git_otype`.
init?(oid: OID, type: git_otype) {
/// Create an instance with an OID and a libgit2 `git_object_t`.
init?(oid: OID, type: git_object_t) {
switch type {
case GIT_OBJ_COMMIT:
self = .Commit(oid)
case GIT_OBJ_TREE:
self = .Tree(oid)
case GIT_OBJ_BLOB:
self = .Blob(oid)
case GIT_OBJ_TAG:
self = .Tag(oid)
case GIT_OBJECT_COMMIT:
self = .commit(oid)
case GIT_OBJECT_TREE:
self = .tree(oid)
case GIT_OBJECT_BLOB:
self = .blob(oid)
case GIT_OBJECT_TAG:
self = .tag(oid)
default:
return nil
}
}
}
extension Pointer: Hashable {
public var hashValue: Int {
return oid.hashValue
}
}
extension Pointer: CustomStringConvertible {
public var description: String {
switch self {
case .Commit:
case .commit:
return "commit(\(oid))"
case .Tree:
case .tree:
return "tree(\(oid))"
case .Blob:
case .blob:
return "blob(\(oid))"
case .Tag:
case .tag:
return "tag(\(oid))"
}
}
@@ -95,7 +96,7 @@ extension Pointer: CustomStringConvertible {
public struct PointerTo<T: ObjectType>: PointerType {
public let oid: OID
public var type: git_otype {
public var type: git_object_t {
return T.type
}
@@ -103,9 +104,3 @@ public struct PointerTo<T: ObjectType>: PointerType {
self.oid = oid
}
}
extension PointerTo: Hashable {
public var hashValue: Int {
return oid.hashValue
}
}
+25 -36
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,33 +122,27 @@ public struct Branch: ReferenceType {
}
}
extension Branch: Hashable {
public var hashValue: Int {
return longName.hashValue ^ oid.hashValue
}
}
/// A git tag reference, which can be either a lightweight tag or a Tag object.
public enum TagReference: ReferenceType {
public enum TagReference: ReferenceType, Hashable {
/// A lightweight tag, which is just a name and an OID.
case Lightweight(String, OID)
case lightweight(String, OID)
/// An annotated tag, which points to a Tag object.
case Annotated(String, Tag)
case annotated(String, Tag)
/// The full name of the reference (e.g., `refs/tags/my-tag`).
public var longName: String {
switch self {
case let .Lightweight(name, _):
case let .lightweight(name, _):
return name
case let .Annotated(name, _):
case let .annotated(name, _):
return name
}
}
/// The short human-readable name of the branch (e.g., `master`).
public var name: String {
return longName.substring(from: "refs/tags/".endIndex)
return String(longName["refs/tags/".endIndex...])
}
/// The OID of the target object.
@@ -155,9 +150,9 @@ public enum TagReference: ReferenceType {
/// If this is an annotated tag, the OID will be the tag's target.
public var oid: OID {
switch self {
case let .Lightweight(_, oid):
case let .lightweight(_, oid):
return oid
case let .Annotated(_, tag):
case let .annotated(_, tag):
return tag.target.oid
}
}
@@ -183,18 +178,12 @@ public enum TagReference: ReferenceType {
var oid = git_reference_target(pointer).pointee
var pointer: OpaquePointer? = nil
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG)
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJECT_TAG)
if result == GIT_OK.rawValue {
self = .Annotated(name, Tag(pointer!))
self = .annotated(name, Tag(pointer!))
} else {
self = .Lightweight(name, OID(oid))
self = .lightweight(name, OID(oid))
}
git_object_free(pointer)
}
}
extension TagReference: Hashable {
public var hashValue: Int {
return longName.hashValue ^ oid.hashValue
}
}
+2 -12
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
}
+511 -61
View File
@@ -7,15 +7,14 @@
//
import Foundation
import Result
import libgit2
import Clibgit2
public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
/// Helper function used as the libgit2 progress callback in git_checkout_options.
/// This is a function with a type signature of git_checkout_progress_cb.
private func checkoutProgressCallback(path: UnsafePointer<Int8>?, completedSteps: Int, totalSteps: Int,
payload: UnsafeMutableRawPointer?) -> Void {
payload: UnsafeMutableRawPointer?) {
if let payload = payload {
let buffer = payload.assumingMemoryBound(to: CheckoutProgressBlock.self)
let block: CheckoutProgressBlock
@@ -23,7 +22,7 @@ private func checkoutProgressCallback(path: UnsafePointer<Int8>?, completedSteps
block = buffer.pointee
} else {
block = buffer.move()
buffer.deallocate(capacity: 1)
buffer.deallocate()
}
block(path.flatMap(String.init(validatingUTF8:)), completedSteps, totalSteps)
}
@@ -40,7 +39,7 @@ private func checkoutOptions(strategy: CheckoutStrategy,
let pointer = UnsafeMutablePointer<git_checkout_options>.allocate(capacity: 1)
git_checkout_init_options(pointer, UInt32(GIT_CHECKOUT_OPTIONS_VERSION))
var options = pointer.move()
pointer.deallocate(capacity: 1)
pointer.deallocate()
options.checkout_strategy = strategy.gitCheckoutStrategy.rawValue
@@ -60,7 +59,7 @@ private func fetchOptions(credentials: Credentials) -> git_fetch_options {
var options = pointer.move()
pointer.deallocate(capacity: 1)
pointer.deallocate()
options.callbacks.payload = credentials.toPointer()
options.callbacks.credentials = credentialsCallback
@@ -75,7 +74,7 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
var options = pointer.move()
pointer.deallocate(capacity: 1)
pointer.deallocate()
options.bare = bare ? 1 : 0
@@ -95,16 +94,35 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
}
/// A git repository.
final public class Repository {
public final class Repository {
// MARK: - Creating Repositories
/// Create a new repository at the given URL.
///
/// URL - The URL of the repository.
///
/// Returns a `Result` with a `Repository` or an error.
public class func create(at url: URL) -> Result<Repository, NSError> {
var pointer: OpaquePointer? = nil
let result = url.withUnsafeFileSystemRepresentation {
git_repository_init(&pointer, $0, 0)
}
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_init"))
}
let repository = Repository(pointer!)
return Result.success(repository)
}
/// Load the repository at the given URL.
///
/// URL - The URL of the repository.
///
/// Returns a `Result` with a `Repository` or an error.
class public func at(_ url: URL) -> Result<Repository, NSError> {
public class func at(_ url: URL) -> Result<Repository, NSError> {
var pointer: OpaquePointer? = nil
let result = url.withUnsafeFileSystemRepresentation {
git_repository_open(&pointer, $0)
@@ -129,26 +147,27 @@ final public class Repository {
/// checkoutProgress - A block that's called with the progress of the checkout.
///
/// Returns a `Result` with a `Repository` or an error.
class public func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
credentials: Credentials = .Default(), checkoutStrategy: CheckoutStrategy = .Safe,
public class func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
credentials: Credentials = .default, checkoutStrategy: CheckoutStrategy = .Safe,
checkoutProgress: CheckoutProgressBlock? = nil) -> Result<Repository, NSError> {
var options = cloneOptions(
bare: bare, localClone: localClone,
fetchOptions: fetchOptions(credentials: credentials),
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
var options = cloneOptions(
bare: bare,
localClone: localClone,
fetchOptions: fetchOptions(credentials: credentials),
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
var pointer: OpaquePointer? = nil
let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString
let result = localURL.withUnsafeFileSystemRepresentation { localPath in
git_clone(&pointer, remoteURLString, localPath, &options)
}
var pointer: OpaquePointer? = nil
let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString
let result = localURL.withUnsafeFileSystemRepresentation { localPath in
git_clone(&pointer, remoteURLString, localPath, &options)
}
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_clone"))
}
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_clone"))
}
let repository = Repository(pointer!)
return Result.success(repository)
let repository = Repository(pointer!)
return Result.success(repository)
}
// MARK: - Initializers
@@ -187,7 +206,7 @@ final public class Repository {
///
/// Returns the result of calling `transform` or an error if the object
/// cannot be loaded.
private func withGitObject<T>(_ oid: OID, type: git_otype,
private func withGitObject<T>(_ oid: OID, type: git_object_t,
transform: (OpaquePointer) -> Result<T, NSError>) -> Result<T, NSError> {
var pointer: OpaquePointer? = nil
var oid = oid.oid
@@ -202,17 +221,40 @@ final public class Repository {
return value
}
private func withGitObject<T>(_ oid: OID, type: git_otype, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
private func withGitObject<T>(_ oid: OID, type: git_object_t, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
return withGitObject(oid, type: type) { Result.success(transform($0)) }
}
private func withGitObjects<T>(_ oids: [OID], type: git_object_t, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
var pointers = [OpaquePointer]()
defer {
for pointer in pointers {
git_object_free(pointer)
}
}
for oid in oids {
var pointer: OpaquePointer? = nil
var oid = oid.oid
let result = git_object_lookup(&pointer, self.pointer, &oid, type)
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_object_lookup"))
}
pointers.append(pointer!)
}
return transform(pointers)
}
/// Loads the object with the given OID.
///
/// oid - The OID of the blob to look up.
///
/// Returns a `Blob`, `Commit`, `Tag`, or `Tree` if one exists, or an error.
public func object(_ oid: OID) -> Result<ObjectType, NSError> {
return withGitObject(oid, type: GIT_OBJ_ANY) { object in
return withGitObject(oid, type: GIT_OBJECT_ANY) { object in
let type = git_object_type(object)
if type == Blob.type {
return Result.success(Blob(object))
@@ -228,7 +270,7 @@ final public class Repository {
domain: "org.libgit2.SwiftGit2",
code: 1,
userInfo: [
NSLocalizedDescriptionKey: "Unrecognized git_otype '\(type)' for oid '\(oid)'.",
NSLocalizedDescriptionKey: "Unrecognized git_object_t '\(type)' for oid '\(oid)'.",
]
)
return Result.failure(error)
@@ -241,7 +283,7 @@ final public class Repository {
///
/// Returns the blob if it exists, or an error.
public func blob(_ oid: OID) -> Result<Blob, NSError> {
return withGitObject(oid, type: GIT_OBJ_BLOB) { Blob($0) }
return withGitObject(oid, type: GIT_OBJECT_BLOB) { Blob($0) }
}
/// Loads the commit with the given OID.
@@ -250,7 +292,7 @@ final public class Repository {
///
/// Returns the commit if it exists, or an error.
public func commit(_ oid: OID) -> Result<Commit, NSError> {
return withGitObject(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { Commit($0) }
}
/// Loads the tag with the given OID.
@@ -259,7 +301,7 @@ final public class Repository {
///
/// Returns the tag if it exists, or an error.
public func tag(_ oid: OID) -> Result<Tag, NSError> {
return withGitObject(oid, type: GIT_OBJ_TAG) { Tag($0) }
return withGitObject(oid, type: GIT_OBJECT_TAG) { Tag($0) }
}
/// Loads the tree with the given OID.
@@ -268,7 +310,7 @@ final public class Repository {
///
/// Returns the tree if it exists, or an error.
public func tree(_ oid: OID) -> Result<Tree, NSError> {
return withGitObject(oid, type: GIT_OBJ_TREE) { Tree($0) }
return withGitObject(oid, type: GIT_OBJECT_TREE) { Tree($0) }
}
/// Loads the referenced object from the pointer.
@@ -287,13 +329,13 @@ final public class Repository {
/// Returns the object if it exists, or an error.
public func object(from pointer: Pointer) -> Result<ObjectType, NSError> {
switch pointer {
case let .Blob(oid):
case let .blob(oid):
return blob(oid).map { $0 as ObjectType }
case let .Commit(oid):
case let .commit(oid):
return commit(oid).map { $0 as ObjectType }
case let .Tag(oid):
case let .tag(oid):
return tag(oid).map { $0 as ObjectType }
case let .Tree(oid):
case let .tree(oid):
return tree(oid).map { $0 as ObjectType }
}
}
@@ -308,7 +350,7 @@ final public class Repository {
let result = git_remote_list(pointer, self.pointer)
guard result == GIT_OK.rawValue else {
pointer.deallocate(capacity: 1)
pointer.deallocate()
return Result.failure(NSError(gitError: result, pointOfFailure: "git_remote_list"))
}
@@ -317,13 +359,22 @@ final public class Repository {
return self.remote(named: $0)
}
git_strarray_free(pointer)
pointer.deallocate(capacity: 1)
pointer.deallocate()
let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error }
if let error = error {
return Result.failure(error)
return remotes.aggregateResult()
}
private func remoteLookup<A>(named name: String, _ callback: (Result<OpaquePointer, NSError>) -> A) -> A {
var pointer: OpaquePointer? = nil
defer { git_remote_free(pointer) }
let result = git_remote_lookup(&pointer, self.pointer, name)
guard result == GIT_OK.rawValue else {
return callback(.failure(NSError(gitError: result, pointOfFailure: "git_remote_lookup")))
}
return Result.success(remotes.map { $0.value! })
return callback(.success(pointer!))
}
/// Load a remote from the repository.
@@ -332,16 +383,25 @@ final public class Repository {
///
/// Returns the remote if it exists, or an error.
public func remote(named name: String) -> Result<Remote, NSError> {
var pointer: OpaquePointer? = nil
let result = git_remote_lookup(&pointer, self.pointer, name)
return remoteLookup(named: name) { $0.map(Remote.init) }
}
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_remote_lookup"))
/// Download new data and update tips
public func fetch(_ remote: Remote) -> Result<(), NSError> {
return remoteLookup(named: remote.name) { remote in
remote.flatMap { pointer in
var opts = git_fetch_options()
let resultInit = git_fetch_init_options(&opts, UInt32(GIT_FETCH_OPTIONS_VERSION))
assert(resultInit == GIT_OK.rawValue)
let result = git_remote_fetch(pointer, nil, &opts, nil)
guard result == GIT_OK.rawValue else {
let err = NSError(gitError: result, pointOfFailure: "git_remote_fetch")
return .failure(err)
}
return .success(())
}
}
let value = Remote(pointer!)
git_remote_free(pointer)
return Result.success(value)
}
// MARK: - Reference Lookups
@@ -352,7 +412,7 @@ final public class Repository {
let result = git_reference_list(pointer, self.pointer)
guard result == GIT_OK.rawValue else {
pointer.deallocate(capacity: 1)
pointer.deallocate()
return Result.failure(NSError(gitError: result, pointOfFailure: "git_reference_list"))
}
@@ -365,13 +425,9 @@ final public class Repository {
self.reference(named: $0)
}
git_strarray_free(pointer)
pointer.deallocate(capacity: 1)
pointer.deallocate()
let error = references.reduce(nil) { $0 == nil ? $0 : $1.error }
if let error = error {
return Result.failure(error)
}
return Result.success(references.map { $0.value! })
return references.aggregateResult()
}
/// Load the reference with the given long name (e.g. "refs/heads/master")
@@ -457,7 +513,7 @@ final public class Repository {
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_set_head"))
}
return Result.success()
return Result.success(())
}
/// Set HEAD to the given reference.
@@ -469,7 +525,7 @@ final public class Repository {
guard result == GIT_OK.rawValue else {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_repository_set_head"))
}
return Result.success()
return Result.success(())
}
/// Check out HEAD.
@@ -485,7 +541,7 @@ final public class Repository {
return Result.failure(NSError(gitError: result, pointOfFailure: "git_checkout_head"))
}
return Result.success()
return Result.success(())
}
/// Check out the given OID.
@@ -509,4 +565,398 @@ final public class Repository {
progress: CheckoutProgressBlock? = nil) -> Result<(), NSError> {
return setHEAD(reference).flatMap { self.checkout(strategy: strategy, progress: progress) }
}
/// Load all commits in the specified branch in topological & time order descending
///
/// :param: branch The branch to get all commits from
/// :returns: Returns a result with array of branches or the error that occurred
public func commits(in branch: Branch) -> CommitIterator {
let iterator = CommitIterator(repo: self, root: branch.oid.oid)
return iterator
}
/// Get the index for the repo. The caller is responsible for freeing the index.
func unsafeIndex() -> Result<OpaquePointer, NSError> {
var index: OpaquePointer? = nil
let result = git_repository_index(&index, self.pointer)
guard result == GIT_OK.rawValue && index != nil else {
let err = NSError(gitError: result, pointOfFailure: "git_repository_index")
return .failure(err)
}
return .success(index!)
}
/// Stage the file(s) under the specified path.
public func add(path: String) -> Result<(), NSError> {
var dirPointer = UnsafeMutablePointer<Int8>(mutating: (path as NSString).utf8String)
var paths = withUnsafeMutablePointer(to: &dirPointer) {
git_strarray(strings: $0, count: 1)
}
return unsafeIndex().flatMap { index in
defer { git_index_free(index) }
let addResult = git_index_add_all(index, &paths, 0, nil, nil)
guard addResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: addResult, pointOfFailure: "git_index_add_all"))
}
// write index to disk
let writeResult = git_index_write(index)
guard writeResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: writeResult, pointOfFailure: "git_index_write"))
}
return .success(())
}
}
/// Perform a commit with arbitrary numbers of parent commits.
public func commit(
tree treeOID: OID,
parents: [Commit],
message: String,
signature: Signature
) -> Result<Commit, NSError> {
// create commit signature
return signature.makeUnsafeSignature().flatMap { signature in
defer { git_signature_free(signature) }
var tree: OpaquePointer? = nil
var treeOIDCopy = treeOID.oid
let lookupResult = git_tree_lookup(&tree, self.pointer, &treeOIDCopy)
guard lookupResult == GIT_OK.rawValue else {
let err = NSError(gitError: lookupResult, pointOfFailure: "git_tree_lookup")
return .failure(err)
}
defer { git_tree_free(tree) }
var msgBuf = git_buf()
git_message_prettify(&msgBuf, message, 0, /* ascii for # */ 35)
defer { git_buf_free(&msgBuf) }
// libgit2 expects a C-like array of parent git_commit pointer
var parentGitCommits: [OpaquePointer?] = []
defer {
for commit in parentGitCommits {
git_commit_free(commit)
}
}
for parentCommit in parents {
var parent: OpaquePointer? = nil
var oid = parentCommit.oid.oid
let lookupResult = git_commit_lookup(&parent, self.pointer, &oid)
guard lookupResult == GIT_OK.rawValue else {
let err = NSError(gitError: lookupResult, pointOfFailure: "git_commit_lookup")
return .failure(err)
}
parentGitCommits.append(parent!)
}
let parentsContiguous = ContiguousArray(parentGitCommits)
return parentsContiguous.withUnsafeBufferPointer { unsafeBuffer in
var commitOID = git_oid()
let parentsPtr = UnsafeMutablePointer(mutating: unsafeBuffer.baseAddress)
let result = git_commit_create(
&commitOID,
self.pointer,
"HEAD",
signature,
signature,
"UTF-8",
msgBuf.ptr,
tree,
parents.count,
parentsPtr
)
guard result == GIT_OK.rawValue else {
return .failure(NSError(gitError: result, pointOfFailure: "git_commit_create"))
}
return commit(OID(commitOID))
}
}
}
/// Perform a commit of the staged files with the specified message and signature,
/// assuming we are not doing a merge and using the current tip as the parent.
public func commit(message: String, signature: Signature) -> Result<Commit, NSError> {
return unsafeIndex().flatMap { index in
defer { git_index_free(index) }
var treeOID = git_oid()
let treeResult = git_index_write_tree(&treeOID, index)
guard treeResult == GIT_OK.rawValue else {
let err = NSError(gitError: treeResult, pointOfFailure: "git_index_write_tree")
return .failure(err)
}
var parentID = git_oid()
let nameToIDResult = git_reference_name_to_id(&parentID, self.pointer, "HEAD")
guard nameToIDResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: nameToIDResult, pointOfFailure: "git_reference_name_to_id"))
}
return commit(OID(parentID)).flatMap { parentCommit in
commit(tree: OID(treeOID), parents: [parentCommit], message: message, signature: signature)
}
}
}
// MARK: - Diffs
public func diff(for commit: Commit) -> Result<Diff, NSError> {
guard !commit.parents.isEmpty else {
// Initial commit in a repository
return self.diff(from: nil, to: commit.oid)
}
var mergeDiff: OpaquePointer? = nil
defer { git_object_free(mergeDiff) }
for parent in commit.parents {
let error = self.diff(from: parent.oid, to: commit.oid) {
switch $0 {
case .failure(let error):
return error
case .success(let newDiff):
if mergeDiff == nil {
mergeDiff = newDiff
} else {
let mergeResult = git_diff_merge(mergeDiff, newDiff)
guard mergeResult == GIT_OK.rawValue else {
return NSError(gitError: mergeResult, pointOfFailure: "git_diff_merge")
}
}
return nil
}
}
if error != nil {
return Result<Diff, NSError>.failure(error!)
}
}
return .success(Diff(mergeDiff!))
}
private func diff(from oldCommitOid: OID?, to newCommitOid: OID?, transform: (Result<OpaquePointer, NSError>) -> NSError?) -> NSError? {
assert(oldCommitOid != nil || newCommitOid != nil, "It is an error to pass nil for both the oldOid and newOid")
var oldTree: OpaquePointer? = nil
defer { git_object_free(oldTree) }
if let oid = oldCommitOid {
switch unsafeTreeForCommitId(oid) {
case .failure(let error):
return transform(.failure(error))
case .success(let value):
oldTree = value
}
}
var newTree: OpaquePointer? = nil
defer { git_object_free(newTree) }
if let oid = newCommitOid {
switch unsafeTreeForCommitId(oid) {
case .failure(let error):
return transform(.failure(error))
case .success(let value):
newTree = value
}
}
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
oldTree,
newTree,
nil)
guard diffResult == GIT_OK.rawValue else {
return transform(.failure(NSError(gitError: diffResult,
pointOfFailure: "git_diff_tree_to_tree")))
}
return transform(Result<OpaquePointer, NSError>.success(diff!))
}
/// Memory safe
private func diff(from oldCommitOid: OID?, to newCommitOid: OID?) -> Result<Diff, NSError> {
assert(oldCommitOid != nil || newCommitOid != nil, "It is an error to pass nil for both the oldOid and newOid")
var oldTree: Tree? = nil
if let oldCommitOid = oldCommitOid {
switch safeTreeForCommitId(oldCommitOid) {
case .failure(let error):
return .failure(error)
case .success(let value):
oldTree = value
}
}
var newTree: Tree? = nil
if let newCommitOid = newCommitOid {
switch safeTreeForCommitId(newCommitOid) {
case .failure(let error):
return .failure(error)
case .success(let value):
newTree = value
}
}
if oldTree != nil && newTree != nil {
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJECT_TREE) { objects in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
objects[0],
objects[1],
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
}
} else if let tree = oldTree {
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
tree,
nil,
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
})
} else if let tree = newTree {
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
var diff: OpaquePointer? = nil
let diffResult = git_diff_tree_to_tree(&diff,
self.pointer,
nil,
tree,
nil)
return processTreeToTreeDiff(diffResult, diff: diff)
})
}
return .failure(NSError(gitError: -1, pointOfFailure: "diff(from: to:)"))
}
private func processTreeToTreeDiff(_ diffResult: Int32, diff: OpaquePointer?) -> Result<Diff, NSError> {
guard diffResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: diffResult,
pointOfFailure: "git_diff_tree_to_tree"))
}
let diffObj = Diff(diff!)
git_diff_free(diff)
return .success(diffObj)
}
private func processDiffDeltas(_ diffResult: OpaquePointer) -> Result<[Diff.Delta], NSError> {
var returnDict = [Diff.Delta]()
let count = git_diff_num_deltas(diffResult)
for i in 0..<count {
let delta = git_diff_get_delta(diffResult, i)
let gitDiffDelta = Diff.Delta((delta?.pointee)!)
returnDict.append(gitDiffDelta)
}
let result = Result<[Diff.Delta], NSError>.success(returnDict)
return result
}
private func safeTreeForCommitId(_ oid: OID) -> Result<Tree, NSError> {
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { commit in
let treeId = git_commit_tree_id(commit)
return tree(OID(treeId!.pointee))
}
}
/// Caller responsible to free returned tree with git_object_free
private func unsafeTreeForCommitId(_ oid: OID) -> Result<OpaquePointer, NSError> {
var commit: OpaquePointer? = nil
var oid = oid.oid
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJECT_COMMIT)
guard commitResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: commitResult, pointOfFailure: "git_object_lookup"))
}
var tree: OpaquePointer? = nil
let treeId = git_commit_tree_id(commit)
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJECT_TREE)
git_object_free(commit)
guard treeResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: treeResult, pointOfFailure: "git_object_lookup"))
}
return Result<OpaquePointer, NSError>.success(tree!)
}
// MARK: - Status
public func status(options: StatusOptions = [.includeUntracked]) -> Result<[StatusEntry], NSError> {
var returnArray = [StatusEntry]()
// Do this because GIT_STATUS_OPTIONS_INIT is unavailable in swift
let pointer = UnsafeMutablePointer<git_status_options>.allocate(capacity: 1)
let optionsResult = git_status_init_options(pointer, UInt32(GIT_STATUS_OPTIONS_VERSION))
guard optionsResult == GIT_OK.rawValue else {
return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options"))
}
var listOptions = pointer.move()
listOptions.flags = options.rawValue
pointer.deallocate()
var unsafeStatus: OpaquePointer? = nil
defer { git_status_list_free(unsafeStatus) }
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &listOptions)
guard statusResult == GIT_OK.rawValue, let unwrapStatusResult = unsafeStatus else {
return .failure(NSError(gitError: statusResult, pointOfFailure: "git_status_list_new"))
}
let count = git_status_list_entrycount(unwrapStatusResult)
for i in 0..<count {
let s = git_status_byindex(unwrapStatusResult, i)
if s?.pointee.status.rawValue == GIT_STATUS_CURRENT.rawValue {
continue
}
let statusEntry = StatusEntry(from: s!.pointee)
returnArray.append(statusEntry)
}
return .success(returnArray)
}
// MARK: - Validity/Existence Check
/// - returns: `.success(true)` iff there is a git repository at `url`,
/// `.success(false)` if there isn't,
/// and a `.failure` if there's been an error.
public static func isValid(url: URL) -> Result<Bool, NSError> {
var pointer: OpaquePointer?
let result = url.withUnsafeFileSystemRepresentation {
git_repository_open_ext(&pointer, $0, GIT_REPOSITORY_OPEN_NO_SEARCH.rawValue, nil)
}
switch result {
case GIT_ENOTFOUND.rawValue:
return .success(false)
case GIT_OK.rawValue:
return .success(true)
default:
return .failure(NSError(gitError: result, pointOfFailure: "git_repository_open_ext"))
}
}
}
private extension Array {
func aggregateResult<Value, Error>() -> Result<[Value], Error> where Element == Result<Value, Error> {
var values: [Value] = []
for result in self {
switch result {
case .success(let value):
values.append(value)
case .failure(let error):
return .failure(error)
}
}
return .success(values)
}
}
+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
Binary file not shown.
+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())
+13 -14
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,11 +169,11 @@ class CommitSpec: QuickSpec {
}
class TreeEntrySpec: QuickSpec {
override func spec() {
override class func spec() {
describe("Tree.Entry(attributes:object:name:)") {
it("should set its properties") {
let attributes = Int32(GIT_FILEMODE_BLOB.rawValue)
let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
let object = Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
let name = "README.md"
let entry = Tree.Entry(attributes: attributes, object: object, name: name)
@@ -191,7 +190,7 @@ class TreeEntrySpec: QuickSpec {
let entry = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.rawValue)))
expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
expect(entry.object).to(equal(Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
expect(entry.name).to(equal("README.md"))
}
}
@@ -231,7 +230,7 @@ class TreeEntrySpec: QuickSpec {
}
class TreeSpec: QuickSpec {
override func spec() {
override class func spec() {
describe("Tree(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -240,7 +239,7 @@ class TreeSpec: QuickSpec {
let tree = repo.withGitObject(oid) { Tree($0) }
let entries = [
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue),
object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
object: .blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
name: "README.md"),
]
expect(tree.entries).to(equal(entries))
@@ -282,7 +281,7 @@ class TreeSpec: QuickSpec {
}
class BlobSpec: QuickSpec {
override func spec() {
override class func spec() {
describe("Blob(pointer)") {
it("should initialize its properties") {
let repo = Fixtures.simpleRepository
@@ -331,7 +330,7 @@ class BlobSpec: QuickSpec {
}
class TagSpec: QuickSpec {
override func spec() {
override class func spec() {
describe("Tag(pointer)") {
it("should set its properties") {
let repo = Fixtures.simpleRepository
@@ -341,7 +340,7 @@ class TagSpec: QuickSpec {
let tagger = repo.withGitObject(oid) { Signature(git_tag_tagger($0).pointee) }
expect(tag.oid).to(equal(oid))
expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
expect(tag.target).to(equal(Pointer.commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
expect(tag.name).to(equal("tag-1"))
expect(tag.tagger).to(equal(tagger))
expect(tag.message).to(equal("tag-1\n"))
+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
+450 -72
View File
@@ -6,14 +6,14 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Result
import SwiftGit2
import Nimble
import Quick
import Guanaco
class RepositorySpec: QuickSpec {
override func spec() {
// swiftlint:disable cyclomatic_complexity
class RepositorySpec: FixturesSpec {
override class func spec() {
describe("Repository.Type.at(_:)") {
it("should work if the repo exists") {
let repo = Fixtures.simpleRepository
@@ -23,10 +23,61 @@ class RepositorySpec: QuickSpec {
it("should fail if the repo doesn't exist") {
let url = URL(fileURLWithPath: "blah")
let result = Repository.at(url)
expect(result).to(haveFailed(beAnError(
domain: equal(libGit2ErrorDomain),
localizedDescription: match("Failed to resolve path")
)))
expect(result.error?.domain) == libGit2ErrorDomain
expect(result.error?.localizedDescription).to(match("failed to resolve path"))
}
}
describe("Repository.Type.isValid(url:)") {
it("should return true if the repo exists") {
guard let repositoryURL = Fixtures.simpleRepository.directoryURL else {
fail("Fixture setup broken: Repository does not exist"); return
}
let result = Repository.isValid(url: repositoryURL)
expect(result.error).to(beNil())
if case .success(let isValid) = result {
expect(isValid).to(beTruthy())
}
}
it("should return false if the directory does not contain a repo") {
let tmpURL = URL(fileURLWithPath: "/dev/null")
let result = Repository.isValid(url: tmpURL)
expect(result.error).to(beNil())
if case .success(let isValid) = result {
expect(isValid).to(beFalsy())
}
}
it("should return error if .git is not readable") {
let localURL = self.temporaryURL(forPurpose: "git-isValid-unreadable").appendingPathComponent(".git")
let nonReadablePermissions: [FileAttributeKey: Any] = [.posixPermissions: 0o077]
try! FileManager.default.createDirectory(
at: localURL,
withIntermediateDirectories: true,
attributes: nonReadablePermissions)
let result = Repository.isValid(url: localURL)
expect(result.value).to(beNil())
expect(result.error).notTo(beNil())
}
}
describe("Repository.Type.create(at:)") {
it("should create a new repo at the specified location") {
let localURL = self.temporaryURL(forPurpose: "local-create")
let result = Repository.create(at: localURL)
expect(result.error).to(beNil())
if case .success(let clonedRepo) = result {
expect(clonedRepo.directoryURL).notTo(beNil())
}
}
}
@@ -36,7 +87,7 @@ class RepositorySpec: QuickSpec {
let localURL = self.temporaryURL(forPurpose: "local-clone")
let result = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true)
expect(result).to(haveSucceeded())
expect(result.error).to(beNil())
if case .success(let clonedRepo) = result {
expect(clonedRepo.directoryURL).notTo(beNil())
@@ -48,7 +99,7 @@ class RepositorySpec: QuickSpec {
let localURL = self.temporaryURL(forPurpose: "bare-clone")
let result = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true, bare: true)
expect(result).to(haveSucceeded())
expect(result.error).to(beNil())
if case .success(let clonedRepo) = result {
expect(clonedRepo.directoryURL).to(beNil())
@@ -60,11 +111,11 @@ class RepositorySpec: QuickSpec {
let localURL = self.temporaryURL(forPurpose: "valid-remote-clone")
let cloneResult = Repository.clone(from: remoteRepo.directoryURL!, to: localURL, localClone: true)
expect(cloneResult).to(haveSucceeded())
expect(cloneResult.error).to(beNil())
if case .success(let clonedRepo) = cloneResult {
let remoteResult = clonedRepo.remote(named: "origin")
expect(remoteResult).to(haveSucceeded())
expect(remoteResult.error).to(beNil())
if case .success(let remote) = remoteResult {
expect(remote.URL).to(equal(remoteRepo.directoryURL?.absoluteString))
@@ -77,11 +128,11 @@ class RepositorySpec: QuickSpec {
let localURL = self.temporaryURL(forPurpose: "public-remote-clone")
let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL)
expect(cloneResult).to(haveSucceeded())
expect(cloneResult.error).to(beNil())
if case .success(let clonedRepo) = cloneResult {
let remoteResult = clonedRepo.remote(named: "origin")
expect(remoteResult).to(haveSucceeded())
expect(remoteResult.error).to(beNil())
if case .success(let remote) = remoteResult {
expect(remote.URL).to(equal(remoteRepoURL?.absoluteString))
@@ -92,26 +143,26 @@ class RepositorySpec: QuickSpec {
let env = ProcessInfo.processInfo.environment
if let privateRepo = env["SG2TestPrivateRepo"],
let gitUsername = env["SG2TestUsername"],
let publicKey = env["SG2TestPublicKey"],
let privateKey = env["SG2TestPrivateKey"],
let passphrase = env["SG2TestPassphrase"] {
let gitUsername = env["SG2TestUsername"],
let publicKey = env["SG2TestPublicKey"],
let privateKey = env["SG2TestPrivateKey"],
let passphrase = env["SG2TestPassphrase"] {
it("should be able to clone a remote repository requiring credentials") {
let remoteRepoURL = URL(string: privateRepo)
let localURL = self.temporaryURL(forPurpose: "private-remote-clone")
let credentials = Credentials.SSHMemory(username: gitUsername,
let credentials = Credentials.sshMemory(username: gitUsername,
publicKey: publicKey,
privateKey: privateKey,
passphrase: passphrase)
let cloneResult = Repository.clone(from: remoteRepoURL!, to: localURL, credentials: credentials)
expect(cloneResult).to(haveSucceeded())
expect(cloneResult.error).to(beNil())
if case .success(let clonedRepo) = cloneResult {
let remoteResult = clonedRepo.remote(named: "origin")
expect(remoteResult).to(haveSucceeded())
expect(remoteResult.error).to(beNil())
if case .success(let remote) = remoteResult {
expect(remote.URL).to(equal(remoteRepoURL?.absoluteString))
@@ -127,7 +178,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let result = repo.blob(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
expect(result.map { $0.oid }.value) == oid
}
it("should error if the blob doesn't exist") {
@@ -135,7 +186,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.blob(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
it("should error if the oid doesn't point to a blob") {
@@ -144,7 +195,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.blob(oid)
expect(result).to(haveFailed())
expect(result.error).notTo(beNil())
}
}
@@ -154,7 +205,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.commit(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
expect(result.map { $0.oid }.value) == oid
}
it("should error if the commit doesn't exist") {
@@ -162,7 +213,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.commit(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
it("should error if the oid doesn't point to a commit") {
@@ -171,7 +222,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.commit(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -181,7 +232,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let result = repo.tag(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
expect(result.map { $0.oid }.value) == oid
}
it("should error if the tag doesn't exist") {
@@ -189,7 +240,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.tag(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
it("should error if the oid doesn't point to a tag") {
@@ -198,7 +249,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.tag(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -208,7 +259,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.tree(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
expect(result.map { $0.oid }.value) == oid
}
it("should error if the tree doesn't exist") {
@@ -216,7 +267,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.tree(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
it("should error if the oid doesn't point to a tree") {
@@ -225,7 +276,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.tree(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -235,7 +286,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob = repo.blob(oid).value
let result = repo.object(oid)
expect(result.map { $0 as! Blob }).to(haveSucceeded(equal(blob)))
expect(result.map { $0 as! Blob }.value) == blob
}
it("should work with a commit") {
@@ -243,7 +294,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit = repo.commit(oid).value
let result = repo.object(oid)
expect(result.map { $0 as! Commit }).to(haveSucceeded(equal(commit)))
expect(result.map { $0 as! Commit }.value) == commit
}
it("should work with a tag") {
@@ -251,7 +302,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag = repo.tag(oid).value
let result = repo.object(oid)
expect(result.map { $0 as! Tag }).to(haveSucceeded(equal(tag)))
expect(result.map { $0 as! Tag }.value) == tag
}
it("should work with a tree") {
@@ -259,14 +310,14 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let tree = repo.tree(oid).value
let result = repo.object(oid)
expect(result.map { $0 as! Tree }).to(haveSucceeded(equal(tree)))
expect(result.map { $0 as! Tree }.value) == tree
}
it("should error if there's no object with that oid") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.object(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -277,7 +328,7 @@ class RepositorySpec: QuickSpec {
let pointer = PointerTo<Commit>(oid)
let commit = repo.commit(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(commit)))
expect(repo.object(from: pointer).value) == commit
}
it("should work with trees") {
@@ -286,7 +337,7 @@ class RepositorySpec: QuickSpec {
let pointer = PointerTo<Tree>(oid)
let tree = repo.tree(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tree)))
expect(repo.object(from: pointer).value) == tree
}
it("should work with blobs") {
@@ -295,7 +346,7 @@ class RepositorySpec: QuickSpec {
let pointer = PointerTo<Blob>(oid)
let blob = repo.blob(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(blob)))
expect(repo.object(from: pointer).value) == blob
}
it("should work with tags") {
@@ -304,7 +355,7 @@ class RepositorySpec: QuickSpec {
let pointer = PointerTo<Tag>(oid)
let tag = repo.tag(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tag)))
expect(repo.object(from: pointer).value) == tag
}
}
@@ -313,40 +364,40 @@ class RepositorySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let pointer = Pointer.Commit(oid)
let pointer = Pointer.commit(oid)
let commit = repo.commit(oid).value!
let result = repo.object(from: pointer).map { $0 as! Commit }
expect(result).to(haveSucceeded(equal(commit)))
expect(result.value) == commit
}
it("should work with trees") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let pointer = Pointer.Tree(oid)
let pointer = Pointer.tree(oid)
let tree = repo.tree(oid).value!
let result = repo.object(from: pointer).map { $0 as! Tree }
expect(result).to(haveSucceeded(equal(tree)))
expect(result.value) == tree
}
it("should work with blobs") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let pointer = Pointer.Blob(oid)
let pointer = Pointer.blob(oid)
let blob = repo.blob(oid).value!
let result = repo.object(from: pointer).map { $0 as! Blob }
expect(result).to(haveSucceeded(equal(blob)))
expect(result.value) == blob
}
it("should work with tags") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let pointer = Pointer.Tag(oid)
let pointer = Pointer.tag(oid)
let tag = repo.tag(oid).value!
let result = repo.object(from: pointer).map { $0 as! Tag }
expect(result).to(haveSucceeded(equal(tag)))
expect(result.value) == tag
}
}
@@ -354,15 +405,15 @@ class RepositorySpec: QuickSpec {
it("should return an empty list if there are no remotes") {
let repo = Fixtures.simpleRepository
let result = repo.allRemotes()
expect(result).to(haveSucceeded(beEmpty()))
expect(result.value) == []
}
it("should return all the remotes") {
let repo = Fixtures.mantleRepository
let remotes = repo.allRemotes()
let names = remotes.map { $0.map { $0.name } }
expect(remotes.map { $0.count }).to(haveSucceeded(equal(2)))
expect(names).to(haveSucceeded(contain("origin", "upstream")))
expect(remotes.map { $0.count }.value) == 2
expect(names.value).to(contain("origin", "upstream"))
}
}
@@ -370,13 +421,13 @@ class RepositorySpec: QuickSpec {
it("should return the remote if it exists") {
let repo = Fixtures.mantleRepository
let result = repo.remote(named: "upstream")
expect(result.map { $0.name }).to(haveSucceeded(equal("upstream")))
expect(result.map { $0.name }.value) == "upstream"
}
it("should error if the remote doesn't exist") {
let repo = Fixtures.simpleRepository
let result = repo.remote(named: "nonexistent")
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -384,14 +435,14 @@ class RepositorySpec: QuickSpec {
it("should return a local branch if it exists") {
let name = "refs/heads/master"
let result = Fixtures.simpleRepository.reference(named: name)
expect(result.map { $0.longName }).to(haveSucceeded(equal(name)))
expect(result.map { $0.longName }.value) == name
expect(result.value as? Branch).notTo(beNil())
}
it("should return a remote branch if it exists") {
let name = "refs/remotes/upstream/master"
let result = Fixtures.mantleRepository.reference(named: name)
expect(result.map { $0.longName }).to(haveSucceeded(equal(name)))
expect(result.map { $0.longName }.value) == name
expect(result.value as? Branch).notTo(beNil())
}
@@ -410,7 +461,7 @@ class RepositorySpec: QuickSpec {
it("should error if the reference doesn't exist") {
let result = Fixtures.simpleRepository.reference(named: "refs/heads/nonexistent")
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -450,7 +501,7 @@ class RepositorySpec: QuickSpec {
]
let expected = expectedNames.map { repo.remoteBranch(named: $0).value! }
let actual = repo.remoteBranches().value!.sorted {
return $0.longName.characters.lexicographicallyPrecedes($1.longName.characters)
return $0.longName.lexicographicallyPrecedes($1.longName)
}
expect(actual).to(equal(expected))
expect(actual.map { $0.name }).to(equal(expectedNames))
@@ -465,7 +516,7 @@ class RepositorySpec: QuickSpec {
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.localBranch(named: "nonexistent")
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -477,7 +528,15 @@ class RepositorySpec: QuickSpec {
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.remoteBranch(named: "origin/nonexistent")
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
describe("Repository.fetch(_:)") {
it("should fetch the data") {
let repo = Fixtures.mantleRepository
let remote = repo.remote(named: "origin").value!
expect(repo.fetch(remote).value).toNot(beNil())
}
}
@@ -500,7 +559,7 @@ class RepositorySpec: QuickSpec {
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.tag(named: "nonexistent")
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
expect(result.error?.domain) == libGit2ErrorDomain
}
}
@@ -527,12 +586,12 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!
expect(repo.HEAD().value?.shortName).to(equal("master"))
expect(repo.setHEAD(oid)).to(haveSucceeded())
expect(repo.setHEAD(oid).error).to(beNil())
let HEAD = repo.HEAD().value
expect(HEAD?.longName).to(equal("HEAD"))
expect(HEAD?.oid).to(equal(oid))
expect(repo.setHEAD(repo.localBranch(named: "master").value!)).to(haveSucceeded())
expect(repo.setHEAD(repo.localBranch(named: "master").value!).error).to(beNil())
expect(repo.HEAD().value?.shortName).to(equal("master"))
}
}
@@ -544,10 +603,10 @@ class RepositorySpec: QuickSpec {
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
let branch = repo.localBranch(named: "another-branch").value!
expect(repo.setHEAD(branch)).to(haveSucceeded())
expect(repo.setHEAD(branch).error).to(beNil())
expect(repo.HEAD().value?.shortName).to(equal(branch.name))
expect(repo.setHEAD(oid)).to(haveSucceeded())
expect(repo.setHEAD(oid).error).to(beNil())
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
}
}
@@ -562,12 +621,12 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!
expect(repo.HEAD().value?.shortName).to(equal("master"))
expect(repo.checkout(oid, strategy: CheckoutStrategy.None)).to(haveSucceeded())
expect(repo.checkout(oid, strategy: CheckoutStrategy.None).error).to(beNil())
let HEAD = repo.HEAD().value
expect(HEAD?.longName).to(equal("HEAD"))
expect(HEAD?.oid).to(equal(oid))
expect(repo.checkout(repo.localBranch(named: "master").value!, strategy: CheckoutStrategy.None)).to(haveSucceeded())
expect(repo.checkout(repo.localBranch(named: "master").value!, strategy: CheckoutStrategy.None).error).to(beNil())
expect(repo.HEAD().value?.shortName).to(equal("master"))
}
@@ -578,7 +637,7 @@ class RepositorySpec: QuickSpec {
expect(repo.checkout(oid, strategy: .None, progress: { (_, completedSteps, totalSteps) -> Void in
expect(completedSteps).to(beLessThanOrEqualTo(totalSteps))
})).to(haveSucceeded())
}).error).to(beNil())
let HEAD = repo.HEAD().value
expect(HEAD?.longName).to(equal("HEAD"))
@@ -593,16 +652,335 @@ class RepositorySpec: QuickSpec {
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
let branch = repo.localBranch(named: "another-branch").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None)).to(haveSucceeded())
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
expect(repo.HEAD().value?.shortName).to(equal(branch.name))
expect(repo.checkout(oid, strategy: CheckoutStrategy.None)).to(haveSucceeded())
expect(repo.checkout(oid, strategy: CheckoutStrategy.None).error).to(beNil())
expect(repo.HEAD().value?.longName).to(equal("HEAD"))
}
}
describe("Repository.allCommits(in:)") {
it("should return all (9) commits") {
let repo = Fixtures.simpleRepository
let branches = repo.localBranches().value!
let expectedCount = 9
let expectedMessages: [String] = [
"List branches in README\n",
"Create a README\n",
"Merge branch 'alphabetize'\n",
"Alphabetize branches\n",
"List new branches\n",
"List branches in README\n",
"Create a README\n",
"List branches in README\n",
"Create a README\n",
]
var commitMessages: [String] = []
for branch in branches {
for commit in repo.commits(in: branch) {
commitMessages.append(commit.value!.message)
}
}
expect(commitMessages.count).to(equal(expectedCount))
expect(commitMessages).to(equal(expectedMessages))
}
}
describe("Repository.add") {
it("Should add the modification under a path") {
let repo = Fixtures.simpleRepository
let branch = repo.localBranch(named: "master").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
// make a change to README
let readmeURL = repo.directoryURL!.appendingPathComponent("README.md")
let readmeData = try! Data(contentsOf: readmeURL)
defer { try! readmeData.write(to: readmeURL) }
try! "different".data(using: .utf8)?.write(to: readmeURL)
let status = repo.status()
expect(status.value?.count).to(equal(1))
expect(status.value!.first!.status).to(equal(.workTreeModified))
expect(repo.add(path: "README.md").error).to(beNil())
let newStatus = repo.status()
expect(newStatus.value?.count).to(equal(1))
expect(newStatus.value!.first!.status).to(equal(.indexModified))
}
it("Should add an untracked file under a path") {
let repo = Fixtures.simpleRepository
let branch = repo.localBranch(named: "master").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
// make a change to README
let untrackedURL = repo.directoryURL!.appendingPathComponent("untracked")
try! "different".data(using: .utf8)?.write(to: untrackedURL)
defer { try! FileManager.default.removeItem(at: untrackedURL) }
expect(repo.add(path: ".").error).to(beNil())
let newStatus = repo.status()
expect(newStatus.value?.count).to(equal(1))
expect(newStatus.value!.first!.status).to(equal(.indexNew))
}
}
describe("Repository.commit") {
it("Should perform a simple commit with specified signature") {
let repo = Fixtures.simpleRepository
let branch = repo.localBranch(named: "master").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
// make a change to README
let untrackedURL = repo.directoryURL!.appendingPathComponent("untrackedtest")
try! "different".data(using: .utf8)?.write(to: untrackedURL)
expect(repo.add(path: ".").error).to(beNil())
let signature = Signature(
name: "swiftgit2",
email: "foobar@example.com",
time: Date(timeIntervalSince1970: 1525200858),
timeZone: TimeZone(secondsFromGMT: 3600)!
)
let message = "Test Commit"
expect(repo.commit(message: message, signature: signature).error).to(beNil())
let updatedBranch = repo.localBranch(named: "master").value!
expect(repo.commits(in: updatedBranch).next()?.value?.author).to(equal(signature))
expect(repo.commits(in: updatedBranch).next()?.value?.committer).to(equal(signature))
expect(repo.commits(in: updatedBranch).next()?.value?.message).to(equal("\(message)\n"))
expect(repo.commits(in: updatedBranch).next()?.value?.oid.description)
.to(equal("7d6b2d7492f29aee48022387f96dbfe996d435fe"))
// should be clean now
let newStatus = repo.status()
expect(newStatus.value?.count).to(equal(0))
}
}
describe("Repository.status") {
it("Should accurately report status for repositories with no status") {
let expectedCount = 0
let repo = Fixtures.mantleRepository
let branch = repo.localBranch(named: "master").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
let status = repo.status()
expect(status.value?.count).to(equal(expectedCount))
}
it("Should accurately report status for repositories with status") {
let expectedCount = 6
let expectedNewFilePaths = [
"stage-file-1",
"stage-file-2",
"stage-file-3",
"stage-file-4",
"stage-file-5",
]
let expectedOldFilePaths = [
"stage-file-1",
"stage-file-2",
"stage-file-3",
"stage-file-4",
"stage-file-5",
]
let expectedUntrackedFiles = [
"unstaged-file",
]
let repoWithStatus = Fixtures.sharedInstance.repository(named: "repository-with-status")
let branchWithStatus = repoWithStatus.localBranch(named: "master").value!
expect(repoWithStatus.checkout(branchWithStatus, strategy: CheckoutStrategy.None).error).to(beNil())
let statuses = repoWithStatus.status().value!
var newFilePaths: [String] = []
for status in statuses {
if let path = status.headToIndex?.newFile?.path {
newFilePaths.append(path)
}
}
var oldFilePaths: [String] = []
for status in statuses {
if let path = status.headToIndex?.oldFile?.path {
oldFilePaths.append(path)
}
}
var newUntrackedFilePaths: [String] = []
for status in statuses {
if let path = status.indexToWorkDir?.newFile?.path {
newUntrackedFilePaths.append(path)
}
}
expect(statuses.count).to(equal(expectedCount))
expect(newFilePaths).to(equal(expectedNewFilePaths))
expect(oldFilePaths).to(equal(expectedOldFilePaths))
expect(newUntrackedFilePaths).to(equal(expectedUntrackedFiles))
}
}
describe("Repository.diff") {
it("Should have accurate delta information") {
let expectedCount = 13
let expectedNewFilePaths = [
".gitmodules",
"Cartfile",
"Cartfile.lock",
"Cartfile.private",
"Cartfile.resolved",
"Carthage.checkout/Nimble",
"Carthage.checkout/Quick",
"Carthage.checkout/xcconfigs",
"Carthage/Checkouts/Nimble",
"Carthage/Checkouts/Quick",
"Carthage/Checkouts/xcconfigs",
"Mantle.xcodeproj/project.pbxproj",
"Mantle.xcworkspace/contents.xcworkspacedata",
]
let expectedOldFilePaths = [
".gitmodules",
"Cartfile",
"Cartfile.lock",
"Cartfile.private",
"Cartfile.resolved",
"Carthage.checkout/Nimble",
"Carthage.checkout/Quick",
"Carthage.checkout/xcconfigs",
"Carthage/Checkouts/Nimble",
"Carthage/Checkouts/Quick",
"Carthage/Checkouts/xcconfigs",
"Mantle.xcodeproj/project.pbxproj",
"Mantle.xcworkspace/contents.xcworkspacedata",
]
let repo = Fixtures.mantleRepository
let branch = repo.localBranch(named: "master").value!
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil())
let head = repo.HEAD().value!
let commit = repo.object(head.oid).value! as! Commit
let diff = repo.diff(for: commit).value!
let newFilePaths = diff.deltas.map { $0.newFile!.path }
let oldFilePaths = diff.deltas.map { $0.oldFile!.path }
expect(diff.deltas.count).to(equal(expectedCount))
expect(newFilePaths).to(equal(expectedNewFilePaths))
expect(oldFilePaths).to(equal(expectedOldFilePaths))
}
it("Should handle initial commit well") {
let expectedCount = 2
let expectedNewFilePaths = [
".gitignore",
"README.md",
]
let expectedOldFilePaths = [
".gitignore",
"README.md",
]
let repo = Fixtures.mantleRepository
expect(repo.checkout(OID(string: "047b931bd7f5478340cef5885a6fff713005f4d6")!,
strategy: CheckoutStrategy.None).error).to(beNil())
let head = repo.HEAD().value!
let initalCommit = repo.object(head.oid).value! as! Commit
let diff = repo.diff(for: initalCommit).value!
var newFilePaths: [String] = []
for delta in diff.deltas {
newFilePaths.append((delta.newFile?.path)!)
}
var oldFilePaths: [String] = []
for delta in diff.deltas {
oldFilePaths.append((delta.oldFile?.path)!)
}
expect(diff.deltas.count).to(equal(expectedCount))
expect(newFilePaths).to(equal(expectedNewFilePaths))
expect(oldFilePaths).to(equal(expectedOldFilePaths))
}
it("Should handle merge commits well") {
let expectedCount = 20
let expectedNewFilePaths = [
"Mantle.xcodeproj/project.pbxproj",
"Mantle/MTLModel+NSCoding.m",
"Mantle/Mantle.h",
"Mantle/NSArray+MTLHigherOrderAdditions.h",
"Mantle/NSArray+MTLHigherOrderAdditions.m",
"Mantle/NSArray+MTLManipulationAdditions.m",
"Mantle/NSDictionary+MTLHigherOrderAdditions.h",
"Mantle/NSDictionary+MTLHigherOrderAdditions.m",
"Mantle/NSDictionary+MTLManipulationAdditions.m",
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.h",
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.m",
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.h",
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.m",
"Mantle/NSSet+MTLHigherOrderAdditions.h",
"Mantle/NSSet+MTLHigherOrderAdditions.m",
"Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.m",
"MantleTests/MTLHigherOrderAdditionsSpec.m",
"MantleTests/MTLNotificationCenterAdditionsSpec.m",
"MantleTests/MTLPredefinedTransformerAdditionsSpec.m",
"README.md",
]
let expectedOldFilePaths = [
"Mantle.xcodeproj/project.pbxproj",
"Mantle/MTLModel+NSCoding.m",
"Mantle/Mantle.h",
"Mantle/NSArray+MTLHigherOrderAdditions.h",
"Mantle/NSArray+MTLHigherOrderAdditions.m",
"Mantle/NSArray+MTLManipulationAdditions.m",
"Mantle/NSDictionary+MTLHigherOrderAdditions.h",
"Mantle/NSDictionary+MTLHigherOrderAdditions.m",
"Mantle/NSDictionary+MTLManipulationAdditions.m",
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.h",
"Mantle/NSNotificationCenter+MTLWeakReferenceAdditions.m",
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.h",
"Mantle/NSOrderedSet+MTLHigherOrderAdditions.m",
"Mantle/NSSet+MTLHigherOrderAdditions.h",
"Mantle/NSSet+MTLHigherOrderAdditions.m",
"Mantle/NSValueTransformer+MTLPredefinedTransformerAdditions.m",
"MantleTests/MTLHigherOrderAdditionsSpec.m",
"MantleTests/MTLNotificationCenterAdditionsSpec.m",
"MantleTests/MTLPredefinedTransformerAdditionsSpec.m",
"README.md",
]
let repo = Fixtures.mantleRepository
expect(repo.checkout(OID(string: "d0d9c13da5eb5f9e8cf2a9f1f6ca3bdbe975b57d")!,
strategy: CheckoutStrategy.None).error).to(beNil())
let head = repo.HEAD().value!
let initalCommit = repo.object(head.oid).value! as! Commit
let diff = repo.diff(for: initalCommit).value!
var newFilePaths: [String] = []
for delta in diff.deltas {
newFilePaths.append((delta.newFile?.path)!)
}
var oldFilePaths: [String] = []
for delta in diff.deltas {
oldFilePaths.append((delta.oldFile?.path)!)
}
expect(diff.deltas.count).to(equal(expectedCount))
expect(newFilePaths).to(equal(expectedNewFilePaths))
expect(oldFilePaths).to(equal(expectedOldFilePaths))
}
}
}
func temporaryURL(forPurpose purpose: String) -> URL {
static func temporaryURL(forPurpose purpose: String) -> URL {
let globallyUniqueString = ProcessInfo.processInfo.globallyUniqueString
let path = "\(NSTemporaryDirectory())\(globallyUniqueString)_\(purpose)"
return URL(fileURLWithPath: path)
+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 }'
}