388 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
Matt Diephouse 4864cc4753 Merge pull request #82 from SwiftGit2/swift3-readme
Update README.md for Swift 3
2017-01-07 14:44:46 -05:00
Matt Diephouse 2e7a0ce1cd Update README.md 2017-01-07 14:44:28 -05:00
Matt Diephouse 36f934d2b6 Merge pull request #78 from mattrubin/guard
Use guard-else instead of if statements when checking git error codes
2016-12-24 01:48:44 -05:00
Matt Rubin 98c0733592 Merge pull request #79 from mattrubin/swiftlint
Update lint configuration for Swiftlint 0.15
2016-12-23 23:56:03 -05:00
Matt Rubin 992ba7bf8a Merge master into guard 2016-12-23 23:51:14 -05:00
Matt Rubin 545bf12645 Merge pull request #77 from mattrubin/whitespace
Remove trailing whitespace on blank lines
2016-12-23 18:25:25 -05:00
Matt Rubin 62619af5e8 Clean up some whitespace around = operators 2016-12-23 18:09:56 -05:00
Matt Rubin 4741790d2c Wrap lines longer than 120 characters 2016-12-23 18:01:28 -05:00
Matt Rubin e148cd2530 Enable new opt-in SwiftLint rules 2016-12-23 18:01:28 -05:00
Matt Rubin baeb5cb3e2 Ignore unused closure parameters 2016-12-23 18:01:28 -05:00
Matt Rubin 28c01d4943 Use guard-else instead of if statements when checking git error codes
The compiler will warn if a guard statement falls through without exiting the scope.
2016-12-23 17:57:35 -05:00
Matt Rubin a0f0e49ee6 Remove trailing whitespace on newlines 2016-12-23 17:48:54 -05:00
Matt Diephouse 2cc5737d77 Merge pull request #72 from mattrubin/swift-api-guidelines
Swift API design guidelines
2016-12-23 17:38:18 -05:00
Matt Rubin c746c720c3 Remove the OID argument label for object getters 2016-12-22 23:36:25 -05:00
Matt Rubin 6da9e7810c Argument labels "withName:" -> "named:" 2016-12-22 18:36:58 -05:00
Matt Rubin 597a2fd000 Rename mapGit* methods back to withGit* 2016-12-21 23:37:21 -05:00
Matt Rubin 9c13bee3ad Delete unavailable method stubs 2016-12-19 00:21:24 -05:00
Matt Rubin a4e26a4b99 Apply API guidelines to private Repository helper functions 2016-12-19 00:17:33 -05:00
Matt Rubin b94b975236 Fix method description strings in RepositorySpec 2016-12-18 23:24:57 -05:00
Matt Rubin afbd6672cd Rename argument labels to refer to OID parameters as "Identifiers"
https://swift.org/documentation/api-design-guidelines/#name-according-to-roles
2016-12-18 23:24:26 -05:00
Matt Rubin ca028a4e4f Convert parameter and property names to camel case, per API guidelines 2016-12-18 22:40:47 -05:00
Matt Rubin 21ee7a44c5 Convert test helper free functions to private extension methods 2016-12-18 22:28:00 -05:00
Matt Rubin 93ddcd3e9a Apply API guidelines to test helper functions 2016-12-18 18:11:04 -05:00
Matt Rubin 2a90c7b5f3 Update Repository methods to match the API design guidelines 2016-12-18 18:11:04 -05:00
Matt Rubin 94c7de848f Convert libGit2Error free function to an NSError convenience initializer 2016-12-18 18:11:04 -05:00
Matt Rubin 3c3c3ff004 Improve argument parameters on git_strarray extension methods
Omit the external argument label and give parameters clearer names.
2016-12-18 18:11:04 -05:00
Matt Diephouse 561b0453c5 Merge pull request #71 from mattrubin/swiftlint
Configure SwiftLint
2016-12-18 14:50:47 -05:00
Matt Rubin b660b09c7a Add a target which just runs SwiftLint, and add it to both schemes 2016-12-18 14:04:25 -05:00
Matt Rubin 31d3412310 Configure SwiftLint's trailing whitespace warnings to ignore empty lines 2016-12-18 00:40:34 -05:00
Matt Rubin c8ce857e42 Lint: Multi-line collection literals should include trailing commas 2016-12-18 00:37:50 -05:00
Matt Rubin 416dbaa08f Lint: Limit vertical whitespace to a single empty line 2016-12-18 00:33:26 -05:00
Matt Rubin 3da641e708 Lint: Lines should not have trailing semicolons 2016-12-18 00:32:15 -05:00
Matt Rubin 3150d56e28 Lint: Files should have a single trailing newline 2016-12-18 00:30:11 -05:00
Matt Rubin 0f29b097e1 Lint: if statements shouldn't wrap their conditionals in parentheses 2016-12-18 00:28:51 -05:00
Matt Rubin 66cf46d67d Lint: Colons should be next to the identifier when specifying a type 2016-12-18 00:26:56 -05:00
Matt Rubin 686a41fbb7 Add a basic SwiftLint configuration 2016-12-18 00:25:30 -05:00
Matt Diephouse 8692c46a0c Merge pull request #70 from mattrubin/swift-3
Swift 3
2016-12-17 21:08:56 -05:00
Matt Rubin 7b52e822ce Simplify path mapping in the Repository initializer 2016-12-17 02:06:47 -05:00
Matt Rubin 1fb378dbaf Use the Swift API for getting a URL's file system representation 2016-12-17 01:46:55 -05:00
Matt Rubin 160428039e Use optional binding instead of comparing to nil and force-unwrapping 2016-12-17 01:33:36 -05:00
Matt Rubin 6244bdfdc6 Avoid using a double pointer with git_branch_name 2016-12-17 01:16:17 -05:00
Matt Rubin 755dfe08f6 Use non-Optional pointers wherever possible 2016-12-17 00:37:50 -05:00
Matt Rubin 003464dde8 Replace NSTimeZone with TimeZone 2016-12-17 00:36:00 -05:00
Matt Rubin b6c3c795bc Replace NSDate with Date wherever possible 2016-12-17 00:35:55 -05:00
Matt Rubin 59cccf62d0 Replace NSURL with URL wherever possible 2016-12-17 00:35:44 -05:00
Matt Rubin f97fcfab38 Convert source and tests to build with Swift 3 2016-12-17 00:22:08 -05:00
Matt Rubin 485b637d47 Update dependencies to support Swift 3 2016-12-17 00:16:24 -05:00
Matt Diephouse 0218aa1123 Merge pull request #69 from mattrubin/xcode-8.2
Xcode 8.2
2016-12-16 14:42:19 -05:00
Matt Rubin 9bae55743b Create a new simulator device to avoid xcodebuild exit status 70
The Travis CI Xcode 8.2 image has two simulator devices for each device type for the latest iOS.
The previous destination specifier caused xcodebuild to fail with exit status 70 and the error message:
"The requested device could not be found because multiple devices matched the request."
2016-12-16 13:22:17 -05:00
Matt Rubin 4198f090fe Configure Travis to build with Xcode 8.2 2016-12-16 12:13:11 -05:00
Matt Diephouse de0cee0806 Merge pull request #68 from mattrubin/build-settings
Clean up build settings
2016-12-15 19:46:36 -05:00
Matt Rubin 869fb17c8b Clean up static library build settings (and the names of the products)
The static library dependencies are built by external scripts, and do not use the naming settings specified here. However, Xcode uses the PRODUCT_NAME setting to generate the name of the placeholder product reference it creates automatically for each target.Specifying the base names of each static library in the build settings causes Xcode to generate names for its placeholder products which match the products that are actually built by the scripts.
2016-12-15 18:25:04 -05:00
Matt Rubin fe97151d16 Use the correct Info.plist for the iOS test target 2016-12-15 18:01:56 -05:00
Matt Rubin d38954516a Enable bitcode for the iOS framework
Bitcode is already enabled for the static library dependencies.
2016-12-15 17:58:56 -05:00
Matt Rubin 2289706481 Remove unnecessary SUPPORTED_PLATFORMS and VALID_ARCHS build settings 2016-12-15 17:48:07 -05:00
Matt Rubin c151e05911 Remove extraneous install name and install path build settings 2016-12-15 17:46:16 -05:00
Matt Rubin dc8a391290 Clean up search path build settings 2016-12-15 17:38:33 -05:00
Matt Rubin 717abc1cb3 Remove unnecessary or overridden project build settings 2016-12-15 17:14:11 -05:00
Matt Rubin ae34822fab Delete unused versioning build settings 2016-12-15 17:09:36 -05:00
Matt Rubin 236712b9d3 Set xcconfigs for static libraries and remove duplicated build settings 2016-12-15 17:06:37 -05:00
Matt Rubin c4c40f5173 Delete target build settings which duplicate settings from the xcconfigs 2016-12-15 17:01:14 -05:00
Matt Rubin eee3ca4446 Delete project build settings which duplicate settings from the xcconfig 2016-12-15 16:57:57 -05:00
Matt Rubin 7ffe3bbb3b Remove FRAMEWORK_SEARCH_PATHS from test targets
These extra search paths were unnecessary and causing warnings from the linker.
2016-12-15 16:24:21 -05:00
Matt Diephouse a8d16010ff Merge pull request #67 from mattrubin/modulemap
Use a modulemap for libgit2
2016-12-14 11:46:15 -05:00
Matt Rubin d1b72d059d Add export and inferred submodule declarations to the libgit2 modulemap 2016-12-13 23:31:31 -05:00
Matt Rubin a4072adf1e Remove libgit2 group and modulemap file reference from the Xcode project 2016-12-13 05:24:48 -05:00
Matt Rubin d4e2413e50 Update the libgit2 modulemap to avoid "does not include header" warnings
Also, use symlinks to enable cleaner path strings in the modulemap.
2016-12-13 05:15:47 -05:00
Matt Rubin c2535ace3f Add a libgit2 modulemap and remove the libgit2 headers from SwiftGit2 2016-12-13 04:27:38 -05:00
Matt Diephouse 14b7df3dac Merge pull request #64 from mattrubin/swift-2.3
Swift 2.3
2016-12-11 15:22:25 -05:00
Matt Rubin 841e110812 Update Guanaco
Now that Swift 2.3 support has been merged into modocache/Guanaco, there's no need to use the fork.
2016-12-11 11:21:48 -08:00
Matt Diephouse 7277c09763 Merge pull request #66 from mattrubin/license
Add a LICENSE file
2016-12-11 09:42:23 -05:00
Matt Rubin c6a8c01c87 Set low project deployment targets
This allows other projects which use SwiftGit2 more flexibility in their own deployment targets.
2016-12-10 16:43:31 -08:00
Matt Rubin 322ff97332 Update Guanaco
The new version has looser deployment targets and cleaner build settings.
2016-12-10 16:43:02 -08:00
Matt Rubin a4b15a2f6c Remove deprecated EMBEDDED_CONTENT_CONTAINS_SWIFT build setting
This old build setting (like its replacement, ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) is only needed for a target which does not contain any Swift code, but which embeds or tests another target which does contain Swift.
2016-12-10 16:41:30 -08:00
Matt Rubin f888eefb09 Don't copy git2.h with the framework's public headers
As of https://github.com/SwiftGit2/SwiftGit2/pull/60, the git2.h header no longer needs to be public.
This change silences a warning that "Umbrella header for module 'SwiftGit2' does not include header '.../git2.h'".
2016-12-10 16:41:21 -08:00
Matt Rubin 7c9bac1ca1 Set common deployment targets for the whole Xcode project
Setting the iOS deployment target at the project level ensures the IPHONEOS_DEPLOYMENT_TARGET environment variable is available to the scripts which build the external libraries.
Before this change, linking the external libraries with SwiftGit2-iOS resulted in hundreds of warnings that "object file (...) was built for newer iOS version (10.1) than being linked (9.2)".
2016-12-10 16:41:04 -08:00
Matt Rubin b3f71b9553 Configure Travis CI to build with Xcode 8.1 2016-12-10 16:39:39 -08:00
Matt Rubin addee4a13f Merge scripts into swift-2.3 2016-12-10 16:38:43 -08:00
Matt Rubin 7f5d098579 Add a LICENSE file 2016-12-10 16:21:30 -08:00
Matt Rubin c4544b2904 Remove xcpretty installation from script/bootstrap
The xcpretty gem is used for CI builds, but not for local Xcode builds.
The Travis configuration already ensures that xcpretty is installed, so including it in the main bootstrap script is unnecessary.
2016-12-09 16:24:26 -08:00
Matt Rubin a3006dc674 Update Travis configuration to build with Xcode 7.3
Travis retired the Xcode 7.2 image and has been routing jobs to the Xcode 7.3 image.
2016-12-09 16:18:39 -08:00
Matt Rubin a9c5fac6eb Update the bundler gem during Travis before_install
This should avoid the error with Bundler 1.13.2:
/Users/travis/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.2/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)
2016-12-09 16:15:12 -08:00
Matt Rubin 80fd0ca939 Update Travis configuration
- Add a build matrix for the different schemes
- Update the dependency installation to work with the new cibuild script
2016-12-09 13:59:24 -08:00
Matt Rubin 9552145b9e Replace script references to ObjectiveGit with SwiftGit2 2016-12-09 13:52:02 -08:00
Matt Rubin 4a562fd653 Clean up script/bootstrap whitespace 2016-12-09 13:43:04 -08:00
Matt Rubin 853ed3f75a Merge master into scripts 2016-12-09 13:39:32 -08:00
Matt Rubin 30c6452d99 Update scripts from Objective-Git, including commits:
commit fbc6bb0c42c3f35725fbe98db4e537e22c9a3aed
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Apr 11 09:40:00 2016 -0600

    Add clean_externals script

commit f250c3dd8330732d27b49af93a7defae6df0629e
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Apr 4 22:32:04 2016 -0600

    Enable pipefail

commit 7813f12c75381d87d5ab345c591d00f7184ab150
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Apr 4 22:19:42 2016 -0600

    Configure cibuild to echo commands and fail on first error

commit 6f802a4b82c634f115b7f941d697ccee3f557a8b
Author: Ben Chatelain <ben@octop.ad>
Date:   Sun Apr 3 13:01:45 2016 -0600

    Overhaul cibuild

    - Replaced xctool with xcodebuild + xcpretty
    - Removed unused cruft and awk scripts

commit 5978a65d53def353ab34d63f02553d7ff7622d1f
Merge: 41d4e28 de7f644
Author: Ben Chatelain <ben@octop.ad>
Date:   Sun Feb 28 21:06:56 2016 -0700

    Merge pull request #554 from libgit2/piet/travis-matrix

    Add matrix build for iOS and Mac

commit 1e3f6c5bdf38c1da26c7cc2b5bd4f6b3098bca2e
Author: Piet Brauer <piet@nerdishbynature.com>
Date:   Wed Feb 24 17:40:52 2016 +0800

    Add matrix build for iOS and Mac

commit 9c13681d06decdb8de327633dc80d9b742a54423
Author: Piet Brauer <piet@nerdishbynature.com>
Date:   Wed Feb 24 16:23:11 2016 +0800

    Enable Bitcode
2016-12-09 13:26:57 -08:00
Matt Rubin 6ba47e317d Clean up script indentation 2016-12-09 13:06:24 -08:00
Matt Rubin e735a7d4cb Update project, source, and tests to build with Swift 2.3 2016-12-06 12:43:03 -05:00
Matt Rubin 40c40c6b2d Use a fork of Guanaco which supports Swift 2.3 2016-12-06 12:36:36 -05:00
Matt Rubin 76b3c9224e Update Quick to 0.9.3
The Cartfile now specifies a dependency on Quick ~> 0.9.3, the first version of the library to support Swift 2.3 and Xcode 8:
https://github.com/Quick/Quick/releases/tag/v0.9.3
2016-12-06 11:22:29 -05:00
Matt Rubin ac3fde8763 Update Nimble to 4.1.0
The Cartfile now specifies a dependency on Nimble ~> 4.1.0, the first version of the library to support Swift 2.3 and Xcode 8:
https://github.com/Quick/Nimble/releases/tag/v4.1.0
2016-12-06 10:25:58 -05:00
Matt Rubin e1c8a536d1 Update libgit2 to 0.24.3
Version 0.24.3 is the latest release version of libgit2, and also includes a fix for "non-modular header" errors:
https://github.com/libgit2/libgit2/commit/0370dae1adea43f250b66abb0d48f9cc5987c15a
2016-12-06 09:55:23 -05:00
Matt Rubin 775c582e29 Update xcconfigs to 0.10
The Cartfile now specifies a dependency on xcconfigs >= 0.10, the version intended for use with Xcode 8:
https://github.com/jspahrsummers/xcconfigs/releases/tag/0.10
2016-12-06 09:55:06 -05:00
Matt Rubin 9ea09594d4 Update Result to 2.1.3
The Cartfile now specifies a dependency on Result ~> 2.1.1, the first version of the library to support Swift 2.3 and Xcode 8:
https://github.com/antitypical/Result/releases/tag/2.1.1
2016-12-06 09:54:47 -05:00
Matt Diephouse f097301ed7 Merge pull request #58 from tombooth/clone
Clone
2016-04-10 18:17:11 -04:00
Tom Booth 60cb395cc6 Add cloneFromURL function
This introduces a new static function on Repository that will allow a
user to clone a local or remote repository.

At the moment only SSH in-memory, username + password and default (no
creds) are implemented.

It provides an enum wrapper around the underlying libgit2 `git_cred_t`
type to abstract it away from the user into something that is a little
more Swift-like. As much of the C callback code and struct creation has
been moved into Swift-land as well, this is now possible as of 2.*
whereas before it was not.

I had to use a wrapper class in Credentials.swift in order to convert
blocks to pointers, as blocks do not implement the AnyObject protocol
that `Unmanaged` requies.

The test requires you passing through a set of environment variables
otherwise it will not run. This is so that secret/private information
isn't leaked into the repository. The required variables are as follows:

   - SG2TestPrivateRepo - the url of the private jrepo to clone;
   - SG2TestUsername - the url of the user that will be connecting;
   - SG2TestPublicKey - the public key data to be used;
   - SG2TestPrivateKey - the private key data;
   - SG2TestPassphrase - passphrase needed to use the private key (blank
     if none).
2016-04-07 14:50:38 +01:00
Tom Booth c3b155cfd4 Switch cibuild to xcodebuild and xcpretty
`xctool` runs the tests as logic only whereas `xcodebuild` and XCode
run them as application tests. When tests are running logic only a lot
of the subsystems that would be available on the simulator are not
there, for example keychain and networking.

https://github.com/facebook/xctool/issues/269
https://github.com/AFNetworking/AFNetworking/pull/1707
https://github.com/facebook/xctool/issues/367
https://github.com/facebook/xctool/issues/553
2016-04-07 14:40:58 +01:00
Matt Diephouse b8885e6509 Merge pull request #60 from drkibitz/feature/remove-pub-impl-detail
Remove the implementation detail leak, implemented in swift
2016-04-01 21:03:19 -04:00
Dr. Kibitz 86fcebd10c Use fromCString 2016-03-18 23:56:44 -07:00
Dr. Kibitz 876cd3edc1 Squashed commit of the following:
commit 1f2cc37d17c534d1df30824c8c462572dbd006df
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 23:30:46 2016 -0700

    Check for progress completion to destroy/dealloc callback pointer

    - Also some general cleanup

commit 792bb9d8a587b6d83dc9fd8e6119d6c79a23a679
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 10:05:03 2016 -0700

    this is a progress callback, don't clean up anything here

commit ce3c88058716089f511c5dd64c8c40813df783e9
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 00:45:22 2016 -0700

    remove one more uneeded type

commit 21b586ac57640d605af382d2b0f57d92900ab18e
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 00:44:46 2016 -0700

    Use move instead

commit 88630c94dbcf0b91e0223f45897168736044297a
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 00:40:16 2016 -0700

    address comments, dealloc after UnsafeMutablePointer alloc

commit e0fcfb82491dda4db815554a07b4c933d48ae420
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Fri Mar 18 00:39:51 2016 -0700

    add git2.h back as public header

commit 79287c952d1e288c5426b5ee1c4b3a5f9ab4efe7
Author: Dr. Kibitz <info@drkibitz.com>
Date:   Sun Mar 13 18:00:18 2016 -0700

    Remove the implementation detail leak, implemented in swift
2016-03-18 23:34:30 -07:00
Matt Diephouse fe02162a6a Merge pull request #59 from BasThomas/swift2-print
Update println > print in README
2016-03-08 16:18:16 -05:00
Bas Broek 393414fef6 Update println > print 2016-03-08 21:14:51 +01:00
Matt Diephouse 6268766594 Merge pull request #57 from tombooth/fix-exc-bad-access-checkout
Fix EXC_BAD_ACCESS when progress updates
2016-03-03 12:22:45 -05:00
Tom Booth 281d1aed2b Fix EXC_BAD_ACCESS when progress updates
Previously when a block was passed into checkout() it would be copied
but then the memory would be freed as nothing had retained a reference
to the copy. This meant that when block() was called in
SG2CheckoutProgressCallback() it would crash due to an attempt to
execute a random chunk of memory that previously contained the block.

This code now retains the payload after copying it.
2016-03-03 16:30:26 +00:00
Matt Diephouse e52387ce4f Merge pull request #56 from tombooth/quick-v0.9.1
Upgrade Quick to v0.9.1
2016-03-03 10:03:46 -05:00
Tom Booth 1292c6a78f Upgrade Quick to v0.9.1
This improves the quality of the test output, as noted by @modocache in
https://github.com/SwiftGit2/SwiftGit2/pull/52

A full diff of the changes to Quick can be found here:

https://github.com/Quick/Quick/compare/v0.8.0...v0.9.1
2016-03-03 14:13:03 +00:00
Matt Diephouse 1d28313725 Merge pull request #54 from tombooth/libgit2-to-v0.23.4
Upgrade libgit2 to v0.23.4
2016-02-27 18:40:48 -05:00
Tom Booth 8ea6f56fa0 Upgrade libgit2 to v0.23.4
The main reason for the upgrade is to enable use of SecureTransport for
https transport.

You can find a full diff here:

https://github.com/libgit2/libgit2/compare/7c63a33ffe1198b77b481974cd0e74e9ace1745c...e8feafe32007ebd16a61820c70abd221655d053c

and the changelog changes:

https://github.com/libgit2/libgit2/compare/7c63a33ffe1198b77b481974cd0e74e9ace1745c...e8feafe32007ebd16a61820c70abd221655d053c#diff-4ac32a78649ca5bdd8e0ba38b7006a1e
2016-02-26 16:20:37 +00:00
Matt Diephouse 97cd921046 Merge pull request #53 from tombooth/correct-dependency-order
Correct the dependency between openssl and libssh2
2016-02-23 15:14:58 -05:00
Tom Booth 433ef719eb Correct the dependency between openssl and libssh2
Previously, libgit2 was depending on both openssl and libssh2. This was
incorrect as libssh2 requires openssl for its build phase. I have moved
the openssl dependency back to libssh2.

I was testing using the scripts/cibuild executable, which masks any
dependency issues with openssl as it prebuilds it. This prebuilding was
done to get around TravisCI timeouts and so can't be removed to stop
this being missed again.
2016-02-23 18:26:00 +00:00
Matt Diephouse 778cf2b52e Merge pull request #52 from tombooth/ios
Return of the iOS target
2016-02-22 08:08:02 -05:00
Tom Booth 1e1655e0c9 Re-enable prebuilding OpenSSL
Now that the requirements for this script exist we can switch
prebuilding OpenSSL back on.
2016-02-22 11:18:16 +00:00
Tom Booth 6c0e55f3ca Structure xcode project for iOS
The commit contains all of the reconfiguration of the XCode project to
create a new iOS target and scheme. This follows, but occasionally
deviates from, the changes made in
https://github.com/SwiftGit2/SwiftGit2/pull/44. A couple of more
specific notes:

  - Disabled bitcode on iOS framework as the builds further down the
    chain won't currently generate bitcode. Not currently an issue but
    when Apple decided App Store can only contain bitcode it will be.
  - Update .gitignore to include directories generated as part of
    building openssl, libssh2 and libgit2. These are created as part of
    the build scripts borrowed from objective-git
  - Splits iOS/Mac libraries used into different groups for clarities
    sake
  - Set the debug and release configurations for the new targets to iOS
    Framework and Application
2016-02-22 11:17:41 +00:00
Tom Booth 77e26af360 Add OpenSSL and libssh2 for compilation on iOS
We need to include the source of these two libraries so that we can
compile them for the appropriate architectures and OS version used
by iOS.
2016-02-16 16:51:49 +00:00
Tom Booth ae91f54aa7 Vary the bundle identifier based on platform
The two different test targets will bundle up the required fixtures
under different bundle identifiers, this corrects the identifier based
on platform.
2016-02-16 16:51:49 +00:00
Tom Booth 7da9b0a084 Semanitcally import Foundation rather than Cocoa
Cocoa/Cocoa.h doesn't exist on iOS and all this header file needs is
some exports from Foundation.
2016-02-16 16:51:49 +00:00
Tom Booth aec66f930c Use ZipArchive to extract fixtures for tests
The current method used by this library uses NSTask to spin up an
externally running task to unzip the fixtures, this will not work on iOS
as this functionality is not allowed. Switching to use ZipArchive, as
noted by @modocache, provides a portable way of extracting fixtures.
2016-02-16 16:51:49 +00:00
Tom Booth a6cde2b1d1 Use script/cibuild for CI
This brings further parity between the way SwiftGit2 and objective-git
build.

At the moment the pre-compilation of OpenSSL is commented out as this
external library is not currently included.
2016-02-16 16:51:43 +00:00
Tom Booth cb5daab309 Bring script/ directory up to date
These scripts were borrowed from the objective-git project and utilized
in the branch that I am taking inspiration from
(https://github.com/SwiftGit2/SwiftGit2/pull/44). Bringing these up to
date includes some fixes for working with iOS. The changelog is as
follows:

Currently unmerged PR fixing script/cibuild for iphonesimulator:

https://github.com/libgit2/objective-git/pull/552

commit 24b2a886c0b61cf1dca0d55cac900b26616e50b9
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Nov 9 21:49:13 2015 -0700

    Fix libssh2 inclusion in libgit2 iOS build script

    - Added CMAKE_PREFIX_PATH to arch-specific libssh2 root dir
    - Added PKG_CONFIG_USE_CMAKE_PREFIX_PATH so things actually make
      sense
    - Removed unused LIBSSH2_INCLUDE_DIRS

commit dca46ad12a958095aca6ee431de842ca62857b11
Author: joe DeCapo <joe@polka.cat>
Date:   Wed Sep 23 05:26:43 2015 -0500

    Disable code signing during build

    Attempting solution from:
http://stackoverflow.com/questions/27671854/travis-ci-fails-to-build-with-a-code-signing-error

commit 0dc6c60dc0c13ecb088b2a93a9ad24b9c72a9b99
Merge: 4447e70 c9da387
Author: Josh Abernathy <joshaber@gmail.com>
Date:   Wed Sep 2 09:36:05 2015 -0400

    Merge pull request #484 from phatblat/ben/ios-test-target

    iOS Test target

commit 4447e700413adf920a665b138149a20344bc9c87
Merge: b7b2549 aa6dd45
Author: Josh Abernathy <joshaber@gmail.com>
Date:   Mon Aug 31 11:53:55 2015 -0500

    Merge pull request #497 from phatblat/ben/bootstrap

    Just install any missing tools in bootstrap

commit 15f906ca2efa9d5ba67744d25a825c9bc75ad9e7
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 15:25:38 2015 -0600

    Quote sdkflag

commit 2712c2a2beb294cd81ae44f733fdc9f17eb1a259
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 14:17:33 2015 -0600

    Add specific iOS simulator destination

    Specifying the destionation works around the following issue with
xctool. Can also hard-code the architecture, but this seems more
future-proof.

    ```
    Failed to query the list of test cases in the test bundle:
2015-08-24 10:57:11.740 sim[50821:2746840]
/Applications/Xcode6.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/sim:
No simulator devices appear to be running.  Setting data directories to
/var/empty.
    2015-08-24 10:57:11.741 sim[50821:2746840] DYLD_INSERT_LIBRARIES
contains possible bad values.  Caller beware:
/usr/local/Cellar/xctool/0.2.4/libexec/lib/otest-query-lib-ios.dylib
    dlopen(/Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests,
1): Library not loaded: @rpath/ObjectiveGit.framework/ObjectiveGit
      Referenced from:
/Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests
      Reason: no suitable image found.  Did find:
        /Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit.framework/ObjectiveGit:
mach-o, but wrong architecture
    ```

    Indeed, the "wrong architecture" message is correct as the framework
was built for a different architecture than the test binary:

    ```
    lipo -info ObjectiveGit.framework/ObjectiveGit
ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests
2015-08-24 11:03
    Non-fat file: ObjectiveGit.framework/ObjectiveGit is architecture:
i386
    Non-fat file: ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests is
architecture: x86_64
    ```

commit aa6dd4531cf3380250045c3bb19839d3a40934f1
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 12:31:31 2015 -0600

    /user -> /usr

commit b8efb3224393d12d720cbbbd348c2cb4ec066d6d
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:51:51 2015 -0600

    Abort script if Homebrew is not installed

commit e7b8e1aa4bf6aa20de09ff4b112ec688570914d1
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:42:17 2015 -0600

    Move check_deps to after update_submodules

commit 27473a0e8e92a47266664271ed4513806937efda
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:34:21 2015 -0600

    Wrap long git submodule command chain for readability

commit 7724e36e7ca1666f535c8967c7534e04664d457e
Author: Ben Chatelain <ben@octop.ad>
Date:   Sun Aug 9 09:12:56 2015 -0600

    Update script comments

commit 768f033f0bf95c01793a941311cdbf45a7fb975c
Author: Ben Chatelain <ben@octop.ad>
Date:   Sat Aug 8 22:51:14 2015 -0600

    Fix iPhone SDK version detection in Xcode 7

commit cb0c5c12f9865e1aa270ed523ce0aeaf72c2be21
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Jul 28 22:44:01 2015 -0600

    Just install any missing tools in bootstrap

    Now REQUIRED_TOOLS is a mix of commands and libraries

commit 8dda480f788e006277767810b29d8a760028ce8b
Author: Piet Brauer <piet@nerdishbynature.com>
Date:   Wed Jul 22 17:10:45 2015 +0200

    Prebuild OpenSSL in order to workaround Travis timouts

commit 6c66e65c539e3b53db6c5531743dcfecdb116c55
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 20 21:45:01 2015 -0600

    Stop letting cmake determine which clang to use

commit 2ea1bd02d33ed7fcd0604404dc98693ad89f3815
Author: joshaber <joshaber@gmail.com>
Date:   Fri Jul 10 12:39:52 2015 -0400

    Include pkg-config in our dependencies.

commit c906271f580d6901a1200fc4795df250aca47cfc
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 6 20:09:34 2015 -0600

    Disable CURL in libgit2 iOS build

commit 549717d138fd4cd1828c7e67fb810523794f1ecb
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 6 20:09:16 2015 -0600

    Remove obsolete OPENSSL_ defines from libgit2 iOS build

commit aed2cc39c831697102ac6aff317990729b55dd2c
Author: Ben Chatelain <ben@octop.ad>
Date:   Thu Jun 25 21:16:56 2015 -0600

    Fix LIBSSH2_INCLUDE_DIRS define

commit 5ba578ac115974f0981d49b7c79072e867ef804b
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Feb 17 17:10:32 2015 -0700

    Fix libgit2 Mac build (again)

    LIBSSH2_INCLUDE_DIR = /usr/local/include/

commit b0b011a9da2c784ef25e793a638c28c3b6387fd0
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Mon Feb 16 16:25:15 2015 -0700

    Revert "Fix libgit2 (Mac) build"

    This reverts commit fd67e2bc2fc40171b06df88b627a636bdcf102cb.

commit fd67e2bc2fc40171b06df88b627a636bdcf102cb
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Feb 10 07:39:25 2015 -0700

    Fix libgit2 (Mac) build

commit b817e13e4c29bea355044e316d9214fbc955ac8f
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Mon Feb 9 08:40:20 2015 -0700

    Fix libgit2-ios build

    Set LIBSSH2_INCLUDE_DIR so that libssh2.h can be found

commit da4608b8a5bb87c3c75c7acdcc453fd69c6b8672
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Thu Nov 6 15:10:33 2014 -0800

    Update objc-build-scripts to stop cleaning automatically

commit f8ff8a60bd0ca6dbfa7b170658c0be8f5f589cd6
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 15:51:29 2014 +1100

    Don't try and link .a's in the External folder.

commit 1e02f02ddcaf946f153449d604a0d60e2197aab8
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 15:51:15 2014 +1100

    Remove set -e because lol.

commit c32fe343651aacf91cbe3cf7d513c612f62b235e
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 14:41:47 2014 +1100

    Skip installing man pages to avoid too many symlink errors.

commit 88ee2eb305d3aeb1ece99c654f12da1fe2eadc40
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Wed Oct 22 11:51:32 2014 -0700

    Update to jspahrsummers/objc-build-scripts@a54782c

commit 2c337c688a2779b51e6d4178cbace23750f3fde7
Author: Justin Spahr-Summers <jspahrsummers@github.com>
Date:   Tue May 27 09:21:55 2014 -0700

    Enable libgit2 thread safety for iOS

    No idea why this was ever disabled.

    Resolves libgit2/libgit2#2384.

    /cc @carlosmn @SquaredTiki

commit 19392f8a036dc603f115b6ced0d03f580dee0f47
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Mon Nov 11 11:47:33 2013 -0800

    Add cmake as a required tool

commit 5b6cc97a958caedcc4dcbda18d1a193ed58a2ad6
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Mon Nov 11 11:37:54 2013 -0800

    Update objc-build-scripts
2016-02-16 16:50:36 +00:00
Matt Diephouse 2c1fb0e21f Merge pull request #50 from tombooth/remove-box-submodule
Remove Box from .gitmodules
2016-02-10 14:45:28 -08:00
Tom Booth 92582ef3e8 Remove Box from .gitmodules
During the upgrade to Swift 2.0 in `5c8a600` the dependency on the
library Box was removed, but the submodule wasn't fully.

This caused projects depending on SwiftGit2 to fail when Carthage was
recursively retrieving dependencies as it would find reference to Box
but no directory for it. The error I encountered was as below:

```
Parse error: expected submodule commit SHA in output of task (ls-tree -z ... Carthage/Checkouts/Box) but encountered:
```
2016-02-10 22:27:44 +00:00
Matt Diephouse d6787e905d Merge pull request #49 from JrGoodle/travis-ci
Add support for Travis CI
2016-01-30 20:56:29 -05:00
joe DeCapo b7ae8cfc9a Update .travis.yml with dependencies 2016-01-30 19:14:26 -06:00
joe DeCapo 9d837b1a40 Add Travis CI build status badge to README.md 2016-01-30 17:58:52 -06:00
joe DeCapo 46fddb0082 Add .travis.yml for running tests with scan 2016-01-25 19:05:45 -06:00
joe DeCapo 374c856484 Add fastlane to .gitignore 2016-01-25 19:04:16 -06:00
Matt Diephouse 4149f2ce5d Set a higher deployment target for the tests
Guanaco seems to require 10.11+.
2016-01-17 11:26:02 -05:00
Matt Diephouse 9ce75607bc Ignore .xcscmblueprint files 2016-01-17 11:24:34 -05:00
Matt Diephouse d3f27174b4 Merge pull request #47 from windmill-io/swift-2.0
SwiftGit2 won't build with Xcode 7.2 that uses Swift 2.0
2016-01-17 11:21:43 -05:00
Markos Charatzas dcc9fcfd8c NFC, code review 2016-01-17 10:39:38 +00:00
Markos Charatzas 5c8a6000c4 updated to Swift 2.0
updated to Xcode 7.2 recommended settings
integrated with Nimble (v3.0.0), Quick (v0.8.0), Result (1.0.1)
integrated with Guanaco (5031bf67297afbe61ac0f2fbf3e3e8400b3f8888) that supports Swift 2.0
2016-01-16 14:57:32 +00:00
Matt Diephouse 44fd952378 Merge pull request #45 from SwiftGit2/update-result
Update Result to 0.4.1
2015-06-11 17:12:04 -04:00
Matt Diephouse c4737c1098 Update Result to 0.4.1 2015-05-08 15:04:43 -04:00
72 changed files with 3776 additions and 2017 deletions
+25
View File
@@ -1,3 +1,6 @@
.vscode/
.build/
# Xcode
#
build/
@@ -16,6 +19,28 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
*.xcscmblueprint
*.idea*
External/libgit2*.a
External/libgit2-mac
External/ios-openssl
External/libgit2-ios
External/libssh2-ios
### fastlane ###
# fastlane - A streamlined workflow tool for Cocoa deployment
# fastlane specific
fastlane/report.xml
# deliver temporary files
fastlane/Preview.html
# snapshot generated screenshots
fastlane/screenshots/**/*.png
fastlane/screenshots/screenshots.html
# scan temporary files
fastlane/test_output
test_output
+11 -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,6 +10,14 @@
[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
[submodule "External/libssh2"]
path = External/libssh2
url = https://github.com/libssh2/libssh2.git
[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
+79
View File
@@ -0,0 +1,79 @@
disabled_rules:
- file_length
- 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
trailing_whitespace:
ignores_comments: false
ignores_empty_lines: false
+30
View File
@@ -0,0 +1,30 @@
language: objective-c
os: osx
osx_image: xcode11.4
sudo: false # Enable container-based builds
env:
matrix:
- SCHEME="SwiftGit2-OSX"
- SCHEME="SwiftGit2-iOS"
matrix:
fast_finish: true
before_install:
- gem update bundler # https://github.com/bundler/bundler/pull/4981
- gem install xcpretty
- gem install xcpretty-travis-formatter
install: script/bootstrap
script: script/cibuild
branches:
only: # whitelist
- master
notifications:
email: false
-1
View File
@@ -1 +0,0 @@
github "antitypical/Result"
+4 -4
View File
@@ -1,4 +1,4 @@
github "jspahrsummers/xcconfigs" >= 0.7.2
github "Quick/Quick" "155f858bce082373fc60d0c0a63415bf336c676b"
github "Quick/Nimble" ~> 0.4.1
github "modocache/Guanaco" "26b6ceff4b8912abd0dfc3a9eed0a46527e040e3"
github "jspahrsummers/xcconfigs" ~> 1.1
github "Quick/Quick" ~> 7.0
github "Quick/Nimble" ~> 12.0
github "ZipArchive/ZipArchive" ~> 2.0
+4 -5
View File
@@ -1,5 +1,4 @@
github "modocache/Guanaco" "26b6ceff4b8912abd0dfc3a9eed0a46527e040e3"
github "Quick/Nimble" "v0.4.2"
github "Quick/Quick" "155f858bce082373fc60d0c0a63415bf336c676b"
github "antitypical/Result" "0.3"
github "jspahrsummers/xcconfigs" "0.8"
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
Vendored Submodule
+1
Submodule External/libssh2 added at 30e9c1347e
+1 -1
View File
@@ -1 +1 @@
/usr/local/opt/openssl/lib/libssl.a
/opt/homebrew/opt/openssl/lib/libssl.a
Vendored Submodule
+1
Submodule External/openssl added at e71ebf275d
+21
View File
@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2014-2016 SwiftGit2 contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+45 -14
View File
@@ -1,25 +1,35 @@
# 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/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.atURL(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.commitWithOID($0.oid) }
if let commit = latestCommit.value {
println("Latest Commit: \(commit.message) by \(commit.author.name)")
} else {
println("Could not get commit: \(latestCommit.error)")
.flatMap {
repo.commit($0.oid)
}
switch latestCommit {
case let .success(commit):
print("Latest Commit: \(commit.message) by \(commit.author.name)")
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)")
}
```
SwiftGit2 requires Xcode 6.3 or later.
## Design
SwiftGit2 uses value objects wherever possible. That means using Swifts `struct`s and `enum`s without holding references to libgit2 objects. This has a number of advantages:
@@ -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:
File diff suppressed because it is too large Load Diff
@@ -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 = "0630"
LastUpgradeVersion = "1220"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -20,13 +20,36 @@
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C9CE0DD21E0710BD0053205D"
BuildableName = "SwiftLint"
BlueprintName = "SwiftLint"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-OSX"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@@ -41,13 +64,14 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
@@ -58,14 +82,12 @@
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66611C72958800A0F352"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-iOS"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C9CE0DD21E0710BD0053205D"
BuildableName = "SwiftLint"
BlueprintName = "SwiftLint"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
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">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66B61C72958D00A0F352"
BuildableName = "SwiftGit2-iOSTests.xctest"
BlueprintName = "SwiftGit2-iOSTests"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66611C72958800A0F352"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-iOS"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "621E66611C72958800A0F352"
BuildableName = "SwiftGit2.framework"
BlueprintName = "SwiftGit2-iOS"
ReferencedContainer = "container:SwiftGit2.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+1 -4
View File
@@ -4,9 +4,6 @@
<FileRef
location = "group:SwiftGit2.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Result/Result.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Quick/Quick.xcodeproj">
</FileRef>
@@ -14,6 +11,6 @@
location = "group:Carthage/Checkouts/Nimble/Nimble.xcodeproj">
</FileRef>
<FileRef
location = "group:Carthage/Checkouts/Guanaco/Guanaco.xcodeproj">
location = "group:Carthage/Checkouts/ZipArchive/ZipArchive.xcodeproj">
</FileRef>
</Workspace>
@@ -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>
+21 -19
View File
@@ -6,51 +6,53 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import Clibgit2
/// The flags defining how a checkout should be performed.
/// More detail is available in the libgit2 documentation for `git_checkout_strategy_t`.
public struct CheckoutStrategy : RawOptionSetType {
public struct CheckoutStrategy: OptionSet {
private let value: UInt
// MARK: - Initialization
/// Create an instance initialized with `nil`.
public init(nilLiteral: ()) {
self.value = 0
}
public init(rawValue value: UInt) {
self.value = value
}
public init(_ strategy: git_checkout_strategy_t) {
self.value = UInt(strategy.value)
self.value = UInt(strategy.rawValue)
}
public static var allZeros: CheckoutStrategy {
return self(rawValue: 0)
return self.init(rawValue: 0)
}
// MARK: - Properties
public var rawValue: UInt {
return value
}
public var git_checkout_strategy: git_checkout_strategy_t {
public var gitCheckoutStrategy: git_checkout_strategy_t {
return git_checkout_strategy_t(UInt32(self.value))
}
// MARK: - Values
/// Default is a dry run, no actual updates.
public static let None = CheckoutStrategy(GIT_CHECKOUT_NONE)
/// Allow safe updates that cannot overwrite uncommitted data.
public static let Safe = CheckoutStrategy(GIT_CHECKOUT_SAFE)
/// Allow all updates to force working directory to look like index
public static let Force = CheckoutStrategy(GIT_CHECKOUT_FORCE)
/// Allow checkout to recreate missing files.
public static let RecreateMissing = CheckoutStrategy(GIT_CHECKOUT_RECREATE_MISSING)
@@ -75,10 +77,10 @@ public struct CheckoutStrategy : RawOptionSetType {
/// Allow checkout to skip unmerged files
public static let SkipUnmerged = CheckoutStrategy(GIT_CHECKOUT_SKIP_UNMERGED)
/// For unmerged files, checkout stage 2 from index
public static let UseOurs = CheckoutStrategy(GIT_CHECKOUT_USE_OURS)
/// For unmerged files, checkout stage 3 from index
public static let UseTheirs = CheckoutStrategy(GIT_CHECKOUT_USE_THEIRS)
+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
}
}
}
+61
View File
@@ -0,0 +1,61 @@
//
// Credentials.swift
// SwiftGit2
//
// Created by Tom Booth on 29/02/2016.
// Copyright © 2016 GitHub, Inc. All rights reserved.
//
import Clibgit2
private class Wrapper<T> {
let value: T
init(_ value: T) {
self.value = value
}
}
public enum Credentials {
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
}
internal func toPointer() -> UnsafeMutableRawPointer {
return Unmanaged.passRetained(Wrapper(self)).toOpaque()
}
}
/// 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>?>?,
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:
result = git_cred_default_new(cred)
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):
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
}
return (result != GIT_OK.rawValue) ? -1 : 0
}
+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))
}
}
}
}
+27 -25
View File
@@ -1,31 +1,33 @@
import Foundation
import Clibgit2
public let libGit2ErrorDomain = "org.libgit2.libgit2"
/// Returns an NSError with an error domain and message for libgit2 errors.
///
/// :param: errorCode An error code returned by a libgit2 function.
/// :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 func libGit2Error(errorCode: Int32, libGit2PointOfFailure: String? = nil) -> NSError {
let code = Int(errorCode)
var userInfo: [String: String] = [:]
internal extension NSError {
/// Returns an NSError with an error domain and message for libgit2 errors.
///
/// :param: errorCode An error code returned by a libgit2 function.
/// :param: libGit2PointOfFailure The name of the libgit2 function that produced the
/// error code.
/// :returns: An NSError with a libgit2 error domain, code, and message.
convenience init(gitError errorCode: Int32, pointOfFailure: String? = nil) {
let code = Int(errorCode)
var userInfo: [String: String] = [:]
if let message = errorMessage(errorCode) {
userInfo[NSLocalizedDescriptionKey] = message
} else {
userInfo[NSLocalizedDescriptionKey] = "Unknown libgit2 error."
if let message = errorMessage(errorCode) {
userInfo[NSLocalizedDescriptionKey] = message
} else {
userInfo[NSLocalizedDescriptionKey] = "Unknown libgit2 error."
}
if let pointOfFailure = pointOfFailure {
userInfo[NSLocalizedFailureReasonErrorKey] = "\(pointOfFailure) failed."
}
self.init(domain: libGit2ErrorDomain, code: code, userInfo: userInfo)
}
if let pointOfFailure = libGit2PointOfFailure {
userInfo[NSLocalizedFailureReasonErrorKey] = "\(pointOfFailure) failed."
}
return NSError(domain: libGit2ErrorDomain, code: code, userInfo: userInfo)
}
/// Returns the libgit2 error message for the given error code.
///
/// The error message represents the last error message generated by
@@ -36,12 +38,12 @@ internal func libGit2Error(errorCode: Int32, libGit2PointOfFailure: String? = ni
/// or errno has been set by the system, this function returns the
/// corresponding string representation of that error. Otherwise, it returns
/// nil.
private func errorMessage(errorCode: Int32) -> String? {
private func errorMessage(_ errorCode: Int32) -> String? {
let last = giterr_last()
if last != nil {
return String.fromCString(last.memory.message)
} else if UInt32(errorCode) == GITERR_OS.value {
return String.fromCString(strerror(errno))
if let lastErrorPointer = last {
return String(validatingUTF8: lastErrorPointer.pointee.message)
} else if UInt32(errorCode) == GIT_ERROR_OS.rawValue {
return String(validatingUTF8: strerror(errno))
} else {
return nil
}
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.libgit2.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
+8 -11
View File
@@ -6,20 +6,17 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
func == (lhs: git_otype, rhs: git_otype) -> Bool {
return lhs.value == rhs.value
}
import Clibgit2
extension git_strarray {
func filter(f: (String) -> Bool) -> [String] {
return map { $0 }.filter(f)
func filter(_ isIncluded: (String) -> Bool) -> [String] {
return map { $0 }.filter(isIncluded)
}
func map<T>(f: (String) -> T) -> [T] {
return Swift.map(0..<self.count) {
let string = String.fromCString(self.strings[Int($0)])!
return f(string)
func map<T>(_ transform: (String) -> T) -> [T] {
return (0..<self.count).map {
let string = String(validatingUTF8: self.strings[$0]!)!
return transform(string)
}
}
}
+30 -41
View File
@@ -6,76 +6,65 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Foundation
import Result
import Clibgit2
/// An identifier for a Git object.
public struct OID {
// MARK: - Initializers
/// Create an instance from a hex formatted string.
///
/// string - A 40-byte hex formatted string.
public init?(string: String) {
// libgit2 doesn't enforce a maximum length
if (string.lengthOfBytesUsingEncoding(NSASCIIStringEncoding) > 40) {
if string.lengthOfBytes(using: String.Encoding.ascii) > 40 {
return nil
}
let pointer = UnsafeMutablePointer<git_oid>.alloc(1)
let pointer = UnsafeMutablePointer<git_oid>.allocate(capacity: 1)
let result = git_oid_fromstr(pointer, string)
if result < GIT_OK.value {
pointer.dealloc(1)
return nil;
if result < GIT_OK.rawValue {
pointer.deallocate()
return nil
}
oid = pointer.memory;
pointer.dealloc(1)
oid = pointer.pointee
pointer.deallocate()
}
/// Create an instance from a libgit2 `git_oid`.
public init(_ oid: git_oid) {
self.oid = oid
}
// MARK: - Properties
public let oid: git_oid
}
extension OID: Printable {
extension OID: CustomStringConvertible {
public var description: String {
let length = Int(GIT_OID_RAWSZ) * 2
let string = UnsafeMutablePointer<Int8>.alloc(length)
let string = UnsafeMutablePointer<Int8>.allocate(capacity: length)
var oid = self.oid
git_oid_fmt(string, &oid)
return String(bytesNoCopy: string, length: length, encoding: NSASCIIStringEncoding, freeWhenDone: true)!
return String(bytesNoCopy: string, length: length, encoding: .ascii, freeWhenDone: true)!
}
}
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 reduce(bytes, 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 static func == (lhs: OID, rhs: OID) -> Bool {
var left = lhs.oid
var right = rhs.oid
return git_oid_cmp(&left, &right) == 0
}
}
public func == (lhs: OID, rhs: OID) -> Bool {
var left = lhs.oid
var right = rhs.oid
return git_oid_cmp(&left, &right) == 0
}
+114 -127
View File
@@ -7,122 +7,140 @@
//
import Foundation
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 }
/// Create an instance with the underlying libgit2 type.
init(_ pointer: COpaquePointer)
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 {
/// The name of the person.
public let name: String
/// The email of the person.
public let email: String
/// The time when the action happened.
public let time: NSDate
public let time: Date
/// The time zone that `time` should be interpreted relative to.
public let timeZone: NSTimeZone
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.fromCString(signature.name)!
email = String.fromCString(signature.email)!
time = NSDate(timeIntervalSince1970: NSTimeInterval(signature.when.time))
timeZone = NSTimeZone(forSecondsFromGMT: NSInteger(60 * signature.when.offset))
name = String(validatingUTF8: signature.name)!
email = String(validatingUTF8: signature.email)!
time = Date(timeIntervalSince1970: TimeInterval(signature.when.time))
timeZone = TimeZone(secondsFromGMT: 60 * Int(signature.when.offset))!
}
/// 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)
}
}
extension Signature: Hashable {
public var hashValue: Int {
return name.hashValue ^ email.hashValue ^ time.timeIntervalSince1970.hashValue
public func hash(into hasher: inout Hasher) {
hasher.combine(name)
hasher.combine(email)
hasher.combine(time)
}
}
public func == (lhs: Signature, rhs: Signature) -> Bool {
return lhs.name == rhs.name
&& lhs.email == rhs.email
&& lhs.time == rhs.time
&& lhs.timeZone.secondsFromGMT == rhs.timeZone.secondsFromGMT
}
/// 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
/// The OID of the commit's tree.
public let tree: PointerTo<Tree>
/// The OIDs of the commit's parents.
public let parents: [PointerTo<Commit>]
/// The author of the commit.
public let author: Signature
/// The committer of the commit.
public let committer: Signature
/// The full message of the commit.
public let message: String
/// Create an instance with a libgit2 `git_commit` object.
public init(_ pointer: COpaquePointer) {
oid = OID(git_object_id(pointer).memory)
message = String.fromCString(git_commit_message(pointer))!
author = Signature(git_commit_author(pointer).memory)
committer = Signature(git_commit_committer(pointer).memory)
tree = PointerTo(OID(git_commit_tree_id(pointer).memory))
self.parents = map(0..<git_commit_parentcount(pointer)) {
return PointerTo(OID(git_commit_parent_id(pointer, $0).memory))
}
}
}
extension Commit: Hashable {
public var hashValue: Int {
return self.oid.hashValue
/// Create an instance with a libgit2 `git_commit` object.
public init(_ pointer: OpaquePointer) {
oid = OID(git_object_id(pointer).pointee)
message = String(validatingUTF8: git_commit_message(pointer))!
author = Signature(git_commit_author(pointer).pointee)
committer = Signature(git_commit_committer(pointer).pointee)
tree = PointerTo(OID(git_commit_tree_id(pointer).pointee))
self.parents = (0..<git_commit_parentcount(pointer)).map {
return PointerTo(OID(git_commit_parent_id(pointer, $0).pointee))
}
}
}
/// 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
/// The object pointed to by the entry.
public let object: Pointer
/// The file name of the entry.
public let name: String
/// Create an instance with a libgit2 `git_tree_entry`.
public init(_ pointer: COpaquePointer) {
let oid = OID(git_tree_entry_id(pointer).memory)
attributes = Int32(git_tree_entry_filemode(pointer).value)
public init(_ pointer: OpaquePointer) {
let oid = OID(git_tree_entry_id(pointer).pointee)
attributes = Int32(git_tree_entry_filemode(pointer).rawValue)
object = Pointer(oid: oid, type: git_tree_entry_type(pointer))!
name = String.fromCString(git_tree_entry_name(pointer))!
name = String(validatingUTF8: git_tree_entry_name(pointer))!
}
/// Create an instance with the individual values.
public init(attributes: Int32, object: Pointer, name: String) {
self.attributes = attributes
@@ -133,105 +151,74 @@ public struct Tree: ObjectType {
/// The OID of the tree.
public let oid: OID
/// The entries in the tree.
public let entries: [String: Entry]
/// Create an instance with a libgit2 `git_tree`.
public init(_ pointer: COpaquePointer) {
oid = OID(git_object_id(pointer).memory)
public init(_ pointer: OpaquePointer) {
oid = OID(git_object_id(pointer).pointee)
var entries: [String: Entry] = [:]
for idx in 0..<git_tree_entrycount(pointer) {
let entry = Entry(git_tree_entry_byindex(pointer, idx))
let entry = Entry(git_tree_entry_byindex(pointer, idx)!)
entries[entry.name] = entry
}
self.entries = entries
}
}
extension Tree.Entry: Hashable {
public var hashValue: Int {
return Int(attributes) ^ object.hashValue ^ name.hashValue
}
}
extension Tree.Entry: Printable {
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
/// The contents of the blob.
public let data: NSData
/// Create an instance with a libgit2 `git_blob`.
public init(_ pointer: COpaquePointer) {
oid = OID(git_object_id(pointer).memory)
// Swift doesn't get the types right without `Int(Int64(...))` :(
let length = Int(Int64(git_blob_rawsize(pointer).value))
data = NSData(bytes: git_blob_rawcontent(pointer), length: length)
}
}
extension Blob: Hashable {
public var hashValue: Int {
return oid.hashValue
/// The contents of the blob.
public let data: Data
/// Create an instance with a libgit2 `git_blob`.
public init(_ pointer: OpaquePointer) {
oid = OID(git_object_id(pointer).pointee)
let length = Int(git_blob_rawsize(pointer))
data = Data(bytes: git_blob_rawcontent(pointer), count: length)
}
}
/// 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
/// The tagged object.
public let target: Pointer
/// The name of the tag.
public let name: String
/// The tagger (author) of the tag.
public let tagger: Signature
/// The message of the tag.
public let message: String
/// Create an instance with a libgit2 `git_tag`.
public init(_ pointer: COpaquePointer) {
oid = OID(git_object_id(pointer).memory)
let targetOID = OID(git_tag_target_id(pointer).memory)
target = Pointer(oid: targetOID, type: git_tag_target_type(pointer))!
name = String.fromCString(git_tag_name(pointer))!
tagger = Signature(git_tag_tagger(pointer).memory)
message = String.fromCString(git_tag_message(pointer))!
}
}
extension Tag: Hashable {
public var hashValue: Int {
return oid.hashValue
/// Create an instance with a libgit2 `git_tag`.
public init(_ pointer: OpaquePointer) {
oid = OID(git_object_id(pointer).pointee)
let targetOID = OID(git_tag_target_id(pointer).pointee)
target = Pointer(oid: targetOID, type: git_tag_target_type(pointer))!
name = String(validatingUTF8: git_tag_name(pointer))!
tagger = Signature(git_tag_tagger(pointer).pointee)
message = String(validatingUTF8: git_tag_message(pointer))!
}
}
+52 -59
View File
@@ -6,89 +6,88 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Foundation
import Foundation
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.value == rhs.type.value
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 let Commit(oid):
return GIT_OBJ_COMMIT
case let Tree(oid):
return GIT_OBJ_TREE
case let Blob(oid):
return GIT_OBJ_BLOB
case let Tag(oid):
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) {
switch type.value {
case GIT_OBJ_COMMIT.value:
self = Commit(oid)
case GIT_OBJ_TREE.value:
self = Tree(oid)
case GIT_OBJ_BLOB.value:
self = Blob(oid)
case GIT_OBJ_TAG.value:
self = Tag(oid)
/// Create an instance with an OID and a libgit2 `git_object_t`.
init?(oid: OID, type: git_object_t) {
switch type {
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: Printable {
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))"
}
}
@@ -96,8 +95,8 @@ extension Pointer: Printable {
public struct PointerTo<T: ObjectType>: PointerType {
public let oid: OID
public var type: git_otype {
public var type: git_object_t {
return T.type
}
@@ -105,9 +104,3 @@ public struct PointerTo<T: ObjectType>: PointerType {
self.oid = oid
}
}
extension PointerTo: Hashable {
public var hashValue: Int {
return oid.hashValue
}
}
+72 -84
View File
@@ -6,25 +6,34 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import Clibgit2
/// A reference to a git object.
public protocol ReferenceType {
/// The full name of the reference (e.g., `refs/heads/master`).
var longName: String { get }
/// The short human-readable name of the reference if one exists (e.g., `master`).
var shortName: String? { get }
/// The OID of the referenced object.
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`.
internal func referenceWithLibGit2Reference(pointer: COpaquePointer) -> ReferenceType {
internal func referenceWithLibGit2Reference(_ pointer: OpaquePointer) -> ReferenceType {
if git_reference_is_branch(pointer) != 0 || git_reference_is_remote(pointer) != 0 {
return Branch(pointer)!
} else if git_reference_is_tag(pointer) != 0 {
@@ -35,167 +44,146 @@ internal func referenceWithLibGit2Reference(pointer: COpaquePointer) -> Referenc
}
/// 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
/// The short human-readable name of the reference if one exists (e.g., `master`).
public let shortName: String?
/// The OID of the referenced object.
public let oid: OID
/// Create an instance with a libgit2 `git_reference` object.
public init(_ pointer: COpaquePointer) {
let shorthand = String.fromCString(git_reference_shorthand(pointer))!
longName = String.fromCString(git_reference_name(pointer))!
shortName = (shorthand == longName ? nil : shorthand)
oid = OID(git_reference_target(pointer).memory)
}
}
extension Reference: Hashable {
public var hashValue: Int {
return longName.hashValue ^ oid.hashValue
/// Create an instance with a libgit2 `git_reference` object.
public init(_ pointer: OpaquePointer) {
let shorthand = String(validatingUTF8: git_reference_shorthand(pointer))!
longName = String(validatingUTF8: git_reference_name(pointer))!
shortName = (shorthand == longName ? nil : shorthand)
oid = OID(git_reference_target(pointer).pointee)
}
}
/// 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
/// The short human-readable name of the branch (e.g., `master`).
public let name: String
/// A pointer to the referenced commit.
public let commit: PointerTo<Commit>
// MARK: Derived Properties
/// The short human-readable name of the branch (e.g., `master`).
///
/// This is the same as `name`, but is declared with an Optional type to adhere to
/// `ReferenceType`.
public var shortName: String? { return name }
/// The OID of the referenced object.
///
/// This is the same as `commit.oid`, but is declared here to adhere to `ReferenceType`.
public var oid: OID { return commit.oid }
/// Whether the branch is a local branch.
public var isLocal: Bool { return longName.hasPrefix("refs/heads/") }
/// Whether the branch is a remote branch.
public var isRemote: Bool { return longName.hasPrefix("refs/remotes/") }
/// Create an instance with a libgit2 `git_reference` object.
///
/// Returns `nil` if the pointer isn't a branch.
public init?(_ pointer: COpaquePointer) {
let namePointer = UnsafeMutablePointer<UnsafePointer<Int8>>.alloc(1)
let success = git_branch_name(namePointer, pointer)
if success != GIT_OK.value {
namePointer.dealloc(1)
public init?(_ pointer: OpaquePointer) {
var namePointer: UnsafePointer<Int8>? = nil
let success = git_branch_name(&namePointer, pointer)
guard success == GIT_OK.rawValue else {
return nil
}
name = String.fromCString(namePointer.memory)!
namePointer.dealloc(1)
longName = String.fromCString(git_reference_name(pointer))!
name = String(validatingUTF8: namePointer!)!
longName = String(validatingUTF8: git_reference_name(pointer))!
var oid: OID
if git_reference_type(pointer).value == GIT_REF_SYMBOLIC.value {
var resolved: COpaquePointer = nil
if git_reference_type(pointer).rawValue == GIT_REFERENCE_SYMBOLIC.rawValue {
var resolved: OpaquePointer? = nil
let success = git_reference_resolve(&resolved, pointer)
if success != GIT_OK.value {
guard success == GIT_OK.rawValue else {
return nil
}
oid = OID(git_reference_target(resolved).memory)
oid = OID(git_reference_target(resolved).pointee)
git_reference_free(resolved)
} else {
oid = OID(git_reference_target(pointer).memory)
oid = OID(git_reference_target(pointer).pointee)
}
commit = PointerTo<Commit>(oid)
}
}
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.substringFromIndex("refs/tags/".endIndex)
return String(longName["refs/tags/".endIndex...])
}
/// The OID of the target object.
///
/// 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
}
}
// MARK: Derived Properties
/// The short human-readable name of the branch (e.g., `master`).
///
/// This is the same as `name`, but is declared with an Optional type to adhere to
/// `ReferenceType`.
public var shortName: String? { return name }
/// Create an instance with a libgit2 `git_reference` object.
///
/// Returns `nil` if the pointer isn't a branch.
public init?(_ pointer: COpaquePointer) {
public init?(_ pointer: OpaquePointer) {
if git_reference_is_tag(pointer) == 0 {
return nil;
return nil
}
let name = String.fromCString(git_reference_name(pointer))!
let name = String(validatingUTF8: git_reference_name(pointer))!
let repo = git_reference_owner(pointer)
var oid = git_reference_target(pointer).memory
var pointer: COpaquePointer = nil
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG)
if result == GIT_OK.value {
self = .Annotated(name, Tag(pointer))
var oid = git_reference_target(pointer).pointee
var pointer: OpaquePointer? = nil
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJECT_TAG)
if result == GIT_OK.rawValue {
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
}
}
+8 -16
View File
@@ -6,29 +6,21 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import Clibgit2
/// A remote in a git repository.
public struct Remote {
public struct Remote: Hashable {
/// The name of the remote.
public let name: String
/// The URL of the remote.
///
/// This may be an SSH URL, which isn't representable using `NSURL`.
public let URL: String
/// Create an instance with a libgit2 `git_remote`.
public init(_ pointer: COpaquePointer) {
name = String.fromCString(git_remote_name(pointer))!
URL = String.fromCString(git_remote_url(pointer))!
public init(_ pointer: OpaquePointer) {
name = String(validatingUTF8: git_remote_name(pointer))!
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
}
+738 -168
View File
File diff suppressed because it is too large Load Diff
+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 -9
View File
@@ -6,7 +6,7 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@import Foundation;
//! Project version number for SwiftGit2.
FOUNDATION_EXPORT double SwiftGit2VersionNumber;
@@ -15,11 +15,3 @@ FOUNDATION_EXPORT double SwiftGit2VersionNumber;
FOUNDATION_EXPORT const unsigned char SwiftGit2VersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <SwiftGit2/PublicHeader.h>
#import "git2.h"
typedef void (^SG2CheckoutProgressBlock)(NSString * __nullable, NSUInteger, NSUInteger);
/// A C function for working with Libgit2. This shouldn't be called directly. It's an
/// implementation detail that, unfortunately, leaks through to the public headers.
extern git_checkout_options SG2CheckoutOptions(SG2CheckoutProgressBlock __nullable progress);
+1 -22
View File
@@ -7,30 +7,9 @@
//
#import "SwiftGit2.h"
#import "git2.h"
__attribute__((constructor))
static void SwiftGit2Init(void) {
git_libgit2_init();
}
static void SG2CheckoutProgressCallback(const char *path, size_t completed_steps, size_t total_steps, void *payload) {
if (payload == NULL) return;
SG2CheckoutProgressBlock block = (__bridge SG2CheckoutProgressBlock)payload;
block((path == nil ? nil : @(path)), completed_steps, total_steps);
}
git_checkout_options SG2CheckoutOptions(SG2CheckoutProgressBlock progress) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
git_checkout_options result = GIT_CHECKOUT_OPTIONS_INIT;
#pragma clang diagnostic pop
if (progress != nil) {
result.progress_cb = SG2CheckoutProgressCallback;
result.progress_payload = (__bridge void *)[progress copy];
}
return result;
}
-66
View File
@@ -1,66 +0,0 @@
framework module SwiftGit2 {
umbrella header "SwiftGit2.h"
header "git2/annotated_commit.h"
header "git2/attr.h"
header "git2/blame.h"
header "git2/blob.h"
header "git2/branch.h"
header "git2/buffer.h"
header "git2/checkout.h"
header "git2/cherrypick.h"
header "git2/clone.h"
header "git2/commit.h"
header "git2/common.h"
header "git2/config.h"
header "git2/cred_helpers.h"
header "git2/describe.h"
header "git2/diff.h"
header "git2/errors.h"
header "git2/filter.h"
header "git2/global.h"
header "git2/graph.h"
header "git2/ignore.h"
header "git2/index.h"
header "git2/indexer.h"
header "git2/merge.h"
header "git2/message.h"
header "git2/net.h"
header "git2/notes.h"
header "git2/object.h"
header "git2/odb_backend.h"
header "git2/odb.h"
header "git2/oid.h"
header "git2/oidarray.h"
header "git2/pack.h"
header "git2/patch.h"
header "git2/pathspec.h"
header "git2/push.h"
header "git2/rebase.h"
header "git2/refdb.h"
header "git2/reflog.h"
header "git2/refs.h"
header "git2/refspec.h"
header "git2/remote.h"
header "git2/repository.h"
header "git2/reset.h"
header "git2/revert.h"
header "git2/revparse.h"
header "git2/revwalk.h"
header "git2/signature.h"
header "git2/stash.h"
header "git2/status.h"
header "git2/strarray.h"
header "git2/submodule.h"
header "git2/tag.h"
header "git2/trace.h"
header "git2/transaction.h"
header "git2/transport.h"
header "git2/tree.h"
header "git2/types.h"
header "git2/version.h"
export *
module * { export * }
}
+38 -42
View File
@@ -6,73 +6,69 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Foundation
import SwiftGit2
import ZipArchive
final class Fixtures {
// MARK: Lifecycle
class var sharedInstance: Fixtures {
struct Singleton {
enum Singleton {
static let instance = Fixtures()
}
return Singleton.instance
}
init() {
let path = NSTemporaryDirectory()
.stringByAppendingPathComponent("org.libgit2.SwiftGit2")
.stringByAppendingPathComponent(NSProcessInfo.processInfo().globallyUniqueString)
directoryURL = NSURL.fileURLWithPath(path, isDirectory: true)!
directoryURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
.appendingPathComponent("org.libgit2.SwiftGit2")
.appendingPathComponent(ProcessInfo.processInfo.globallyUniqueString)
}
// MARK: - Setup and Teardown
let directoryURL: NSURL
let directoryURL: URL
func setUp() {
NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil, error: nil)
let bundle = NSBundle(identifier: "org.libgit2.SwiftGit2-OSXTests")!
let zipURLs = bundle.URLsForResourcesWithExtension("zip", subdirectory: nil)! as! [NSURL]
try! FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil)
#if os(OSX)
let platform = "OSX"
#else
let platform = "iOS"
#endif
let bundleIdentifier = String(format: "org.libgit2.SwiftGit2-%@Tests", arguments: [platform])
let bundle = Bundle(identifier: bundleIdentifier)!
let zipURLs = bundle.urls(forResourcesWithExtension: "zip", subdirectory: nil)!
for URL in zipURLs {
unzipFileAtURL(URL, intoDirectoryAtURL: directoryURL)
SSZipArchive.unzipFile(atPath: URL.path, toDestination: directoryURL.path)
}
}
func tearDown() {
NSFileManager.defaultManager().removeItemAtURL(directoryURL, error: nil)
try! FileManager.default.removeItem(at: directoryURL)
}
func unzipFileAtURL(fileURL: NSURL, intoDirectoryAtURL directoryURL: NSURL) {
let task = NSTask()
task.launchPath = "/usr/bin/unzip"
task.arguments = [ "-qq", "-d", directoryURL.path!, fileURL.path! ]
task.launch()
task.waitUntilExit()
}
// MARK: - Helpers
func repositoryWithName(name: String) -> Repository {
let url = directoryURL.URLByAppendingPathComponent(name, isDirectory: true)
return Repository.atURL(url).value!
func repository(named name: String) -> Repository {
let url = directoryURL.appendingPathComponent(name, isDirectory: true)
return Repository.at(url).value!
}
// MARK: - The Fixtures
class var detachedHeadRepository: Repository {
return Fixtures.sharedInstance.repositoryWithName("detached-head")
return Fixtures.sharedInstance.repository(named: "detached-head")
}
class var simpleRepository: Repository {
return Fixtures.sharedInstance.repositoryWithName("simple-repository")
return Fixtures.sharedInstance.repository(named: "simple-repository")
}
class var mantleRepository: Repository {
return Fixtures.sharedInstance.repositoryWithName("Mantle")
return Fixtures.sharedInstance.repository(named: "Mantle")
}
}
Binary file not shown.
+2 -2
View File
@@ -9,11 +9,11 @@
import Quick
class FixturesSpec: QuickSpec {
override func spec() {
override class func spec() {
beforeSuite {
Fixtures.sharedInstance.setUp()
}
afterSuite {
Fixtures.sharedInstance.tearDown()
}
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.libgit2.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
+7 -8
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())
@@ -25,19 +24,19 @@ class OIDSpec: QuickSpec {
it("should not be nil if string is just right") {
expect(OID(string: "1234567890123456789012345678ABCDEFabcdef")).notTo(beNil())
}
it("should be nil with non-hex characters") {
expect(OID(string: "123456789012345678901234567890123456789j")).to(beNil())
}
}
describe("OID(oid)") {
it("should equal an OID with the same git_oid") {
let oid = OID(string: "1234567890123456789012345678901234567890")!
expect(OID(oid.oid)).to(equal(oid))
}
}
describe("OID.description") {
it("should return the SHA") {
let SHA = "1234567890123456789012345678901234567890"
@@ -45,7 +44,7 @@ class OIDSpec: QuickSpec {
expect(oid.description).to(equal(SHA))
}
}
describe("==(OID, OID)") {
it("should be equal when identical") {
let SHA = "1234567890123456789012345678901234567890"
@@ -53,14 +52,14 @@ class OIDSpec: QuickSpec {
let oid2 = OID(string: SHA)!
expect(oid1).to(equal(oid2))
}
it("should be not equal when different") {
let oid1 = OID(string: "1234567890123456789012345678901234567890")!
let oid2 = OID(string: "0000000000000000000000000000000000000000")!
expect(oid1).notTo(equal(oid2))
}
}
describe("OID.hashValue") {
it("should be equal when OIDs are equal") {
let SHA = "1234567890123456789012345678901234567890"
+125 -121
View File
@@ -6,79 +6,81 @@
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import Result
import SwiftGit2
import Nimble
import Quick
import Clibgit2
func from_git_object<T>(repository: Repository, oid: OID, f: COpaquePointer -> T) -> T {
let repository = repository.pointer
var oid = oid.oid
var pointer: COpaquePointer = nil
git_object_lookup(&pointer, repository, &oid, GIT_OBJ_ANY)
let result = f(pointer)
git_object_free(pointer)
return result
private extension Repository {
func withGitObject<T>(_ oid: OID, transform: (OpaquePointer) -> T) -> T {
let repository = self.pointer
var oid = oid.oid
var pointer: OpaquePointer? = nil
git_object_lookup(&pointer, repository, &oid, GIT_OBJECT_ANY)
let result = transform(pointer!)
git_object_free(pointer)
return result
}
}
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
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let raw_signature = from_git_object(repo, oid) { git_commit_author($0).memory }
let raw_signature = repo.withGitObject(oid) { git_commit_author($0).pointee }
let signature = Signature(raw_signature)
expect(signature.name).to(equal("Matt Diephouse"))
expect(signature.email).to(equal("matt@diephouse.com"))
expect(signature.time).to(equal(NSDate(timeIntervalSince1970: 1416186947)))
expect(signature.timeZone.abbreviation).to(equal("GMT-5"))
expect(signature.time).to(equal(Date(timeIntervalSince1970: 1416186947)))
expect(signature.timeZone.abbreviation()).to(equal("GMT-5"))
}
}
describe("==(Signature, Signature)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let author1 = from_git_object(repo, oid) { commit in
Signature(git_commit_author(commit).memory)
let author1 = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = author1
expect(author1).to(equal(author2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let oid2 = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")!
let author1 = from_git_object(repo, oid1) { commit in
Signature(git_commit_author(commit).memory)
let author1 = repo.withGitObject(oid1) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = from_git_object(repo, oid2) { commit in
Signature(git_commit_author(commit).memory)
let author2 = repo.withGitObject(oid2) { commit in
Signature(git_commit_author(commit).pointee)
}
expect(author1).notTo(equal(author2))
}
}
describe("Signature.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let author1 = from_git_object(repo, oid) { commit in
Signature(git_commit_author(commit).memory)
let author1 = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = author1
expect(author1.hashValue).to(equal(author2.hashValue))
}
}
@@ -86,18 +88,18 @@ 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
let oid = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")!
let commit = from_git_object(repo, oid) { Commit($0) }
let author = from_git_object(repo, oid) { commit in
Signature(git_commit_author(commit).memory)
let commit = repo.withGitObject(oid) { Commit($0) }
let author = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let committer = from_git_object(repo, oid) { commit in
Signature(git_commit_committer(commit).memory)
let committer = repo.withGitObject(oid) { commit in
Signature(git_commit_committer(commit).pointee)
}
let tree = PointerTo<Tree>(OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!)
let parents: [PointerTo<Commit>] = [
@@ -110,20 +112,20 @@ class CommitSpec: QuickSpec {
expect(commit.author).to(equal(author))
expect(commit.committer).to(equal(committer))
}
it("should handle 0 parents") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit = from_git_object(repo, oid) { Commit($0) }
let commit = repo.withGitObject(oid) { Commit($0) }
expect(commit.parents).to(equal([]))
}
it("should handle multiple parents") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!
let commit = from_git_object(repo, oid) { Commit($0) }
let commit = repo.withGitObject(oid) { Commit($0) }
let parents: [PointerTo<Commit>] = [
PointerTo(OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!),
PointerTo(OID(string: "57f6197561d1f99b03c160f4026a07f06b43cf20")!),
@@ -131,34 +133,34 @@ class CommitSpec: QuickSpec {
expect(commit.parents).to(equal(parents))
}
}
describe("==(Commit, Commit)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit1 = from_git_object(repo, oid) { Commit($0) }
let commit1 = repo.withGitObject(oid) { Commit($0) }
let commit2 = commit1
expect(commit1).to(equal(commit2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let oid2 = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!
let commit1 = from_git_object(repo, oid1) { Commit($0) }
let commit2 = from_git_object(repo, oid2) { Commit($0) }
let commit1 = repo.withGitObject(oid1) { Commit($0) }
let commit2 = repo.withGitObject(oid2) { Commit($0) }
expect(commit1).notTo(equal(commit2))
}
}
describe("Commit.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit1 = from_git_object(repo, oid) { Commit($0) }
let commit1 = repo.withGitObject(oid) { Commit($0) }
let commit2 = commit1
expect(commit1.hashValue).to(equal(commit2.hashValue))
}
@@ -167,59 +169,59 @@ 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.value)
let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
let attributes = Int32(GIT_FILEMODE_BLOB.rawValue)
let object = Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
let name = "README.md"
let entry = Tree.Entry(attributes: attributes, object: object, name: name)
expect(entry.attributes).to(equal(attributes))
expect(entry.object).to(equal(object))
expect(entry.name).to(equal(name))
}
}
describe("Tree.Entry(pointer)") {
it("should set its properties") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.value)))
expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
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.name).to(equal("README.md"))
}
}
describe("==(Tree.Entry, Tree.Entry)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry1 = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = entry1
expect(entry1).to(equal(entry2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let entry1 = from_git_object(repo, oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = from_git_object(repo, oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = repo.withGitObject(oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
expect(entry1).notTo(equal(entry2))
}
}
describe("Tree.Entry.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry1 = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = entry1
expect(entry1.hashValue).to(equal(entry2.hashValue))
}
@@ -228,47 +230,49 @@ 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
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree = from_git_object(repo, oid) { Tree($0) }
let tree = repo.withGitObject(oid) { Tree($0) }
let entries = [
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.value), object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!), name: "README.md"),
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue),
object: .blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
name: "README.md"),
]
expect(tree.entries).to(equal(entries))
}
}
describe("==(Tree, Tree)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree1 = from_git_object(repo, oid) { Tree($0) }
let tree1 = repo.withGitObject(oid) { Tree($0) }
let tree2 = tree1
expect(tree1).to(equal(tree2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let tree1 = from_git_object(repo, oid1) { Tree($0) }
let tree2 = from_git_object(repo, oid2) { Tree($0) }
let tree1 = repo.withGitObject(oid1) { Tree($0) }
let tree2 = repo.withGitObject(oid2) { Tree($0) }
expect(tree1).notTo(equal(tree2))
}
}
describe("Tree.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree1 = from_git_object(repo, oid) { Tree($0) }
let tree1 = repo.withGitObject(oid) { Tree($0) }
let tree2 = tree1
expect(tree1.hashValue).to(equal(tree2.hashValue))
}
@@ -277,47 +281,47 @@ 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
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob = from_git_object(repo, oid) { Blob($0) }
let blob = repo.withGitObject(oid) { Blob($0) }
let contents = "# Simple Repository\nA simple repository used for testing SwiftGit2.\n\n## Branches\n\n- master\n\n"
let data = (contents as NSString).dataUsingEncoding(NSUTF8StringEncoding)!
let data = contents.data(using: String.Encoding.utf8)!
expect(blob.oid).to(equal(oid))
expect(blob.data).to(equal(data))
}
}
describe("==(Blob, Blob)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob1 = from_git_object(repo, oid) { Blob($0) }
let blob1 = repo.withGitObject(oid) { Blob($0) }
let blob2 = blob1
expect(blob1).to(equal(blob2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let oid2 = OID(string: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")!
let blob1 = from_git_object(repo, oid1) { Blob($0) }
let blob2 = from_git_object(repo, oid2) { Blob($0) }
let blob1 = repo.withGitObject(oid1) { Blob($0) }
let blob2 = repo.withGitObject(oid2) { Blob($0) }
expect(blob1).notTo(equal(blob2))
}
}
describe("Blob.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob1 = from_git_object(repo, oid) { Blob($0) }
let blob1 = repo.withGitObject(oid) { Blob($0) }
let blob2 = blob1
expect(blob1.hashValue).to(equal(blob2.hashValue))
}
@@ -326,50 +330,50 @@ 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
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag = from_git_object(repo, oid) { Tag($0) }
let tagger = from_git_object(repo, oid) { Signature(git_tag_tagger($0).memory) }
let tag = repo.withGitObject(oid) { Tag($0) }
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"))
}
}
describe("==(Tag, Tag)") {
it("should be true with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag1 = from_git_object(repo, oid) { Tag($0) }
let tag1 = repo.withGitObject(oid) { Tag($0) }
let tag2 = tag1
expect(tag1).to(equal(tag2))
}
it("should be false with unequal objects") {
let repo = Fixtures.simpleRepository
let oid1 = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let oid2 = OID(string: "13bda91157f255ab224ff88d0a11a82041c9d0c1")!
let tag1 = from_git_object(repo, oid1) { Tag($0) }
let tag2 = from_git_object(repo, oid2) { Tag($0) }
let tag1 = repo.withGitObject(oid1) { Tag($0) }
let tag2 = repo.withGitObject(oid2) { Tag($0) }
expect(tag1).notTo(equal(tag2))
}
}
describe("Tag.hashValue") {
it("should be equal with equal objects") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag1 = from_git_object(repo, oid) { Tag($0) }
let tag1 = repo.withGitObject(oid) { Tag($0) }
let tag2 = tag1
expect(tag1.hashValue).to(equal(tag2.hashValue))
}
+49 -47
View File
@@ -6,46 +6,48 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import Result
import SwiftGit2
import Nimble
import Quick
import Clibgit2
func from_git_reference<T>(repository: Repository, name: String, f: COpaquePointer -> T) -> T {
let repository = repository.pointer
var pointer: COpaquePointer = nil
git_reference_lookup(&pointer, repository, name)
let result = f(pointer)
git_object_free(pointer)
return result
private extension Repository {
func withGitReference<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
let repository = self.pointer
var pointer: OpaquePointer? = nil
git_reference_lookup(&pointer, repository, name)
let result = transform(pointer!)
git_reference_free(pointer)
return result
}
}
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
let ref = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
expect(ref.longName).to(equal("refs/heads/master"))
expect(ref.shortName).to(equal("master"))
expect(ref.oid).to(equal(OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!))
}
}
describe("==(Reference, Reference)") {
it("should be true with equal references") {
let repo = Fixtures.simpleRepository
let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref2 = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref1 = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
let ref2 = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
expect(ref1).to(equal(ref2))
}
it("should be false with unequal references") {
let repo = Fixtures.simpleRepository
let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref2 = from_git_reference(repo, "refs/heads/another-branch") { Reference($0) }
let ref1 = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
let ref2 = repo.withGitReference(named: "refs/heads/another-branch") { Reference($0) }
expect(ref1).notTo(equal(ref2))
}
}
@@ -53,8 +55,8 @@ class ReferenceSpec: QuickSpec {
describe("Reference.hashValue") {
it("should be equal with equal references") {
let repo = Fixtures.simpleRepository
let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref2 = from_git_reference(repo, "refs/heads/master") { Reference($0) }
let ref1 = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
let ref2 = repo.withGitReference(named: "refs/heads/master") { Reference($0) }
expect(ref1.hashValue).to(equal(ref2.hashValue))
}
}
@@ -62,11 +64,11 @@ 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
let branch = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
expect(branch.longName).to(equal("refs/heads/master"))
expect(branch.name).to(equal("master"))
expect(branch.shortName).to(equal(branch.name))
@@ -75,10 +77,10 @@ class BranchSpec: QuickSpec {
expect(branch.isLocal).to(beTrue())
expect(branch.isRemote).to(beFalse())
}
it("should work with symoblic refs") {
let repo = Fixtures.mantleRepository
let branch = from_git_reference(repo, "refs/remotes/origin/HEAD") { Branch($0)! }
let branch = repo.withGitReference(named: "refs/remotes/origin/HEAD") { Branch($0)! }
expect(branch.longName).to(equal("refs/remotes/origin/HEAD"))
expect(branch.name).to(equal("origin/HEAD"))
expect(branch.shortName).to(equal(branch.name))
@@ -88,19 +90,19 @@ class BranchSpec: QuickSpec {
expect(branch.isRemote).to(beTrue())
}
}
describe("==(Branch, Branch)") {
it("should be true with equal branches") {
let repo = Fixtures.simpleRepository
let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch2 = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch1 = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
let branch2 = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
expect(branch1).to(equal(branch2))
}
it("should be false with unequal branches") {
let repo = Fixtures.simpleRepository
let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch2 = from_git_reference(repo, "refs/heads/another-branch") { Branch($0)! }
let branch1 = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
let branch2 = repo.withGitReference(named: "refs/heads/another-branch") { Branch($0)! }
expect(branch1).notTo(equal(branch2))
}
}
@@ -108,8 +110,8 @@ class BranchSpec: QuickSpec {
describe("Branch.hashValue") {
it("should be equal with equal references") {
let repo = Fixtures.simpleRepository
let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch2 = from_git_reference(repo, "refs/heads/master") { Branch($0)! }
let branch1 = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
let branch2 = repo.withGitReference(named: "refs/heads/master") { Branch($0)! }
expect(branch1.hashValue).to(equal(branch2.hashValue))
}
}
@@ -117,45 +119,45 @@ 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
let tag = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
expect(tag.longName).to(equal("refs/tags/tag-2"))
expect(tag.name).to(equal("tag-2"))
expect(tag.shortName).to(equal(tag.name))
expect(tag.oid).to(equal(OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")!))
}
it("should work with a lightweight tag") {
let repo = Fixtures.mantleRepository
let tag = from_git_reference(repo, "refs/tags/1.5.4") { TagReference($0)! }
let tag = repo.withGitReference(named: "refs/tags/1.5.4") { TagReference($0)! }
expect(tag.longName).to(equal("refs/tags/1.5.4"))
expect(tag.name).to(equal("1.5.4"))
expect(tag.shortName).to(equal(tag.name))
expect(tag.oid).to(equal(OID(string: "d9dc95002cfbf3929d2b70d2c8a77e6bf5b1b88a")!))
}
it("should return nil if not a tag") {
let repo = Fixtures.simpleRepository
let tag = from_git_reference(repo, "refs/heads/master") { TagReference($0) }
let tag = repo.withGitReference(named: "refs/heads/master") { TagReference($0) }
expect(tag).to(beNil())
}
}
describe("==(TagReference, TagReference)") {
it("should be true with equal tag references") {
let repo = Fixtures.simpleRepository
let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag1 = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
let tag2 = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
expect(tag1).to(equal(tag2))
}
it("should be false with unequal tag references") {
let repo = Fixtures.simpleRepository
let tag1 = from_git_reference(repo, "refs/tags/tag-1") { TagReference($0)! }
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag1 = repo.withGitReference(named: "refs/tags/tag-1") { TagReference($0)! }
let tag2 = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
expect(tag1).notTo(equal(tag2))
}
}
@@ -163,8 +165,8 @@ class TagReferenceSpec: QuickSpec {
describe("TagReference.hashValue") {
it("should be equal with equal references") {
let repo = Fixtures.simpleRepository
let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
let tag1 = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
let tag2 = repo.withGitReference(named: "refs/tags/tag-2") { TagReference($0)! }
expect(tag1.hashValue).to(equal(tag2.hashValue))
}
}
+23 -21
View File
@@ -6,54 +6,56 @@
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
//
import Result
import SwiftGit2
import Nimble
import Quick
import Clibgit2
func with_git_remote<T>(repository: Repository, name: String, f: COpaquePointer -> T) -> T {
let repository = repository.pointer
var pointer: COpaquePointer = nil
git_remote_lookup(&pointer, repository, name)
let result = f(pointer)
git_object_free(pointer)
return result
private extension Repository {
func withGitRemote<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
let repository = self.pointer
var pointer: OpaquePointer? = nil
git_remote_lookup(&pointer, repository, name)
let result = transform(pointer!)
git_remote_free(pointer)
return result
}
}
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
let remote = with_git_remote(repo, "upstream") { Remote($0) }
let remote = repo.withGitRemote(named: "upstream") { Remote($0) }
expect(remote.name).to(equal("upstream"))
expect(remote.URL).to(equal("git@github.com:Mantle/Mantle.git"))
}
}
describe("==(Remote, Remote)") {
it("should be true with equal objects") {
let repo = Fixtures.mantleRepository
let remote1 = with_git_remote(repo, "upstream") { Remote($0) }
let remote1 = repo.withGitRemote(named: "upstream") { Remote($0) }
let remote2 = remote1
expect(remote1).to(equal(remote2))
}
it("should be false with unequal objcets") {
let repo = Fixtures.mantleRepository
let origin = with_git_remote(repo, "origin") { Remote($0) }
let upstream = with_git_remote(repo, "upstream") { Remote($0) }
let origin = repo.withGitRemote(named: "origin") { Remote($0) }
let upstream = repo.withGitRemote(named: "upstream") { Remote($0) }
expect(origin).notTo(equal(upstream))
}
}
describe("Remote.hashValue") {
it("should be equal with equal objcets") {
let repo = Fixtures.mantleRepository
let remote1 = with_git_remote(repo, "upstream") { Remote($0) }
let remote1 = repo.withGitRemote(named: "upstream") { Remote($0) }
let remote2 = remote1
expect(remote1.hashValue).to(equal(remote2.hashValue))
}
File diff suppressed because it is too large Load Diff
+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
View File
@@ -0,0 +1 @@
../External/libgit2/include/git2
+1
View File
@@ -0,0 +1 @@
../External/libgit2/include/git2.h
+31
View File
@@ -0,0 +1,31 @@
module Clibgit2 {
umbrella header "git2.h"
export *
module * { export * }
// Exclude headers intended only for Microsoft compilers
exclude header "git2/inttypes.h"
exclude header "git2/stdint.h"
// Explicit modules for headers not included in the umbrella header:
explicit module cred_helpers {
header "git2/cred_helpers.h"
export *
}
explicit module trace {
header "git2/trace.h"
export *
}
// Explicit module for the "sys" headers:
explicit module sys {
umbrella "git2/sys"
export *
module * { export * }
}
}
-18
View File
@@ -1,18 +0,0 @@
**Copyright (c) 2013 Justin Spahr-Summers**
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-82
View File
@@ -1,82 +0,0 @@
# objc-build-scripts
This project is a collection of scripts created with two goals:
1. To standardize how Objective-C projects are bootstrapped after cloning
1. To easily build Objective-C projects on continuous integration servers
## Scripts
Right now, there are two important scripts: [`bootstrap`](#bootstrap) and
[`cibuild`](#cibuild). Both are Bash scripts, to maximize compatibility and
eliminate pesky system configuration issues (like setting up a working Ruby
environment).
The structure of the scripts on disk is meant to follow that of a typical Ruby
project:
```
script/
bootstrap
cibuild
```
### bootstrap
This script is responsible for bootstrapping (initializing) your project after
it's been checked out. Here, you should install or clone any dependencies that
are required for a working build and development environment.
By default, the script will verify that [xctool][] is installed, then initialize
and update submodules recursively. If any submodules contain `script/bootstrap`,
that will be run as well.
To check that other tools are installed, you can set the `REQUIRED_TOOLS`
environment variable before running `script/bootstrap`, or edit it within the
script directly. Note that no installation is performed automatically, though
this can always be added within your specific project.
### cibuild
This script is responsible for building the project, as you would want it built
for continuous integration. This is preferable to putting the logic on the CI
server itself, since it ensures that any changes are versioned along with the
source.
By default, the script will run [`bootstrap`](#bootstrap), look for any Xcode
workspace or project in the working directory, then build all targets/schemes
(as found by `xcodebuild -list`) using [xctool][].
You can also specify the schemes to build by passing them into the script:
```sh
script/cibuild ReactiveCocoa-Mac ReactiveCocoa-iOS
```
As with the `bootstrap` script, there are several environment variables that can
be used to customize behavior. They can be set on the command line before
invoking the script, or the defaults changed within the script directly.
## Getting Started
To add the scripts to your project, read the contents of this repository into
a `script` folder:
```
$ git remote add objc-build-scripts https://github.com/jspahrsummers/objc-build-scripts.git
$ git fetch objc-build-scripts
$ git read-tree --prefix=script/ -u objc-build-scripts/master
```
Then commit the changes, to incorporate the scripts into your own repository's
history. You can also freely tweak the scripts for your specific project's
needs.
To merge in upstream changes later:
```
$ git fetch -p objc-build-scripts
$ git merge --ff --squash -Xsubtree=script objc-build-scripts/master
```
[xctool]: https://github.com/facebook/xctool
+30 -23
View File
@@ -9,7 +9,8 @@ export SCRIPT_DIR=$(dirname "$0")
config ()
{
# A whitespace-separated list of executables that must be present and locatable.
: ${REQUIRED_TOOLS="xctool cmake"}
# These will each be installed through Homebrew if not found.
: ${REQUIRED_TOOLS="cmake libssh2 libtool autoconf automake pkg-config"}
export REQUIRED_TOOLS
}
@@ -22,12 +23,6 @@ main ()
{
config
if [ -n "$REQUIRED_TOOLS" ]
then
echo "*** Checking dependencies..."
check_deps
fi
local submodules=$(git submodule status)
local result=$?
@@ -41,28 +36,38 @@ main ()
echo "*** Updating submodules..."
update_submodules
fi
if [ -n "$REQUIRED_TOOLS" ]
then
echo "*** Checking dependencies..."
check_deps
fi
}
check_deps ()
{
for tool in $REQUIRED_TOOLS
do
which -s "$tool"
if [ "$?" -ne "0" ]
then
echo "*** Error: $tool not found. Please install it and bootstrap again."
exit 1
fi
done
# Check if Homebrew is installed
which -s brew
local result=$?
if [ "$result" -ne "0" ]
then
echo
echo "Homebrew is not installed (http://brew.sh). You will need to manually ensure the following tools are installed:"
echo " $REQUIRED_TOOLS"
echo
echo "Additionally, the following libssh2 files must be symlinked under /usr/local:"
echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
exit $result
fi
# Ensure that we have libgit2's dependencies installed.
installed=`brew list`
libs="libssh2 libtool autoconf automake"
for lib in $libs
for tool in $REQUIRED_TOOLS
do
# Skip packages that are already installed.
echo "$installed" | grep -q "$lib" && code=$? || code=$?
echo "$installed" | grep -q "$tool" && code=$? || code=$?
if [ "$code" -eq "0" ]
then
@@ -72,12 +77,12 @@ check_deps ()
exit $code
fi
echo "*** Installing $lib with Homebrew..."
brew install "$lib"
echo "*** Installing $tool with Homebrew..."
brew install "$tool"
done
brew_prefix=`brew --prefix`
expected_prefix=/usr/local
expected_prefix=/opt/homebrew
if [ "$brew_prefix" != "$expected_prefix" ]
then
@@ -114,7 +119,9 @@ bootstrap_submodule ()
update_submodules ()
{
git submodule sync --quiet && git submodule update --init && git submodule foreach --quiet bootstrap_submodule
git submodule sync --quiet && \
git submodule update --init && \
git submodule foreach --quiet bootstrap_submodule
}
export -f bootstrap_submodule
+69 -133
View File
@@ -1,150 +1,86 @@
#!/bin/bash
#!/bin/bash -ex
#
# script/cibuild
# SwiftGit2
#
# Executes the build and runs tests for Mac and iOS. Designed to be invoked by
# Travis as a matrix build so that the two platform builds can run in parallel.
#
# Dependent tools & scripts:
# - script/bootstrap
# - script/update_libssl_ios
# - [xcodebuild](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html)
# - xcpretty (gem)
# - xcpretty-travis-formatter (gem)
#
# Environment Variables:
# - SCHEME: specifies which Xcode scheme to build. Set to one of the following:
# - SwiftGit2-OSX
# - SwiftGit2-iOS
# - TRAVIS: indicates when the build is being run by travis, used to invoke
# the xcpretty-travis-formatter gem for output.
if [ -z "$SCHEME" ]; then
echo "The SCHEME environment variable is empty. Please set this to one of:"
echo "- SwiftGit2-OSX"
echo "- SwiftGit2-iOS"
exit 1
fi
export SCRIPT_DIR=$(dirname "$0")
##
## Configuration Variables
##
SCHEMES="$@"
set -o pipefail
SCRIPT_DIR=$(dirname "$0")
XCWORKSPACE="SwiftGit2.xcworkspace"
XCODE_OPTIONS=$(RUN_CLANG_STATIC_ANALYZER=NO ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO)
config ()
{
# The workspace to build.
#
# If not set and no workspace is found, the -workspace flag will not be passed
# to `xctool`.
#
# Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will
# take precedence.
: ${XCWORKSPACE=$(find_pattern "*.xcworkspace")}
# The project to build.
#
# If not set and no project is found, the -project flag will not be passed
# to `xctool`.
#
# Only one of `XCWORKSPACE` and `XCODEPROJ` needs to be set. The former will
# take precedence.
: ${XCODEPROJ=$(find_pattern "*.xcodeproj")}
# A bootstrap script to run before building.
#
# If this file does not exist, it is not considered an error.
: ${BOOTSTRAP="$SCRIPT_DIR/bootstrap"}
# Extra options to pass to xctool.
: ${XCTOOL_OPTIONS="RUN_CLANG_STATIC_ANALYZER=NO"}
# A whitespace-separated list of default schemes to build.
#
# Individual names can be quoted to avoid word splitting.
: ${SCHEMES:=$(xcodebuild -list -project "$XCODEPROJ" 2>/dev/null | awk -f "$SCRIPT_DIR/schemes.awk")}
export XCWORKSPACE
export XCODEPROJ
export BOOTSTRAP
export XCTOOL_OPTIONS
export SCHEMES
}
if [ -n "$TRAVIS" ]; then
# Use a special formatter when running on TravisCI
XCPRETTY_FORMAT_OPTIONS="-f `xcpretty-travis-formatter`"
else
XCPRETTY_FORMAT_OPTIONS="--color"
fi
##
## Build Process
##
main ()
{
config
echo "*** Bootstrapping..."
"$SCRIPT_DIR/bootstrap"
if [ -f "$BOOTSTRAP" ]
then
echo "*** Bootstrapping..."
"$BOOTSTRAP" || exit $?
fi
if [ "$SCHEME" == "SwiftGit2-OSX" ]; then
echo "*** Building and testing $SCHEME..."
echo
echo "*** The following schemes will be built:"
echo "$SCHEMES" | xargs -n 1 echo " "
echo
xcodebuild -workspace "$XCWORKSPACE" \
-scheme "$SCHEME" \
${XCODE_OPTIONS[*]} \
build test \
2>&1 | xcpretty $XCPRETTY_FORMAT_OPTIONS
elif [ "$SCHEME" == "SwiftGit2-iOS" ]; then
echo "*** Prebuilding OpenSSL"
"$SCRIPT_DIR/update_libssl_ios"
echo "$SCHEMES" | xargs -n 1 | (
local status=0
echo "*** Creating a simulator for testing..."
# Create a new simulator device and reference it by id to avoid xcodebuild exit status 70 with the following errors:
# "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-X
RUNTIME_ID=com.apple.CoreSimulator.SimRuntime.iOS-11-4
DESTINATION_ID=$(xcrun simctl create "$SIMULATOR_NAME" $DEVICE_ID $RUNTIME_ID)
while read scheme
do
build_scheme "$scheme" || status=1
done
echo "*** Building and testing $SCHEME..."
echo
exit $status
)
}
find_pattern ()
{
ls -d $1 2>/dev/null | head -n 1
}
run_xctool ()
{
if [ -n "$XCWORKSPACE" ]
then
xctool -workspace "$XCWORKSPACE" $XCTOOL_OPTIONS "$@" 2>&1
elif [ -n "$XCODEPROJ" ]
then
xctool -project "$XCODEPROJ" $XCTOOL_OPTIONS "$@" 2>&1
else
echo "*** No workspace or project file found."
exit 1
fi
}
parse_build ()
{
awk -f "$SCRIPT_DIR/xctool.awk" 2>&1 >/dev/null
}
build_scheme ()
{
local scheme=$1
echo "*** Building and testing $scheme..."
echo
local sdkflag=
local action=test
# Determine whether we can run unit tests for this target.
run_xctool -scheme "$scheme" run-tests | parse_build
local awkstatus=$?
if [ "$awkstatus" -eq "1" ]
then
# SDK not found, try for iphonesimulator.
sdkflag="-sdk iphonesimulator"
# Determine whether the unit tests will run with iphonesimulator
run_xctool $sdkflag -scheme "$scheme" run-tests | parse_build
awkstatus=$?
if [ "$awkstatus" -ne "0" ]
then
# Unit tests will not run on iphonesimulator.
sdkflag=""
fi
fi
if [ "$awkstatus" -ne "0" ]
then
# Unit tests aren't supported.
action=build
fi
run_xctool $sdkflag -scheme "$scheme" $action
}
export -f build_scheme
export -f run_xctool
export -f parse_build
main
xcodebuild -workspace "$XCWORKSPACE" \
-scheme "$SCHEME" \
-destination "id=$DESTINATION_ID" \
-sdk iphonesimulator \
${XCODE_OPTIONS[*]} \
build test \
2>&1 | xcpretty $XCPRETTY_FORMAT_OPTIONS
fi
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash -ex
#
# clean_externals
# SwiftGit2
#
# Removes the outputs from the various static library targets.
# Necessary when switching platforms/architectures as Xcode does not clean
# these for you.
#
# A list of external static libraries included in the SwiftGit2 framework
libraries=(
External/libgit2.a
External/libgit2-ios/libgit2-ios.a
External/libssh2-ios/lib/libssh2-ios.a
External/ios-openssl/lib/libssl.a
External/ios-openssl/lib/libcrypto.a
External/ios-openssl/include
)
rm -vrf "${libraries[@]}"
+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
}
-10
View File
@@ -1,10 +0,0 @@
BEGIN {
FS = "\n";
}
/Schemes:/ {
while (getline && $0 != "") {
sub(/^ +/, "");
print "'" $0 "'";
}
}
-12
View File
@@ -1,12 +0,0 @@
BEGIN {
FS = "\n";
}
/Targets:/ {
while (getline && $0 != "") {
if ($0 ~ /Tests/) continue;
sub(/^ +/, "");
print "'" $0 "'";
}
}
+102 -22
View File
@@ -1,34 +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 -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."
+71 -11
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
@@ -42,20 +42,21 @@ function build_libgit2 ()
LOG="${INSTALL_PREFIX}/build-libgit2.log"
echo "$LOG"
cmake -DCMAKE_C_COMPILER=clang \
cmake \
-DCMAKE_C_COMPILER_WORKS:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DOPENSSL_INCLUDE_DIR:PATH=../../External/ios-openssl/include/ \
-DCMAKE_LIBRARY_PATH:PATH=../../External/libssh2-ios/lib/ \
-DCMAKE_INCLUDE_PATH:PATH=../../External/libssh2-ios/include/libssh2/ \
-DOPENSSL_SSL_LIBRARY:FILEPATH=../../External/ios-openssl/lib/libssl.a \
-DCMAKE_LIBRARY_PATH:PATH="${SDKROOT}/usr/lib/" \
-DOPENSSL_CRYPTO_LIBRARY:FILEPATH=../../External/ios-openssl/lib/libcrypto.a \
-DCMAKE_PREFIX_PATH:PATH="${ROOT_PATH}/External/libssh2-ios/bin/${SDKNAME}-${ARCH}.sdk" \
-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
@@ -66,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
+4 -4
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"
@@ -24,8 +24,8 @@ function build_ssh2 ()
cp -R "${ROOT_PATH}/External/libssh2" "${ROOT_PATH}/External/libssh2-ios/src/"
pushd "${ROOT_PATH}/External/libssh2-ios/src/libssh2" > /dev/null
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"
export CPPFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"
export CFLAGS="-arch ${ARCH} -fembed-bitcode -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"
export CPPFLAGS="-arch ${ARCH} -fembed-bitcode -pipe -no-cpp-precomp -isysroot ${SDKROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}"
mkdir -p "${ROOT_PATH}/External/libssh2-ios/bin/${SDKNAME}-${ARCH}.sdk"
LOG="${ROOT_PATH}/External/libssh2-ios/bin/${SDKNAME}-${ARCH}.sdk/build-libssh2.log"
@@ -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."
}
+1 -1
View File
@@ -43,7 +43,7 @@ function build_ssl ()
echo "$LOG"
./Configure ${HOST} ${CONFIG} --openssldir="/tmp/openssl-${ARCH}" >> "${LOG}" 2>&1
perl -i -pe "s|^CC= gcc|CC= ${CLANG} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -arch ${ARCH} |g" Makefile >> "${LOG}" 2>&1
perl -i -pe "s|^CC= gcc|CC= ${CLANG} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -arch ${ARCH} -fembed-bitcode |g" Makefile >> "${LOG}" 2>&1
perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${SDKROOT} \$1|g" Makefile >> "${LOG}" 2>&1
make >> "${LOG}" 2>&1
+28 -6
View File
@@ -14,17 +14,39 @@ function xcode_major_version ()
xcode_version | awk -F '.' '{ print $1 }'
}
# Returns the latest iOS SDK version available
# via xcodebuild
function xcode_minor_version ()
{
xcode_version | awk -F '.' '{ print $2 }'
}
# Returns the latest iOS SDK version available via xcodebuild.
function ios_sdk_version ()
{
# This relies on the fact that the latest iPhone SDK
# is the last thing listed before the Xcode version.
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep SDKVersion | tail -n 1 | awk '{ print $2 }'
# The grep command produces output like the following, singling out the
# SDKVersion of just the iPhone* SDKs:
#
# iPhoneOS9.0.sdk - iOS 9.0 (iphoneos9.0)
# SDKVersion: 9.0
# --
# 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 }'
}
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 }'
}
-35
View File
@@ -1,35 +0,0 @@
# Exit statuses:
#
# 0 - No errors found.
# 1 - Build or test failure. Errors will be logged automatically.
# 2 - Untestable target. Retry with the "build" action.
BEGIN {
status = 0;
}
{
print;
fflush(stdout);
}
/is not valid for Testing/ {
exit 2;
}
/[0-9]+: (error|warning):/ {
errors = errors $0 "\n";
}
/(TEST|BUILD) FAILED/ {
status = 1;
}
END {
if (length(errors) > 0) {
print "\n*** All errors:\n" errors;
}
fflush(stdout);
exit status;
}
-25
View File
@@ -1,25 +0,0 @@
# Exit statuses:
#
# 0 - No errors found.
# 1 - Wrong SDK. Retry with SDK `iphonesimulator`.
# 2 - Missing target.
BEGIN {
status = 0;
}
{
print;
}
/Testing with the '(.+)' SDK is not yet supported/ {
status = 1;
}
/does not contain a target named/ {
status = 2;
}
END {
exit status;
}