pub mod blame;
pub mod commit;
pub mod deflate;
pub mod diff;
pub mod error;
pub mod merge_base;
pub mod object;
pub mod oid;
pub mod pack;
pub mod pack_index;
pub mod repo;
pub mod revwalk;
pub mod sha1;
pub mod tree;
pub use blame::{blame_file, BlameHunk};
pub use commit::RawCommit;
pub use diff::{
compute_stats, diff_blobs, diff_trees, diff_trees_with_stats, DiffDelta, DiffHunk, DiffStats,
DiffStatus,
};
pub use error::GitError;
pub use object::ObjectType;
pub use oid::Oid;
pub use repo::RawRepo;
pub use revwalk::RevWalk;
pub use tree::{parse_tree, TreeEntry};
#[cfg(test)]
pub(crate) mod tests {
use std::path::PathBuf;
pub fn find_repo_git_dir() -> PathBuf {
let manifest = env!("CARGO_MANIFEST_DIR");
let out = std::process::Command::new("git")
.args(["-C", manifest, "rev-parse", "--git-common-dir"])
.output()
.expect("failed to run `git rev-parse --git-common-dir`");
assert!(
out.status.success(),
"not in a git repo (`git rev-parse --git-common-dir` failed): {}",
String::from_utf8_lossy(&out.stderr)
);
let raw = String::from_utf8_lossy(&out.stdout);
let raw = raw.trim();
assert!(
!raw.is_empty(),
"`git rev-parse --git-common-dir` returned empty output"
);
let p = PathBuf::from(raw);
if p.is_absolute() {
p
} else {
PathBuf::from(manifest).join(p)
}
}
}