- Notifications
You must be signed in to change notification settings - Fork179
SwiftGit2/SwiftGit2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Swift bindings tolibgit2.
letURL:URL=...letresult=Repository.at(URL)switch result{caselet.success(repo):letlatestCommit= repo.HEAD().flatMap{ repo.commit($0.oid)}switch latestCommit{caselet.success(commit):print("Latest Commit:\(commit.message) by\(commit.author.name)")caselet.failure(error):print("Could not get commit:\(error)")}caselet.failure(error):print("Could not open repository:\(error)")}
SwiftGit2 uses value objects wherever possible. That means using Swift’sstruct
s andenum
s 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 onlyclass
:Repository
. This highlights the failability and mutation of these methods, while freeing up all other instances to be immutablestruct
s andenum
s.
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
The easiest way to add SwiftGit2 to your project is to useCarthage. Simply addgithub "SwiftGit2/SwiftGit2"
to yourCartfile
and runcarthage update
.
If you’d like, you can do things thehard old-fashioned way:
- Add SwiftGit2 as a submodule of your project’s repository.
- Run
git submodule update --init --recursive
to fetch all of SwiftGit2’s depedencies. - Add
SwiftGit2.xcodeproj
to your project’s Xcode project or workspace. - 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. - 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.
If you want to build a copy of SwiftGit2 without Carthage, possibly for development:
- Clone SwiftGit2
- Run
git submodule update --init --recursive
to clone the submodules - Build in Xcode
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’sSwift Style Guide.
SwiftGit2 is available under the MIT license.
About
Swift bindings to libgit2
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.