Crates.io | gitwrap |
lib.rs | gitwrap |
version | |
source | src |
created_at | 2024-12-03 11:07:08.085893 |
updated_at | 2024-12-12 19:16:28.150116 |
description | GitWrap is a simple wrapper around `git` command |
homepage | |
repository | https://github.com/japiber/gitwrap |
max_upload_size | |
id | 1469875 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
GitWrap is a simple wrapper around git
command.
The purpose of this library is to provide a controlled and reliable method of accessing the git commands in the simplest possible way.
This project is in progress, not all git commands / options are implemented yet.
This project is inspired and based on Go Git Cmd Wrapper
The code is licensed under the permissive Apache v2.0 licence. This means you can do what you like with the software, as long as you include the required notices. Read this for a summary.
cargo install gitwrap
Running the above command will globally install the gitwrap binary. Install as library
Run the following Cargo command in your project directory:
cargo add gitwrap
Or add the following line to your Cargo.toml:
gitwrap = "0.5.1"
Here are some examples of use (work in progress)
use gitwrap::clone;
fn initialize(repo_url: &str, repo_path: &str) {
let mut cmd = clone::clone(None);
cmd.option(clone::repository(repo_url));
cmd.option(clone::directory(repo_path));
cmd.option(clone::config("http.sslVerify", "false"));
assert!(cmd.execute().is_ok());
}
fn initialize(repo_url: &str, repo_path: &str) {
let cmd = clone!(None,
clone::repository("https://github.com/japiber/gitwrap.git"),
clone::directory(path.as_str()),
clone::config("http.sslVerify", "false"));
assert!(cmd.execute().is_ok());
}
use gitwrap::config;
fn set_repo_config(commit_email: &str, repo_path: &str) {
let mut cmd = config::config(Some(repo_path));
cmd.option(config::entry("user.email", commit_email));
assert!(cmd.execute().is_ok());
}
use gitwrap::rev_parse;
fn is_repo_valid(repo_path: &str) {
let mut cmd = rev_parse::rev_parse(Some(repo_path));
cmd.option(rev_parse::is_inside_work_tree());
let r = cmd.execute();
assert!(r.is_ok());
assert!(r.ok().unwrap().contains("true"));
}