use rskit_errors::AppResult;
use crate::options::{
CheckoutOptions, CherryPickOptions, CommitOptions, MergeOptions, RebaseOptions,
};
use crate::types::{MergeResult, Oid, RebaseResult, ResetMode, StashEntry, StatusEntry};
pub trait IndexManager {
fn stage(&self, paths: &[&str]) -> AppResult<()>;
fn unstage(&self, paths: &[&str]) -> AppResult<()>;
fn staged_entries(&self) -> AppResult<Vec<StatusEntry>>;
}
pub trait Committer {
fn commit(&self, message: &str, opts: Option<&CommitOptions>) -> AppResult<Oid>;
}
pub trait Merger {
fn merge(&self, branch: &str, opts: Option<&MergeOptions>) -> AppResult<MergeResult>;
fn abort_merge(&self) -> AppResult<()>;
fn merge_abort(&self) -> AppResult<()> {
self.abort_merge()
}
}
pub trait Rebaser {
fn rebase(&self, onto: &str, opts: Option<&RebaseOptions>) -> AppResult<RebaseResult>;
fn abort_rebase(&self) -> AppResult<()>;
fn continue_rebase(&self) -> AppResult<RebaseResult>;
fn rebase_abort(&self) -> AppResult<()> {
self.abort_rebase()
}
fn rebase_continue(&self) -> AppResult<RebaseResult> {
self.continue_rebase()
}
}
pub trait CherryPicker {
fn cherry_pick(&self, commit: &str, opts: Option<&CherryPickOptions>) -> AppResult<Oid>;
fn cherry_pick_continue(&self) -> AppResult<Oid>;
fn cherry_pick_abort(&self) -> AppResult<()>;
}
pub trait Resetter {
fn reset(&self, target: &str, mode: ResetMode) -> AppResult<()>;
}
pub trait CheckoutManager {
fn checkout(&self, ref_name: &str, opts: Option<&CheckoutOptions>) -> AppResult<()>;
fn checkout_files(&self, paths: &[&str]) -> AppResult<()>;
}
pub trait Stasher {
fn stash(&self, message: &str) -> AppResult<Oid>;
fn stash_push(&self, message: &str) -> AppResult<Oid> {
self.stash(message)
}
fn stash_pop(&self) -> AppResult<()>;
fn stash_pop_index(&self, index: usize) -> AppResult<()>;
fn stash_list(&self) -> AppResult<Vec<StashEntry>>;
}