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
|
||
|---|---|---|
| Carthage/Checkouts | ||
| External | ||
| script | ||
| SwiftGit2 | ||
| SwiftGit2.xcodeproj | ||
| SwiftGit2.xcworkspace | ||
| SwiftGit2Tests | ||
| .gitignore | ||
| .gitmodules | ||
| .travis.yml | ||
| Cartfile | ||
| Cartfile.private | ||
| Cartfile.resolved | ||
| README.md | ||
SwiftGit2 
Swift bindings to libgit2.
let URL: NSURL = ...
let repo = Repository.atURL(URL)
if let repo = repo.value {
let latestCommit: Result<Commit, NSError> = 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)")
}
} else {
println("Could not open repository: \(repo.error)")
}
SwiftGit2 requires Xcode 6.3 or later.
Design
SwiftGit2 uses value objects wherever possible. That means using Swift’s structs and enums without holding references to libgit2 objects. This has a number of advantages:
- Values can be used concurrently.
- Consuming values won’t result in disk access.
- Disk access can be contained to a smaller number of APIs.
This vastly simplifies the design of long-lived applications, which are the most common use case with Swift. Consequently, SwiftGit2 APIs don’t necessarily map 1-to-1 with libgit2 APIs.
All methods for reading from or writing to a repository are on SwiftGit’s only class: Repository. This highlights the failability and mutation of these methods, while freeing up all other instances to be immutable structs and enums.
Importing SwiftGit2
The easiest way to add SwiftGit2 to your project is to use Carthage. Simply add github "SwiftGit2/SwiftGit2" to your Cartfile and run carthage update.
If you’d like, you can do things the hard old-fashioned way:
- Add SwiftGit2 as a submodule of your project’s repository.
- Run
git submodule update --init --recursiveto fetch all of SwiftGit2’s depedencies. - Add
SwiftGit2.xcodeprojto your project’s Xcode project or workspace. - On the “Build Phases” tab of your application target, add
SwiftGit2.frameworkto the “Link Binary With Libraries” phase. SwiftGit2 must also be added to a “Copy Frameworks” build phase. - 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.
Contributions
We ❤️ to receive pull requests! GitHub makes it easy:
- Fork the repository
- Create a branch with your changes
- Send a Pull Request
All contributions should match GitHub’s Swift Style Guide.
License
SwiftGit2 is available under the MIT license.