pub mod blame;
pub mod branch;
pub mod checkout;
pub mod cherrypick;
pub mod commit;
pub mod config;
pub mod diff;
pub mod fetch;
pub mod graph;
mod helpers;
pub mod index;
pub mod log;
pub mod merge;
pub mod object;
pub mod rebase;
pub mod reflog;
pub mod refs;
pub mod remote;
mod repo;
pub mod repository;
pub mod reset;
pub mod stash;
pub mod status;
pub mod submodule;
pub mod tag;
pub mod worktree;
pub use git2;
pub use repo::GitRepo;
#[cfg(test)]
pub(crate) mod test_helpers {
use std::fs;
use std::path::Path;
use std::sync::Arc;
use git2::{Oid, Repository, Signature};
use ironflow_core::operation::{NoopSecretResolver, OperationContext};
pub(crate) fn ctx() -> OperationContext {
OperationContext::new(Arc::new(NoopSecretResolver))
}
pub(crate) fn init_repo(path: &Path) -> Oid {
let repo = Repository::init(path).unwrap();
fs::write(path.join("file.txt"), "content").unwrap();
let mut idx = repo.index().unwrap();
idx.add_path(Path::new("file.txt")).unwrap();
idx.write().unwrap();
let tree = repo.find_tree(idx.write_tree().unwrap()).unwrap();
let sig = Signature::now("Test", "test@test.com").unwrap();
repo.commit(Some("HEAD"), &sig, &sig, "init", &tree, &[])
.unwrap()
}
pub(crate) fn make_two_commits(path: &Path) -> (String, String) {
let repo = Repository::init(path).unwrap();
let sig = Signature::now("Test", "test@test.com").unwrap();
fs::write(path.join("file.txt"), "v1").unwrap();
let mut idx = repo.index().unwrap();
idx.add_path(Path::new("file.txt")).unwrap();
idx.write().unwrap();
let tree = repo.find_tree(idx.write_tree().unwrap()).unwrap();
let c1 = repo
.commit(Some("HEAD"), &sig, &sig, "first", &tree, &[])
.unwrap();
let parent = repo.find_commit(c1).unwrap();
fs::write(path.join("other.txt"), "v2").unwrap();
let mut idx = repo.index().unwrap();
idx.add_path(Path::new("other.txt")).unwrap();
idx.write().unwrap();
let tree2 = repo.find_tree(idx.write_tree().unwrap()).unwrap();
let c2 = repo
.commit(Some("HEAD"), &sig, &sig, "second", &tree2, &[&parent])
.unwrap();
(c1.to_string(), c2.to_string())
}
}