use std::num::NonZeroUsize;
use std::path::PathBuf;
use crate::domain::{CommitBaseline, CommitPage, LocalBranch, ObjectId, RepoPath};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum GitCommand {
LocalBranches,
SwitchBranch {
branch: LocalBranch,
},
Discover {
start: PathBuf,
},
IsBare,
HasHead,
Status,
WorktreeDiff {
path: RepoPath,
},
UntrackedDiff {
path: RepoPath,
},
Commits {
page: CommitPage,
},
RepositoryFiles,
Grep {
query: String,
},
FileHistory {
path: RepoPath,
limit: NonZeroUsize,
},
RevisionFile {
revision: ObjectId,
path: RepoPath,
},
CommitMessage {
commit: ObjectId,
},
ChangedFiles {
commit: ObjectId,
baseline: CommitBaseline,
},
CommitDiff {
commit: ObjectId,
baseline: CommitBaseline,
path: RepoPath,
},
TreeEntries {
treeish: ObjectId,
},
}
impl GitCommand {
#[must_use]
pub fn kind(&self) -> &'static str {
match self {
Self::LocalBranches => "list local branches",
Self::SwitchBranch { .. } => "switch branch",
Self::Discover { .. } => "discover repository",
Self::IsBare => "check bare repository",
Self::HasHead => "check HEAD",
Self::Status => "read worktree status",
Self::WorktreeDiff { .. } => "read worktree diff",
Self::UntrackedDiff { .. } => "read untracked diff",
Self::Commits { .. } => "read commit history",
Self::RepositoryFiles => "list repository files",
Self::Grep { .. } => "search repository content",
Self::FileHistory { .. } => "read file history",
Self::RevisionFile { .. } => "read revision file",
Self::CommitMessage { .. } => "read commit message",
Self::ChangedFiles { .. } => "read changed files",
Self::CommitDiff { .. } => "read commit diff",
Self::TreeEntries { .. } => "read tree entries",
}
}
}