use std::time::SystemTime;
use crate::error::Result;
use crate::types::{
AheadBehind, BlameEntry, BranchInfo, BranchTrackingInfo, CommitId, CommitInfo,
CommitQuery, CommitQueryResult,
ConflictSummary, DiffSummary, OperationState, RefInfo, RefKind, RemoteInfo,
RepositoryInfo, SortOrder, StashDetail, StashEntry, StatusDigest,
SubmoduleInfo, SubmoduleSummary, TagInfo, TreeEntry,
WorktreeDetail, WorktreeInfo, WorktreeStatus,
};
pub trait VcsBackend: Send + Sync {
fn status_digest(&self) -> Result<StatusDigest>;
fn local_branches(&self) -> Result<Vec<BranchInfo>>;
fn remote_branches(&self) -> Result<Vec<BranchInfo>>;
fn list_commits(&self) -> Result<Vec<CommitInfo>>;
fn list_commits_sorted(&self, order: SortOrder) -> Result<Vec<CommitInfo>>;
fn log_since(&self, since: SystemTime, until: SystemTime) -> Result<Vec<CommitInfo>>;
fn find_commit(&self, id: &CommitId) -> Result<CommitInfo>;
fn query_commits(&self, _query: CommitQuery) -> Result<CommitQueryResult> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "query_commits" })
}
fn list_tags(&self) -> Result<Vec<TagInfo>>;
fn list_tags_sorted(&self, order: SortOrder) -> Result<Vec<TagInfo>>;
fn diff(&self, from: &CommitId, to: &CommitId) -> Result<DiffSummary>;
fn is_dirty(&self) -> Result<bool>;
fn merge_base(&self, a: &CommitId, b: &CommitId) -> Result<Option<CommitId>>;
fn is_ancestor(&self, candidate: &CommitId, descendant: &CommitId) -> Result<bool>;
fn blame(&self, path: &std::path::Path) -> Result<Vec<BlameEntry>>;
fn worktree_status(&self) -> Result<WorktreeStatus>;
fn file_at_commit(&self, path: &std::path::Path, commit_id: &CommitId) -> Result<Vec<u8>>;
fn ahead_behind(&self, local: &CommitId, upstream: &CommitId) -> Result<AheadBehind>;
fn repository_info(&self) -> Result<RepositoryInfo>;
fn remote_url(&self, _name: &str) -> Result<Option<String>> {
Ok(None)
}
fn submodules(&self) -> Result<Vec<SubmoduleInfo>> {
Ok(Vec::new())
}
fn stash_entries(&self) -> Result<Vec<StashEntry>> {
Ok(Vec::new())
}
fn worktrees(&self) -> Result<Vec<WorktreeInfo>> {
Ok(Vec::new())
}
fn create_tag(&self, _name: &str) -> Result<()> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "create_tag" })
}
fn create_annotated_tag(&self, _name: &str, _message: &str) -> Result<()> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "create_annotated_tag" })
}
fn delete_tag(&self, _name: &str) -> Result<()> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "delete_tag" })
}
fn branch_tracking(&self, _branch: &str) -> Result<BranchTrackingInfo> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "branch_tracking" })
}
fn local_branch_tracking(&self) -> Result<Vec<BranchTrackingInfo>> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "local_branch_tracking" })
}
fn is_merged_into(&self, _branch: &str, _target: &str) -> Result<bool> {
Err(crate::error::Error::UnsupportedBackendFeature {
backend: None,
feature: "is_merged_into",
})
}
fn branch_ahead_behind(&self, _branch: &str) -> Result<Option<AheadBehind>> {
return Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "branch_ahead_behind" })
}
fn operation_state(&self) -> Result<OperationState> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "operation_state" })
}
fn unmerged_paths(&self) -> Result<Vec<std::path::PathBuf>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "unmerged_paths" })
}
fn conflict_summary(&self) -> Result<ConflictSummary> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "conflict_summary" })
}
fn blame_at(&self, _path: &std::path::Path, _commit_id: &CommitId) -> Result<Vec<BlameEntry>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "blame_at" })
}
fn tree_at_commit(&self, _commit_id: &CommitId) -> Result<Vec<TreeEntry>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "tree_at_commit" })
}
fn tree_at_path(&self, _commit_id: &CommitId, _path: &std::path::Path) -> Result<Vec<TreeEntry>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "tree_at_path" })
}
fn remotes(&self) -> Result<Vec<RemoteInfo>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "remotes" })
}
fn references(&self) -> Result<Vec<RefInfo>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "references" })
}
fn references_by_kind(&self, _kind: RefKind) -> Result<Vec<RefInfo>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "references_by_kind" })
}
fn submodule_summaries(&self) -> Result<Vec<SubmoduleSummary>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "submodule_summaries" })
}
fn stash_detail(&self, _index: usize) -> Result<StashDetail> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "stash_detail" })
}
fn stash_diff(&self, _index: usize) -> Result<DiffSummary> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "stash_diff" })
}
fn worktree_details(&self) -> Result<Vec<WorktreeDetail>> {
Err(crate::error::Error::UnsupportedBackendFeature { backend: None, feature: "worktree_details" })
}
}