consolidate git operations into a Repo type

This commit is contained in:
2026-10-03 12:46:44 +07:00
parent 4656f1340b
commit 49d351fe06
21 changed files with 2243 additions and 2203 deletions
+8 -31
View File
@@ -11,41 +11,18 @@ mod worktree;
#[cfg(test)]
mod tests;
pub use cache::{GitCache, fork_namespace, sanitize_path_component};
pub use diff::{
CommitDiff, DiffHunk, DiffLine, DiffLineKind, DiffStatus, FileDiff, worktree_commit_diff,
worktree_commit_range_diff,
};
pub use history::{
CommitList, FileCommit, MAX_LISTED_COMMITS, all_commits, head_commit, worktree_all_commits,
worktree_commit, worktree_commit_range_commits, worktree_last_commits,
};
pub use nip34::{
GraspSignals, Nip34Binding, Nip34Kind, detect_nip34, is_grasp_url, set_nostr_repo,
};
pub use patch::{
apply_patch, format_patch_between, patch_commits, patch_diffs, split_patch_series,
};
pub use remote::{
clone_repo, ensure_origin, fetch_all, fetch_repo_refs, origin_url, push_all, push_commit_ref,
push_main, remote_has_refs, set_origin,
};
pub use repo::{
RepoRefState, commits_since, current_branch, delete_refs_with_prefix, fast_forward_branches,
head_commit_id, init_repository, merge_base, refs_with_prefix, repo_branches, repo_ref_state,
repo_tags, root_commit, worktree_branches, worktree_current_branch, worktree_ref_exists,
worktree_ref_state,
};
pub use cache::GitCache;
pub use diff::{CommitDiff, DiffHunk, DiffLine, DiffLineKind, DiffStatus, FileDiff};
pub use history::{CommitList, FileCommit, MAX_LISTED_COMMITS};
pub use nip34::{GraspSignals, Nip34Binding, Nip34Kind};
pub use patch::PatchParser;
pub use repo::{Repo, RepoRefState};
pub use scan::{LocalRepo, find_git_repos};
pub use worktree::{
WorktreeSnapshot, find_readme, worktree_checkout_branch, worktree_checkout_tag,
worktree_commits_ahead, worktree_dirty, worktree_entries, worktree_read, worktree_snapshot,
};
pub use worktree::WorktreeSnapshot;
/// The terminal prompt is disabled so a credential request fails instead of hanging.
#[cfg(test)]
fn git_in(dir: &std::path::Path, args: &[&str]) -> anyhow::Result<String> {
let output = remote::git_output(dir, args, "git")?;
let output = Repo::run_git(dir, args, "git")?;
if !output.status.success() {
anyhow::bail!(