9 releases (breaking)

0.6.0 Jan 23, 2022
0.5.0 Dec 20, 2021
0.4.0 Nov 14, 2021
0.3.1 Feb 27, 2021
0.0.1 Feb 6, 2021

#576 in Build Utils


Used in git-event

MIT license

51KB
962 lines

git-meta

Crates.io docs.rs licence Github actions build status

Git-meta is a collection of functionality for gathering information about git repos and commits


lib.rs:

Git-meta

Git-meta is a collection of functionality for gathering information about git repos and commits You can open an existing repo with GitRepo::open(path) (Branch and commits provided for example. Provide None to use current checked out values)

use std::path::PathBuf;
use git_meta::GitRepo;
GitRepo::open(
        PathBuf::from("/path/to/repo"),
        Some("main".to_string()),
        Some("b24fe6112e97eb9ee0cc1fd5aaa520bf8814f6c3".to_string()))
    .expect("Unable to clone repo");

You can create a new repo for cloning with GitRepo::new(url)

use std::path::PathBuf;
use git_meta::{GitCredentials, GitRepo};
use mktemp::Temp;
let temp_dir = Temp::new_dir().expect("Unable to create test clone dir");

let creds = GitCredentials::SshKey {
    username: "git".to_string(),
    public_key: None,
    private_key: PathBuf::from("/path/to/private/key"),
    passphrase: None,
};

GitRepo::new("https://github.com/tjtelan/git-meta-rs")
    .expect("Unable to create GitRepo")
    .with_credentials(Some(creds))
    .to_clone()
    .git_clone_shallow(temp_dir.as_path())
    .expect("Unable to clone repo");

Note: Shallow cloning requires git CLI to be installed

Dependencies

~23MB
~468K SLoC