| 1 |
# git2-rs |
| 2 |
|
| 3 |
[Documentation](https://docs.rs/git2) |
| 4 |
|
| 5 |
libgit2 bindings for Rust. |
| 6 |
|
| 7 |
``` |
| 8 |
cargo add git2 |
| 9 |
``` |
| 10 |
|
| 11 |
## Features |
| 12 |
|
| 13 |
By default, git2 includes support for working with local repositories, but does |
| 14 |
not include network support (e.g. cloning remote repositories). If you want to |
| 15 |
use features that require network support, you may need the `"https"` and/or |
| 16 |
`"ssh"` features. If you support user-provided repository URLs, you probably |
| 17 |
want to enable both. |
| 18 |
|
| 19 |
``` |
| 20 |
cargo add git2 --features https,ssh |
| 21 |
``` |
| 22 |
|
| 23 |
## Rust version requirements |
| 24 |
|
| 25 |
git2-rs works with stable Rust, and typically works with the most recent prior |
| 26 |
stable release as well. |
| 27 |
|
| 28 |
## Version of libgit2 |
| 29 |
|
| 30 |
Currently this library requires libgit2 1.9.0 (or newer patch versions). The |
| 31 |
source for libgit2 is included in the libgit2-sys crate so there's no need to |
| 32 |
pre-install the libgit2 library, the libgit2-sys crate will figure that and/or |
| 33 |
build that for you. On the other hand, if an appropriate version of `libgit2` |
| 34 |
is present, `git2` will attempt to dynamically link it. |
| 35 |
|
| 36 |
To be more precise, the vendored `libgit2` is linked statically if two |
| 37 |
conditions both hold: |
| 38 |
|
| 39 |
- The environment variable `LIBGIT2_NO_VENDOR=1` is **not** set |
| 40 |
- **and** either a) The Cargo feature `vendored-libgit2` is set or b) an |
| 41 |
appropriate version of `libgit2` cannot be found on the system. |
| 42 |
|
| 43 |
In particular, note that the environment variable overrides the Cargo feature. |
| 44 |
|
| 45 |
## Building git2-rs |
| 46 |
|
| 47 |
```sh |
| 48 |
$ git clone https://github.com/rust-lang/git2-rs |
| 49 |
$ cd git2-rs |
| 50 |
$ cargo build |
| 51 |
``` |
| 52 |
|
| 53 |
### Automating Testing |
| 54 |
|
| 55 |
Running tests and handling all of the associated edge cases on every commit |
| 56 |
proves tedious very quickly. You can use GitHub's automated CI to run the |
| 57 |
tests on your commit(s) if you do not run them locally. |
| 58 |
|
| 59 |
## Building on macOS 10.10+ |
| 60 |
|
| 61 |
If the `ssh` feature is enabled then this library depends |
| 62 |
on libssh2 which depends on OpenSSL. To get OpenSSL working follow the |
| 63 |
[`openssl` crate's instructions](https://github.com/sfackler/rust-openssl/blob/master/openssl/src/lib.rs#L31). |
| 64 |
|
| 65 |
# License |
| 66 |
|
| 67 |
This project is licensed under either of |
| 68 |
|
| 69 |
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or |
| 70 |
https://www.apache.org/licenses/LICENSE-2.0) |
| 71 |
* MIT license ([LICENSE-MIT](LICENSE-MIT) or |
| 72 |
https://opensource.org/licenses/MIT) |
| 73 |
|
| 74 |
at your option. |
| 75 |
|
| 76 |
### Contribution |
| 77 |
|
| 78 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 79 |
for inclusion in git2-rs by you, as defined in the Apache-2.0 license, shall be |
| 80 |
dual licensed as above, without any additional terms or conditions. |
| 81 |
|
| 82 |
[pre-commit-hook]: https://gist.github.com/glfmn/0c5e9e2b41b48007ed3497d11e3dbbfa |