Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 064aed35b6 | |||
| 0505abce23 | |||
| 89b08709e4 | |||
| f4ba5cd328 | |||
| 20b46e76dd | |||
| 5eb09593a0 | |||
| 6836608fca | |||
| 67b2ee52e8 | |||
| a5a9656732 | |||
| 6fb4054d38 | |||
| db091b107e | |||
| e76de59957 | |||
| e7315035df | |||
| 9343544dc9 | |||
| 2b7899198d | |||
| 11ca78320d | |||
| f00bb4699a | |||
| d176b1afaf | |||
| 3ebe0d82a8 | |||
| 8c461732df | |||
| bcccf31665 | |||
| edbd64318c | |||
| b620e0c08e | |||
| dc6a307153 | |||
| ac7f35a976 | |||
| cbb2207031 | |||
| 712cfc50ea | |||
| b253e02ac8 | |||
| 3dc0712e24 | |||
| 827ec79117 | |||
| 08c382a327 | |||
| f577819044 | |||
| 0842b80a3d | |||
| 734d25c15b | |||
| 84e7f996ae | |||
| ab0f592aed | |||
| ed618c6fbc | |||
| 17a0b7514d | |||
| 1e57a9ff00 | |||
| e78fe86a34 | |||
| c8a192f18b | |||
| e7656b1d88 | |||
| 62d0e15491 | |||
| 5ec4722a20 | |||
| c5cbf4cc17 | |||
| b87b66f11a | |||
| 571cdef3c4 | |||
| cc4833b334 |
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,45 @@
|
||||
name: pull request
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
xcode: [ Xcode_14.3, Xcode_15.2.0 ]
|
||||
os: [ macos-13 ]
|
||||
include:
|
||||
- xcode: Xcode_15.4
|
||||
os: macos-14
|
||||
- xcode: Xcode_16.2
|
||||
os: macos-14
|
||||
steps:
|
||||
- name: ls Xcode
|
||||
run: ls -la /Applications/Xcode*
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
- name: get architecture
|
||||
run: |
|
||||
echo "ARCHITECTURE=$(uname -m)" >> $GITHUB_ENV
|
||||
echo $(uname -m)
|
||||
- name: Set XCode Version
|
||||
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app
|
||||
- name: schemes list
|
||||
run: xcodebuild -workspace SwiftGit2.xcworkspace -list
|
||||
- name: update_libgit2
|
||||
run: script/update_libgit2
|
||||
- name: bootstrap
|
||||
run: script/bootstrap
|
||||
# - name: cibuild
|
||||
# run: script/cibuild
|
||||
- name: Build project
|
||||
run: xcodebuild -workspace SwiftGit2.xcworkspace -scheme SwiftGit2-OSX -archivePath ./SwiftGit2 archive ARCHS="${{ env.ARCHITECTURE }}"
|
||||
@@ -1,3 +1,6 @@
|
||||
.vscode/
|
||||
.build/
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
@@ -20,6 +23,7 @@ DerivedData
|
||||
*.idea*
|
||||
|
||||
External/libgit2*.a
|
||||
External/libgit2-mac
|
||||
External/ios-openssl
|
||||
External/libgit2-ios
|
||||
External/libssh2-ios
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
language: objective-c
|
||||
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
|
||||
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
-1
@@ -1,4 +1,4 @@
|
||||
github "jspahrsummers/xcconfigs" ~> 1.0
|
||||
github "jspahrsummers/xcconfigs" ~> 1.1
|
||||
github "Quick/Quick" ~> 2.0
|
||||
github "Quick/Nimble" ~> 8.0
|
||||
github "ZipArchive/ZipArchive" ~> 2.0
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
github "Quick/Nimble" "v8.0.1"
|
||||
github "Quick/Quick" "v2.0.0"
|
||||
github "ZipArchive/ZipArchive" "v2.1.5"
|
||||
github "jspahrsummers/xcconfigs" "1.0"
|
||||
github "Quick/Nimble" "v8.1.2"
|
||||
github "Quick/Quick" "v2.2.1"
|
||||
github "ZipArchive/ZipArchive" "v2.2.3"
|
||||
github "jspahrsummers/xcconfigs" "1.1"
|
||||
|
||||
Vendored
+1
-1
Submodule Carthage/Checkouts/Nimble updated: 43304bf2b1...7a46a5fc86
Vendored
+1
-1
Submodule Carthage/Checkouts/Quick updated: 0b4ed6c706...09b3becb37
Vendored
+1
-1
Submodule Carthage/Checkouts/ZipArchive updated: 6017baba3c...f3379e6efa
Vendored
+1
-1
Submodule Carthage/Checkouts/xcconfigs updated: d0f8992afa...4ced0ad5a9
Vendored
-1
@@ -1 +0,0 @@
|
||||
/usr/local/opt/openssl/lib/libcrypto.a
|
||||
Vendored
+1
-1
Submodule External/libgit2 updated: f23dc5b29f...7f4fa17862
Vendored
-1
@@ -1 +0,0 @@
|
||||
/usr/local/opt/openssl/lib/libssl.a
|
||||
@@ -1,25 +1,31 @@
|
||||
# SwiftGit2
|
||||
[](https://travis-ci.org/SwiftGit2/SwiftGit2)
|
||||
[](#carthage)
|
||||
[](https://github.com/SwiftGit2/SwiftGit2/releases)
|
||||

|
||||

|
||||
|
||||
Swift bindings to [libgit2](https://github.com/libgit2/libgit2).
|
||||
|
||||
```swift
|
||||
let URL: NSURL = ...
|
||||
let repo = Repository.at(URL)
|
||||
if let repo = repo.value {
|
||||
let latestCommit: Result<Commit, NSError> = repo
|
||||
let URL: URL = ...
|
||||
let result = Repository.at(URL)
|
||||
switch result {
|
||||
case let .success(repo):
|
||||
let latestCommit = repo
|
||||
.HEAD()
|
||||
.flatMap { repo.commit($0.oid) }
|
||||
if let commit = latestCommit.value {
|
||||
.flatMap {
|
||||
repo.commit($0.oid)
|
||||
}
|
||||
|
||||
switch latestCommit {
|
||||
case let .success(commit):
|
||||
print("Latest Commit: \(commit.message) by \(commit.author.name)")
|
||||
} else {
|
||||
print("Could not get commit: \(latestCommit.error)")
|
||||
|
||||
case let .failure(error):
|
||||
print("Could not get commit: \(error)")
|
||||
}
|
||||
} else {
|
||||
println("Could not open repository: \(repo.error)")
|
||||
|
||||
case let .failure(error):
|
||||
print("Could not open repository: \(error)")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -44,6 +50,10 @@ To build SwiftGit2, you'll need the following tools installed locally:
|
||||
* automake
|
||||
* pkg-config
|
||||
|
||||
```
|
||||
brew install cmake libssh2 libtool autoconf automake pkg-config
|
||||
```
|
||||
|
||||
## Adding SwiftGit2 to your Project
|
||||
The easiest way to add SwiftGit2 to your project is to use [Carthage](https://github.com/Carthage/Carthage). Simply add `github "SwiftGit2/SwiftGit2"` to your `Cartfile` and run `carthage update`.
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
237731C71F46542B0020A3FE /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; };
|
||||
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
|
||||
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25499A996CA7BD416620A397 /* CommitIterator.swift */; };
|
||||
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
|
||||
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F5181B0258FE7D10048F1EF /* StatusOptions.swift */; };
|
||||
621E66A01C72958800A0F352 /* OID.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE70B3E41A1ACB1A002C3F4E /* OID.swift */; };
|
||||
621E66A11C72958800A0F352 /* Remotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F6D1A57284700999413 /* Remotes.swift */; };
|
||||
621E66A21C72958800A0F352 /* CheckoutStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE276B281ACCD3CF00D6DAD7 /* CheckoutStrategy.swift */; };
|
||||
@@ -136,6 +138,7 @@
|
||||
232861421F4A3A2E00276D65 /* Diffs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diffs.swift; sourceTree = "<group>"; };
|
||||
237731C61F46542B0020A3FE /* repository-with-status.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = "repository-with-status.zip"; sourceTree = "<group>"; };
|
||||
25499A996CA7BD416620A397 /* CommitIterator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommitIterator.swift; sourceTree = "<group>"; };
|
||||
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusOptions.swift; sourceTree = "<group>"; };
|
||||
621E66B41C72958800A0F352 /* SwiftGit2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftGit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66CE1C72958D00A0F352 /* SwiftGit2-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SwiftGit2-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
621E66E11C729CE500A0F352 /* libgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgit2.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -315,6 +318,7 @@
|
||||
BECB5F691A56F19900999413 /* References.swift */,
|
||||
BECB5F6D1A57284700999413 /* Remotes.swift */,
|
||||
25499A996CA7BD416620A397 /* CommitIterator.swift */,
|
||||
3F5181B0258FE7D10048F1EF /* StatusOptions.swift */,
|
||||
);
|
||||
path = SwiftGit2;
|
||||
sourceTree = "<group>";
|
||||
@@ -593,7 +597,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 1010;
|
||||
LastUpgradeCheck = 1220;
|
||||
ORGANIZATIONNAME = "GitHub, Inc";
|
||||
TargetAttributes = {
|
||||
621E66611C72958800A0F352 = {
|
||||
@@ -682,7 +686,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libgit2_ios;
|
||||
shellScript = "script/update_libgit2_ios\n";
|
||||
};
|
||||
621E66E81C729EB800A0F352 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@@ -695,7 +699,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libssl_ios;
|
||||
shellScript = "script/update_libssl_ios\n";
|
||||
};
|
||||
621E66EE1C729EBB00A0F352 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@@ -721,7 +725,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = script/update_libgit2;
|
||||
shellScript = "script/update_libgit2\n";
|
||||
};
|
||||
C9CE0DD61E0710C20053205D /* Lint Sources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@@ -756,6 +760,7 @@
|
||||
621E66A71C72958800A0F352 /* Pointers.swift in Sources */,
|
||||
621E66A81C72958800A0F352 /* Errors.swift in Sources */,
|
||||
621E66A91C72958800A0F352 /* SwiftGit2.m in Sources */,
|
||||
3F5181B2258FE7D10048F1EF /* StatusOptions.swift in Sources */,
|
||||
2549921B34FFC36AF8C9CD6D /* CommitIterator.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -791,6 +796,7 @@
|
||||
BE7A753F1A4A2BCC002DA7E3 /* Pointers.swift in Sources */,
|
||||
DA5914761A94579000AED74C /* Errors.swift in Sources */,
|
||||
BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */,
|
||||
3F5181B1258FE7D10048F1EF /* StatusOptions.swift in Sources */,
|
||||
25499D325997CAB9BEFFCA4D /* CommitIterator.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -928,6 +934,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -936,6 +943,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F511A0D75EE00F525B9 /* iOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
@@ -976,12 +984,13 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F451A0D75EE00F525B9 /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -991,12 +1000,13 @@
|
||||
baseConfigurationReference = BEB31F471A0D75EE00F525B9 /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INSTALL_GROUP = "";
|
||||
INSTALL_MODE_FLAG = "";
|
||||
INSTALL_OWNER = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
@@ -1011,14 +1021,15 @@
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
External,
|
||||
"External/libgit2-mac",
|
||||
External/,
|
||||
"$(inherited)",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lgit2",
|
||||
"-force_load",
|
||||
External/libgit2.a,
|
||||
/usr/local/lib/libssh2.a,
|
||||
"External/libgit2-mac/libgit2-mac.a",
|
||||
External/libssh2.a,
|
||||
"-lgit2-mac",
|
||||
"-lcrypto",
|
||||
"-lssl",
|
||||
"-lcurl",
|
||||
@@ -1026,6 +1037,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SwiftGit2;
|
||||
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
|
||||
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -1039,14 +1051,15 @@
|
||||
);
|
||||
INFOPLIST_FILE = SwiftGit2/Info.plist;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
External,
|
||||
"External/libgit2-mac",
|
||||
External/,
|
||||
"$(inherited)",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lgit2",
|
||||
"-force_load",
|
||||
External/libgit2.a,
|
||||
/usr/local/lib/libssh2.a,
|
||||
"External/libgit2-mac/libgit2-mac.a",
|
||||
External/libssh2.a,
|
||||
"-lgit2-mac",
|
||||
"-lcrypto",
|
||||
"-lssl",
|
||||
"-lcurl",
|
||||
@@ -1054,6 +1067,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SwiftGit2;
|
||||
SWIFT_INCLUDE_PATHS = "$(SRCROOT)/libgit2";
|
||||
VALID_ARCHS = "arm64 arm64e i386 x86_64\n";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -1062,7 +1076,7 @@
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
@@ -1073,7 +1087,7 @@
|
||||
baseConfigurationReference = BEB31F531A0D75EE00F525B9 /* macOS-Application.xcconfig */;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = SwiftGit2Tests/Info.plist;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
@@ -1083,6 +1097,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -1091,6 +1106,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BEB31F571A0D75EE00F525B9 /* macOS-StaticLibrary.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
PRODUCT_NAME = git2;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1220"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -41,6 +41,15 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-OSX"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -53,17 +62,6 @@
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "BEB31F221A0D6F7A00F525B9"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-OSX"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -84,8 +82,6 @@
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1010"
|
||||
LastUpgradeVersion = "1220"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -41,6 +41,15 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "621E66611C72958800A0F352"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-iOS"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -53,17 +62,6 @@
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "621E66611C72958800A0F352"
|
||||
BuildableName = "SwiftGit2.framework"
|
||||
BlueprintName = "SwiftGit2-iOS"
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -84,8 +82,6 @@
|
||||
ReferencedContainer = "container:SwiftGit2.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// The flags defining how a checkout should be performed.
|
||||
/// More detail is available in the libgit2 documentation for `git_checkout_strategy_t`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public class CommitIterator: IteratorProtocol, Sequence {
|
||||
public typealias Iterator = CommitIterator
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private class Wrapper<T> {
|
||||
let value: T
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2017 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public struct StatusEntry {
|
||||
public var status: Diff.Status
|
||||
@@ -32,7 +32,7 @@ public struct Diff {
|
||||
public var deltas = [Delta]()
|
||||
|
||||
public struct Delta {
|
||||
public static let type = GIT_OBJ_REF_DELTA
|
||||
public static let type = GIT_OBJECT_REF_DELTA
|
||||
|
||||
public var status: Status
|
||||
public var flags: Flags
|
||||
@@ -50,7 +50,7 @@ public struct Diff {
|
||||
public struct File {
|
||||
public var oid: OID
|
||||
public var path: String
|
||||
public var size: Int64
|
||||
public var size: UInt64
|
||||
public var flags: Flags
|
||||
|
||||
public init(_ diffFile: git_diff_file) {
|
||||
@@ -94,7 +94,7 @@ public struct Diff {
|
||||
}
|
||||
public let rawValue: UInt32
|
||||
|
||||
public static let binary = Flags(rawValue: 0)
|
||||
public static let binary = Flags([])
|
||||
public static let notBinary = Flags(rawValue: 1 << 0)
|
||||
public static let validId = Flags(rawValue: 1 << 1)
|
||||
public static let exists = Flags(rawValue: 1 << 2)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public let libGit2ErrorDomain = "org.libgit2.libgit2"
|
||||
|
||||
@@ -42,7 +42,7 @@ private func errorMessage(_ errorCode: Int32) -> String? {
|
||||
let last = giterr_last()
|
||||
if let lastErrorPointer = last {
|
||||
return String(validatingUTF8: lastErrorPointer.pointee.message)
|
||||
} else if UInt32(errorCode) == GITERR_OS.rawValue {
|
||||
} else if UInt32(errorCode) == GIT_ERROR_OS.rawValue {
|
||||
return String(validatingUTF8: strerror(errno))
|
||||
} else {
|
||||
return nil
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
extension git_strarray {
|
||||
func filter(_ isIncluded: (String) -> Bool) -> [String] {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// An identifier for a Git object.
|
||||
public struct OID {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A git object.
|
||||
public protocol ObjectType {
|
||||
static var type: git_otype { get }
|
||||
static var type: git_object_t { get }
|
||||
|
||||
/// The OID of the object.
|
||||
var oid: OID { get }
|
||||
@@ -84,7 +84,7 @@ extension Signature: Hashable {
|
||||
|
||||
/// A git commit.
|
||||
public struct Commit: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_COMMIT
|
||||
public static let type = GIT_OBJECT_COMMIT
|
||||
|
||||
/// The OID of the commit.
|
||||
public let oid: OID
|
||||
@@ -120,7 +120,7 @@ public struct Commit: ObjectType, Hashable {
|
||||
|
||||
/// A git tree.
|
||||
public struct Tree: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_TREE
|
||||
public static let type = GIT_OBJECT_TREE
|
||||
|
||||
/// An entry in a `Tree`.
|
||||
public struct Entry: Hashable {
|
||||
@@ -176,7 +176,7 @@ extension Tree.Entry: CustomStringConvertible {
|
||||
|
||||
/// A git blob.
|
||||
public struct Blob: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_BLOB
|
||||
public static let type = GIT_OBJECT_BLOB
|
||||
|
||||
/// The OID of the blob.
|
||||
public let oid: OID
|
||||
@@ -195,7 +195,7 @@ public struct Blob: ObjectType, Hashable {
|
||||
|
||||
/// An annotated git tag.
|
||||
public struct Tag: ObjectType, Hashable {
|
||||
public static let type = GIT_OBJ_TAG
|
||||
public static let type = GIT_OBJECT_TAG
|
||||
|
||||
/// The OID of the tag.
|
||||
public let oid: OID
|
||||
|
||||
+15
-15
@@ -6,15 +6,15 @@
|
||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A pointer to a git object.
|
||||
public protocol PointerType: Hashable {
|
||||
/// The OID of the referenced object.
|
||||
var oid: OID { get }
|
||||
|
||||
/// The libgit2 `git_otype` of the referenced object.
|
||||
var type: git_otype { get }
|
||||
/// The libgit2 `git_object_t` of the referenced object.
|
||||
var type: git_object_t { get }
|
||||
}
|
||||
|
||||
public extension PointerType {
|
||||
@@ -48,29 +48,29 @@ public enum Pointer: PointerType {
|
||||
}
|
||||
}
|
||||
|
||||
public var type: git_otype {
|
||||
public var type: git_object_t {
|
||||
switch self {
|
||||
case .commit:
|
||||
return GIT_OBJ_COMMIT
|
||||
return GIT_OBJECT_COMMIT
|
||||
case .tree:
|
||||
return GIT_OBJ_TREE
|
||||
return GIT_OBJECT_TREE
|
||||
case .blob:
|
||||
return GIT_OBJ_BLOB
|
||||
return GIT_OBJECT_BLOB
|
||||
case .tag:
|
||||
return GIT_OBJ_TAG
|
||||
return GIT_OBJECT_TAG
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an instance with an OID and a libgit2 `git_otype`.
|
||||
init?(oid: OID, type: git_otype) {
|
||||
/// Create an instance with an OID and a libgit2 `git_object_t`.
|
||||
init?(oid: OID, type: git_object_t) {
|
||||
switch type {
|
||||
case GIT_OBJ_COMMIT:
|
||||
case GIT_OBJECT_COMMIT:
|
||||
self = .commit(oid)
|
||||
case GIT_OBJ_TREE:
|
||||
case GIT_OBJECT_TREE:
|
||||
self = .tree(oid)
|
||||
case GIT_OBJ_BLOB:
|
||||
case GIT_OBJECT_BLOB:
|
||||
self = .blob(oid)
|
||||
case GIT_OBJ_TAG:
|
||||
case GIT_OBJECT_TAG:
|
||||
self = .tag(oid)
|
||||
default:
|
||||
return nil
|
||||
@@ -96,7 +96,7 @@ extension Pointer: CustomStringConvertible {
|
||||
public struct PointerTo<T: ObjectType>: PointerType {
|
||||
public let oid: OID
|
||||
|
||||
public var type: git_otype {
|
||||
public var type: git_object_t {
|
||||
return T.type
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A reference to a git object.
|
||||
public protocol ReferenceType {
|
||||
@@ -107,7 +107,7 @@ public struct Branch: ReferenceType, Hashable {
|
||||
longName = String(validatingUTF8: git_reference_name(pointer))!
|
||||
|
||||
var oid: OID
|
||||
if git_reference_type(pointer).rawValue == GIT_REF_SYMBOLIC.rawValue {
|
||||
if git_reference_type(pointer).rawValue == GIT_REFERENCE_SYMBOLIC.rawValue {
|
||||
var resolved: OpaquePointer? = nil
|
||||
let success = git_reference_resolve(&resolved, pointer)
|
||||
guard success == GIT_OK.rawValue else {
|
||||
@@ -178,7 +178,7 @@ public enum TagReference: ReferenceType, Hashable {
|
||||
var oid = git_reference_target(pointer).pointee
|
||||
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG)
|
||||
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJECT_TAG)
|
||||
if result == GIT_OK.rawValue {
|
||||
self = .annotated(name, Tag(pointer!))
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2015 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
/// A remote in a git repository.
|
||||
public struct Remote: Hashable {
|
||||
|
||||
+33
-23
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
public typealias CheckoutProgressBlock = (String?, Int, Int) -> Void
|
||||
|
||||
@@ -206,7 +206,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the result of calling `transform` or an error if the object
|
||||
/// cannot be loaded.
|
||||
private func withGitObject<T>(_ oid: OID, type: git_otype,
|
||||
private func withGitObject<T>(_ oid: OID, type: git_object_t,
|
||||
transform: (OpaquePointer) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
var oid = oid.oid
|
||||
@@ -221,11 +221,11 @@ public final class Repository {
|
||||
return value
|
||||
}
|
||||
|
||||
private func withGitObject<T>(_ oid: OID, type: git_otype, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
|
||||
private func withGitObject<T>(_ oid: OID, type: git_object_t, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
|
||||
return withGitObject(oid, type: type) { Result.success(transform($0)) }
|
||||
}
|
||||
|
||||
private func withGitObjects<T>(_ oids: [OID], type: git_otype, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
private func withGitObjects<T>(_ oids: [OID], type: git_object_t, transform: ([OpaquePointer]) -> Result<T, NSError>) -> Result<T, NSError> {
|
||||
var pointers = [OpaquePointer]()
|
||||
defer {
|
||||
for pointer in pointers {
|
||||
@@ -254,7 +254,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns a `Blob`, `Commit`, `Tag`, or `Tree` if one exists, or an error.
|
||||
public func object(_ oid: OID) -> Result<ObjectType, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_ANY) { object in
|
||||
return withGitObject(oid, type: GIT_OBJECT_ANY) { object in
|
||||
let type = git_object_type(object)
|
||||
if type == Blob.type {
|
||||
return Result.success(Blob(object))
|
||||
@@ -270,7 +270,7 @@ public final class Repository {
|
||||
domain: "org.libgit2.SwiftGit2",
|
||||
code: 1,
|
||||
userInfo: [
|
||||
NSLocalizedDescriptionKey: "Unrecognized git_otype '\(type)' for oid '\(oid)'.",
|
||||
NSLocalizedDescriptionKey: "Unrecognized git_object_t '\(type)' for oid '\(oid)'.",
|
||||
]
|
||||
)
|
||||
return Result.failure(error)
|
||||
@@ -283,7 +283,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the blob if it exists, or an error.
|
||||
public func blob(_ oid: OID) -> Result<Blob, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_BLOB) { Blob($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_BLOB) { Blob($0) }
|
||||
}
|
||||
|
||||
/// Loads the commit with the given OID.
|
||||
@@ -292,7 +292,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the commit if it exists, or an error.
|
||||
public func commit(_ oid: OID) -> Result<Commit, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { Commit($0) }
|
||||
}
|
||||
|
||||
/// Loads the tag with the given OID.
|
||||
@@ -301,7 +301,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the tag if it exists, or an error.
|
||||
public func tag(_ oid: OID) -> Result<Tag, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_TAG) { Tag($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_TAG) { Tag($0) }
|
||||
}
|
||||
|
||||
/// Loads the tree with the given OID.
|
||||
@@ -310,7 +310,7 @@ public final class Repository {
|
||||
///
|
||||
/// Returns the tree if it exists, or an error.
|
||||
public func tree(_ oid: OID) -> Result<Tree, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_TREE) { Tree($0) }
|
||||
return withGitObject(oid, type: GIT_OBJECT_TREE) { Tree($0) }
|
||||
}
|
||||
|
||||
/// Loads the referenced object from the pointer.
|
||||
@@ -571,7 +571,15 @@ public final class Repository {
|
||||
/// :param: branch The branch to get all commits from
|
||||
/// :returns: Returns a result with array of branches or the error that occurred
|
||||
public func commits(in branch: Branch) -> CommitIterator {
|
||||
let iterator = CommitIterator(repo: self, root: branch.oid.oid)
|
||||
return commits(from: branch.oid)
|
||||
}
|
||||
|
||||
/// Load all commits from the given base in topological & time order descending
|
||||
///
|
||||
/// :param: base The oid to get all commits from
|
||||
/// :returns: Returns a result with array of branches or the error that occurred
|
||||
public func commits(from base: OID) -> CommitIterator {
|
||||
let iterator = CommitIterator(repo: self, root: base.oid)
|
||||
return iterator
|
||||
}
|
||||
|
||||
@@ -588,9 +596,10 @@ public final class Repository {
|
||||
|
||||
/// Stage the file(s) under the specified path.
|
||||
public func add(path: String) -> Result<(), NSError> {
|
||||
let dir = path
|
||||
var dirPointer = UnsafeMutablePointer<Int8>(mutating: (dir as NSString).utf8String)
|
||||
var paths = git_strarray(strings: &dirPointer, count: 1)
|
||||
var dirPointer = UnsafeMutablePointer<Int8>(mutating: (path as NSString).utf8String)
|
||||
var paths = withUnsafeMutablePointer(to: &dirPointer) {
|
||||
git_strarray(strings: $0, count: 1)
|
||||
}
|
||||
return unsafeIndex().flatMap { index in
|
||||
defer { git_index_free(index) }
|
||||
let addResult = git_index_add_all(index, &paths, 0, nil, nil)
|
||||
@@ -795,7 +804,7 @@ public final class Repository {
|
||||
}
|
||||
|
||||
if oldTree != nil && newTree != nil {
|
||||
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJ_TREE) { objects in
|
||||
return withGitObjects([oldTree!.oid, newTree!.oid], type: GIT_OBJECT_TREE) { objects in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -805,7 +814,7 @@ public final class Repository {
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
}
|
||||
} else if let tree = oldTree {
|
||||
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
|
||||
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -815,7 +824,7 @@ public final class Repository {
|
||||
return processTreeToTreeDiff(diffResult, diff: diff)
|
||||
})
|
||||
} else if let tree = newTree {
|
||||
return withGitObject(tree.oid, type: GIT_OBJ_TREE, transform: { tree in
|
||||
return withGitObject(tree.oid, type: GIT_OBJECT_TREE, transform: { tree in
|
||||
var diff: OpaquePointer? = nil
|
||||
let diffResult = git_diff_tree_to_tree(&diff,
|
||||
self.pointer,
|
||||
@@ -857,7 +866,7 @@ public final class Repository {
|
||||
}
|
||||
|
||||
private func safeTreeForCommitId(_ oid: OID) -> Result<Tree, NSError> {
|
||||
return withGitObject(oid, type: GIT_OBJ_COMMIT) { commit in
|
||||
return withGitObject(oid, type: GIT_OBJECT_COMMIT) { commit in
|
||||
let treeId = git_commit_tree_id(commit)
|
||||
return tree(OID(treeId!.pointee))
|
||||
}
|
||||
@@ -867,14 +876,14 @@ public final class Repository {
|
||||
private func unsafeTreeForCommitId(_ oid: OID) -> Result<OpaquePointer, NSError> {
|
||||
var commit: OpaquePointer? = nil
|
||||
var oid = oid.oid
|
||||
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJ_COMMIT)
|
||||
let commitResult = git_object_lookup(&commit, self.pointer, &oid, GIT_OBJECT_COMMIT)
|
||||
guard commitResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: commitResult, pointOfFailure: "git_object_lookup"))
|
||||
}
|
||||
|
||||
var tree: OpaquePointer? = nil
|
||||
let treeId = git_commit_tree_id(commit)
|
||||
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJ_TREE)
|
||||
let treeResult = git_object_lookup(&tree, self.pointer, treeId, GIT_OBJECT_TREE)
|
||||
|
||||
git_object_free(commit)
|
||||
|
||||
@@ -887,7 +896,7 @@ public final class Repository {
|
||||
|
||||
// MARK: - Status
|
||||
|
||||
public func status() -> Result<[StatusEntry], NSError> {
|
||||
public func status(options: StatusOptions = [.includeUntracked]) -> Result<[StatusEntry], NSError> {
|
||||
var returnArray = [StatusEntry]()
|
||||
|
||||
// Do this because GIT_STATUS_OPTIONS_INIT is unavailable in swift
|
||||
@@ -896,12 +905,13 @@ public final class Repository {
|
||||
guard optionsResult == GIT_OK.rawValue else {
|
||||
return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options"))
|
||||
}
|
||||
var options = pointer.move()
|
||||
var listOptions = pointer.move()
|
||||
listOptions.flags = options.rawValue
|
||||
pointer.deallocate()
|
||||
|
||||
var unsafeStatus: OpaquePointer? = nil
|
||||
defer { git_status_list_free(unsafeStatus) }
|
||||
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &options)
|
||||
let statusResult = git_status_list_new(&unsafeStatus, self.pointer, &listOptions)
|
||||
guard statusResult == GIT_OK.rawValue, let unwrapStatusResult = unsafeStatus else {
|
||||
return .failure(NSError(gitError: statusResult, pointOfFailure: "git_status_list_new"))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Copyright © 2020 GitHub, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Clibgit2
|
||||
import Foundation
|
||||
|
||||
public struct StatusOptions: OptionSet {
|
||||
public let rawValue: UInt32
|
||||
|
||||
public init(rawValue: UInt32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let includeUntracked = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNTRACKED.rawValue
|
||||
)
|
||||
public static let includeIgnored = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_IGNORED.rawValue
|
||||
)
|
||||
public static let includeUnmodified = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNMODIFIED.rawValue
|
||||
)
|
||||
public static let excludeSubmodules = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_EXCLUDE_SUBMODULES.rawValue
|
||||
)
|
||||
public static let recurseUntrackedDirs = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS.rawValue
|
||||
)
|
||||
public static let disablePathSpecMatch = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH.rawValue
|
||||
)
|
||||
public static let recurseIgnoredDirs = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RECURSE_IGNORED_DIRS.rawValue
|
||||
)
|
||||
public static let renamesHeadToIndex = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX.rawValue
|
||||
)
|
||||
public static let renamesIndexToWorkDir = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR.rawValue
|
||||
)
|
||||
public static let sortCasesSensitively = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_SORT_CASE_SENSITIVELY.rawValue
|
||||
)
|
||||
public static let sortCasesInSensitively = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY.rawValue
|
||||
)
|
||||
public static let renamesFromRewrites = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_RENAMES_FROM_REWRITES.rawValue
|
||||
)
|
||||
public static let noRefresh = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_NO_REFRESH.rawValue
|
||||
)
|
||||
public static let updateIndex = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_UPDATE_INDEX.rawValue
|
||||
)
|
||||
public static let includeUnreadable = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNREADABLE.rawValue
|
||||
)
|
||||
public static let includeUnreadableAsUntracked = StatusOptions(
|
||||
rawValue: GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED.rawValue
|
||||
)
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitObject<T>(_ oid: OID, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -17,7 +17,7 @@ private extension Repository {
|
||||
var oid = oid.oid
|
||||
|
||||
var pointer: OpaquePointer? = nil
|
||||
git_object_lookup(&pointer, repository, &oid, GIT_OBJ_ANY)
|
||||
git_object_lookup(&pointer, repository, &oid, GIT_OBJECT_ANY)
|
||||
let result = transform(pointer!)
|
||||
git_object_free(pointer)
|
||||
|
||||
@@ -25,7 +25,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class SignatureSpec: QuickSpec {
|
||||
class SignatureSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Signature(signature)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitReference<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -24,7 +24,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class ReferenceSpec: QuickSpec {
|
||||
class ReferenceSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Reference(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
import libgit2
|
||||
import Clibgit2
|
||||
|
||||
private extension Repository {
|
||||
func withGitRemote<T>(named name: String, transform: (OpaquePointer) -> T) -> T {
|
||||
@@ -24,7 +24,7 @@ private extension Repository {
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteSpec: QuickSpec {
|
||||
class RemoteSpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Remote(pointer)") {
|
||||
it("should initialize its properties") {
|
||||
|
||||
@@ -12,7 +12,7 @@ import Quick
|
||||
|
||||
// swiftlint:disable cyclomatic_complexity
|
||||
|
||||
class RepositorySpec: QuickSpec {
|
||||
class RepositorySpec: FixturesSpec {
|
||||
override func spec() {
|
||||
describe("Repository.Type.at(_:)") {
|
||||
it("should work if the repo exists") {
|
||||
@@ -776,7 +776,7 @@ class RepositorySpec: QuickSpec {
|
||||
}
|
||||
|
||||
it("Should accurately report status for repositories with status") {
|
||||
let expectedCount = 5
|
||||
let expectedCount = 6
|
||||
let expectedNewFilePaths = [
|
||||
"stage-file-1",
|
||||
"stage-file-2",
|
||||
@@ -791,6 +791,9 @@ class RepositorySpec: QuickSpec {
|
||||
"stage-file-4",
|
||||
"stage-file-5",
|
||||
]
|
||||
let expectedUntrackedFiles = [
|
||||
"unstaged-file",
|
||||
]
|
||||
|
||||
let repoWithStatus = Fixtures.sharedInstance.repository(named: "repository-with-status")
|
||||
let branchWithStatus = repoWithStatus.localBranch(named: "master").value!
|
||||
@@ -800,16 +803,28 @@ class RepositorySpec: QuickSpec {
|
||||
|
||||
var newFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
newFilePaths.append((status.headToIndex?.newFile?.path)!)
|
||||
if let path = status.headToIndex?.newFile?.path {
|
||||
newFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
var oldFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
oldFilePaths.append((status.headToIndex?.oldFile?.path)!)
|
||||
if let path = status.headToIndex?.oldFile?.path {
|
||||
oldFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
|
||||
var newUntrackedFilePaths: [String] = []
|
||||
for status in statuses {
|
||||
if let path = status.indexToWorkDir?.newFile?.path {
|
||||
newUntrackedFilePaths.append(path)
|
||||
}
|
||||
}
|
||||
|
||||
expect(statuses.count).to(equal(expectedCount))
|
||||
expect(newFilePaths).to(equal(expectedNewFilePaths))
|
||||
expect(oldFilePaths).to(equal(expectedOldFilePaths))
|
||||
expect(newUntrackedFilePaths).to(equal(expectedUntrackedFiles))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module libgit2 {
|
||||
module Clibgit2 {
|
||||
umbrella header "git2.h"
|
||||
|
||||
export *
|
||||
|
||||
+52
-24
@@ -46,6 +46,7 @@ main ()
|
||||
|
||||
check_deps ()
|
||||
{
|
||||
echo "** check_deps **"
|
||||
# Check if Homebrew is installed
|
||||
which -s brew
|
||||
local result=$?
|
||||
@@ -56,13 +57,21 @@ check_deps ()
|
||||
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 "Additionally, the following libssh2 files must be symlinked under /usr/local or /opt/homebrew :"
|
||||
echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
|
||||
exit $result
|
||||
|
||||
if [ ! -z "$CI" ]
|
||||
then
|
||||
echo
|
||||
echo "I will try to install brew now on the github runner"
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure that we have libgit2's dependencies installed.
|
||||
installed=`brew list`
|
||||
installed=$(brew list)
|
||||
|
||||
for tool in $REQUIRED_TOOLS
|
||||
do
|
||||
@@ -71,6 +80,7 @@ check_deps ()
|
||||
|
||||
if [ "$code" -eq "0" ]
|
||||
then
|
||||
echo "*** $tool is available 👍"
|
||||
continue
|
||||
elif [ "$code" -ne "1" ]
|
||||
then
|
||||
@@ -81,27 +91,45 @@ check_deps ()
|
||||
brew install "$tool"
|
||||
done
|
||||
|
||||
brew_prefix=`brew --prefix`
|
||||
expected_prefix=/usr/local
|
||||
|
||||
if [ "$brew_prefix" != "$expected_prefix" ]
|
||||
then
|
||||
echo "*** Adding soft links into $expected_prefix..."
|
||||
|
||||
products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
|
||||
|
||||
for product in "${products[@]}"
|
||||
do
|
||||
destination="$expected_prefix/$product"
|
||||
if [ -e "$destination" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
sudo mkdir -p "$(dirname "$destination")"
|
||||
sudo ln -s "$brew_prefix/$product" "$destination"
|
||||
done
|
||||
brew_prefix=$(brew --prefix)
|
||||
if [[ $(uname -m) == 'arm64' ]]; then
|
||||
echo "** Running on a Apple Silicon M1"
|
||||
expected_prefix=/opt/homebrew
|
||||
else
|
||||
echo "** Running on a Apple x86"
|
||||
expected_prefix=/usr/local
|
||||
fi
|
||||
|
||||
install_path="./External"
|
||||
pwd
|
||||
set -x
|
||||
cp "$brew_prefix"/lib/libcrypto.a $install_path
|
||||
cp "$brew_prefix"/lib/libssl.a $install_path
|
||||
cp "$brew_prefix"/lib/libssh2.a $install_path
|
||||
set +x
|
||||
if [ "$brew_prefix" != "$expected_prefix" ]
|
||||
then
|
||||
echo "*** Adding soft links into $expected_prefix..."
|
||||
|
||||
products=(lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h)
|
||||
|
||||
for product in "${products[@]}"
|
||||
do
|
||||
destination="$expected_prefix/$product"
|
||||
if [ -e "$destination" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
sudo mkdir -p "$(dirname "$destination")"
|
||||
sudo ln -s "$brew_prefix/$product" "$destination"
|
||||
done
|
||||
fi
|
||||
|
||||
# openssl@1 is expected
|
||||
#sslSource=$(find $brew_prefix -name libcrypto.a | grep openssl | sort | head -1 | xargs dirname)
|
||||
#echo "Find libcrypto.a and take first $sslSource and copy to install_path=$install_path"
|
||||
#cp $sslSource/* "$install_path" 2>/dev/null | echo "Copy and ignore subdirectory. This makes build work on x86 and arm64"
|
||||
}
|
||||
|
||||
bootstrap_submodule ()
|
||||
@@ -110,7 +138,7 @@ bootstrap_submodule ()
|
||||
|
||||
if [ -e "$bootstrap" ]
|
||||
then
|
||||
echo "*** Bootstrapping $name..."
|
||||
echo "*** Bootstrapping ..."
|
||||
"$bootstrap" >/dev/null
|
||||
else
|
||||
update_submodules
|
||||
|
||||
+4
-4
@@ -57,7 +57,7 @@ if [ "$SCHEME" == "SwiftGit2-OSX" ]; then
|
||||
|
||||
xcodebuild -workspace "$XCWORKSPACE" \
|
||||
-scheme "$SCHEME" \
|
||||
${XCODE_OPTIONS[*]} \
|
||||
"${XCODE_OPTIONS[*]}" \
|
||||
build test \
|
||||
2>&1 | xcpretty $XCPRETTY_FORMAT_OPTIONS
|
||||
elif [ "$SCHEME" == "SwiftGit2-iOS" ]; then
|
||||
@@ -69,8 +69,8 @@ elif [ "$SCHEME" == "SwiftGit2-iOS" ]; then
|
||||
# "The requested device could not be found because no available devices matched the request."
|
||||
# "The requested device could not be found because multiple devices matched the request."
|
||||
SIMULATOR_NAME="Custom Simulator"
|
||||
DEVICE_ID=com.apple.CoreSimulator.SimDeviceType.iPhone-5
|
||||
RUNTIME_ID=com.apple.CoreSimulator.SimRuntime.iOS-10-2
|
||||
DEVICE_ID=com.apple.CoreSimulator.SimDeviceType.iPhone-X
|
||||
RUNTIME_ID=com.apple.CoreSimulator.SimRuntime.iOS-11-4
|
||||
DESTINATION_ID=$(xcrun simctl create "$SIMULATOR_NAME" $DEVICE_ID $RUNTIME_ID)
|
||||
|
||||
echo "*** Building and testing $SCHEME..."
|
||||
@@ -80,7 +80,7 @@ elif [ "$SCHEME" == "SwiftGit2-iOS" ]; then
|
||||
-scheme "$SCHEME" \
|
||||
-destination "id=$DESTINATION_ID" \
|
||||
-sdk iphonesimulator \
|
||||
${XCODE_OPTIONS[*]} \
|
||||
"${XCODE_OPTIONS[*]}" \
|
||||
build test \
|
||||
2>&1 | xcpretty $XCPRETTY_FORMAT_OPTIONS
|
||||
fi
|
||||
|
||||
@@ -9,7 +9,7 @@ function setup_build_environment ()
|
||||
# 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 +22,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
|
||||
@@ -32,7 +32,7 @@ function setup_build_environment ()
|
||||
then
|
||||
IPHONEOS_DEPLOYMENT_TARGET="6.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
|
||||
@@ -51,7 +51,7 @@ function setup_build_environment ()
|
||||
function build_all_archs ()
|
||||
{
|
||||
setup_build_environment
|
||||
|
||||
|
||||
local setup=$1
|
||||
local build_arch=$2
|
||||
local finish_build=$3
|
||||
@@ -80,8 +80,8 @@ function build_all_archs ()
|
||||
fi
|
||||
|
||||
SDKNAME="${PLATFORM}${SDKVERSION}"
|
||||
SDKROOT="$(ios_sdk_path ${SDKNAME})"
|
||||
|
||||
SDKROOT="$(sdk_path ${SDKNAME})"
|
||||
|
||||
echo "Building ${LIBRARY_NAME} for ${SDKNAME} ${ARCH}"
|
||||
echo "Please stand by..."
|
||||
|
||||
@@ -92,4 +92,3 @@ function build_all_archs ()
|
||||
# finish the build (usually lipo)
|
||||
eval $finish_build
|
||||
}
|
||||
|
||||
|
||||
+127
-22
@@ -5,34 +5,139 @@ 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"
|
||||
|
||||
if [ "External/libgit2.a" -nt "External/libgit2" ]
|
||||
then
|
||||
echo "No update needed."
|
||||
exit 0
|
||||
if [[ `uname -m` == 'arm64' ]]; then
|
||||
echo "** Running on a Apple Silicon M1"
|
||||
PATH="/opt/homebrew/bin:$PATH"
|
||||
else
|
||||
echo "** Running on a Apple x86"
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
fi
|
||||
|
||||
cd "External/libgit2"
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
source "${SCRIPT_DIR}/xcode_functions.sh"
|
||||
|
||||
if [ -d "build" ]; then
|
||||
function setup_build_environment ()
|
||||
{
|
||||
pushd "$SCRIPT_DIR/.." > /dev/null
|
||||
ROOT_PATH="$PWD"
|
||||
popd > /dev/null
|
||||
|
||||
CLANG="/usr/bin/xcrun clang"
|
||||
CC="${CLANG}"
|
||||
CPP="${CLANG} -E"
|
||||
|
||||
# We need to clear this so that cmake doesn't have a conniption
|
||||
MACOSX_DEPLOYMENT_TARGET=""
|
||||
|
||||
XCODE_MAJOR_VERSION=$(xcode_major_version)
|
||||
XCODE_MINOR_VERSION=$(xcode_minor_version)
|
||||
|
||||
CAN_BUILD_ARM="0"
|
||||
|
||||
# Determine if we can be building for ARM Macs
|
||||
if [ "${XCODE_MAJOR_VERSION}" -ge "13" ]
|
||||
then
|
||||
CAN_BUILD_ARM="1"
|
||||
elif [ "${XCODE_MAJOR_VERSION}" -eq "12" ] && [ "${XCODE_MINOR_VERSION}" -ge "2" ]
|
||||
then
|
||||
CAN_BUILD_ARM="1"
|
||||
fi
|
||||
|
||||
ARCHS="x86_64"
|
||||
if [ "${CAN_BUILD_ARM}" -eq "1" ]
|
||||
then
|
||||
ARCHS="${ARCHS} arm64 arm64e"
|
||||
fi
|
||||
}
|
||||
|
||||
function build_all_archs ()
|
||||
{
|
||||
setup_build_environment
|
||||
|
||||
local setup=$1
|
||||
local build_arch=$2
|
||||
local finish_build=$3
|
||||
|
||||
# run the prepare function
|
||||
eval $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
|
||||
eval $build_arch
|
||||
done
|
||||
|
||||
# finish the build (usually lipo)
|
||||
eval $finish_build
|
||||
}
|
||||
|
||||
function setup ()
|
||||
{
|
||||
if [ "${ROOT_PATH}/External/libgit2-mac/libgit2-mac.a" -nt "${ROOT_PATH}/External/libgit2" ]
|
||||
then
|
||||
echo "No update needed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LIBRARY_NAME="libgit2"
|
||||
LIB_PATH="${ROOT_PATH}/External/libgit2-mac"
|
||||
rm -rf "${LIB_PATH}"
|
||||
|
||||
pushd "${ROOT_PATH}/External/libgit2" > /dev/null
|
||||
}
|
||||
|
||||
function build_libgit2 ()
|
||||
{
|
||||
rm -rf "build"
|
||||
fi
|
||||
mkdir "build"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
pushd "build" > /dev/null
|
||||
|
||||
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||
-DLIBSSH2_INCLUDE_DIRS:PATH=/usr/local/include/ \
|
||||
-DBUILD_CLAR:BOOL=OFF \
|
||||
-DTHREADSAFE:BOOL=ON \
|
||||
..
|
||||
cmake --build .
|
||||
# install the each built arch somewhere sane
|
||||
INSTALL_PREFIX="${LIB_PATH}/${SDKNAME}-${ARCH}.sdk"
|
||||
|
||||
product="libgit2.a"
|
||||
install_path="../../${product}"
|
||||
if [ "${product}" -nt "${install_path}" ]; then
|
||||
cp -v "${product}" "${install_path}"
|
||||
fi
|
||||
mkdir -p "${INSTALL_PREFIX}"
|
||||
|
||||
LOG="${INSTALL_PREFIX}/build-libgit2.log"
|
||||
echo "$LOG"
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET="10.9" 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}" \
|
||||
.. >> "${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
|
||||
}
|
||||
|
||||
build_all_archs setup build_libgit2 fat_binary
|
||||
|
||||
echo "libgit2 has been updated."
|
||||
|
||||
@@ -14,6 +14,11 @@ function xcode_major_version ()
|
||||
xcode_version | awk -F '.' '{ print $1 }'
|
||||
}
|
||||
|
||||
function xcode_minor_version ()
|
||||
{
|
||||
xcode_version | awk -F '.' '{ print $2 }'
|
||||
}
|
||||
|
||||
# Returns the latest iOS SDK version available via xcodebuild.
|
||||
function ios_sdk_version ()
|
||||
{
|
||||
@@ -26,11 +31,22 @@ function ios_sdk_version ()
|
||||
# iPhoneSimulator9.0.sdk - Simulator - iOS 9.0 (iphonesimulator9.0)
|
||||
# SDKVersion: 9.0
|
||||
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
function macos_sdk_version ()
|
||||
{
|
||||
# The grep command produces output like the following, singling out the
|
||||
# SDKVersion of just the Mac SDKs:
|
||||
#
|
||||
# MacOSX11.0.sdk - macOS 11.0 (macosx11.0)
|
||||
# SDKVersion: 11.0
|
||||
# ...
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^MacOSX' | tail -n 1 | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
# Returns the path to the specified iOS SDK name
|
||||
function ios_sdk_path ()
|
||||
function sdk_path ()
|
||||
{
|
||||
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -i $1 | grep 'Path:' | awk '{ print $2 }'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user