giro

Crates.iogiro
lib.rsgiro
version0.1.2
sourcesrc
created_at2023-03-06 23:22:01.281347
updated_at2023-03-26 13:24:54.572504
descriptionResolve whether a path belongs to a git repository or not
homepage
repositoryhttps://github.com/mantono/giro
max_upload_size
id803081
size7,796
Anton Österberg (mantono)

documentation

README

giro

giro (from git-root) is a crate to for resolving the Git repository root directory, if any, of a path. So essentially, it enables you to find out two things:

  • Does a path belong to a Git repository?
  • If so, what is the root directory of this Git repository?

This crate only exposes one public function: 'git_root'

pub fn git_root<P: AsRef<std::path::Path>>(path: P) -> Result<Option<PathBuf>, std::io::Error>

Having this isolated functionality in a create means that other applications or crates may be able to use this crate over for example git2 or similar crates when they are only used for this functionality.

Usage

Library (crate)

Run

cargo add giro

or add

giro = "0.1"

to your projects Cargo.toml.

Then call it with

let root: Option<std::path::PathBuf> = giro::git_root("some/path")?;

Application (binary)

This will install giro as a git plugin. The binary will be installed as git-root.

cargo install giro

then run

git root

to check if the current directory is inside a git repository or not.

Man Pages

If you want man pages for the git-root binary, it can be added by copying the file git-root.1.man to a directory in your $MANPATH.

Commit count: 37

cargo fmt