changeset_operations/traits/
git_provider.rs1use std::path::Path;
2
3use changeset_git::{CommitInfo, FileChange, TagInfo};
4
5use crate::Result;
6
7pub trait FullGitProvider:
8 GitDiffProvider + GitStatusProvider + GitStagingProvider + GitCommitProvider + GitTagProvider
9{
10}
11impl<
12 T: GitDiffProvider + GitStatusProvider + GitStagingProvider + GitCommitProvider + GitTagProvider,
13> FullGitProvider for T
14{
15}
16
17pub trait GitDiffProvider: Send + Sync {
18 fn changed_files(&self, project_root: &Path, base: &str, head: &str)
22 -> Result<Vec<FileChange>>;
23}
24
25pub trait GitStatusProvider: Send + Sync {
26 fn is_working_tree_clean(&self, project_root: &Path) -> Result<bool>;
30
31 fn current_branch(&self, project_root: &Path) -> Result<String>;
35
36 fn remote_url(&self, project_root: &Path) -> Result<Option<String>>;
40}
41
42pub trait GitStagingProvider: Send + Sync {
43 fn stage_files(&self, project_root: &Path, paths: &[&Path]) -> Result<()>;
47
48 fn delete_files(&self, project_root: &Path, paths: &[&Path]) -> Result<()>;
55}
56
57pub trait GitCommitProvider: Send + Sync {
58 fn commit(&self, project_root: &Path, message: &str) -> Result<CommitInfo>;
62
63 fn reset_to_parent(&self, project_root: &Path) -> Result<()>;
69}
70
71pub trait GitTagProvider: Send + Sync {
72 fn create_tag(&self, project_root: &Path, tag_name: &str, message: &str) -> Result<TagInfo>;
76
77 fn delete_tag(&self, project_root: &Path, tag_name: &str) -> Result<bool>;
83}