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
9 + GitWorkdirDiffProvider
10 + GitStatusProvider
11 + GitStagingProvider
12 + GitCommitProvider
13 + GitTagProvider
14{
15}
16impl<
17 T: GitDiffProvider
18 + GitWorkdirDiffProvider
19 + GitStatusProvider
20 + GitStagingProvider
21 + GitCommitProvider
22 + GitTagProvider,
23> FullGitProvider for T
24{
25}
26
27pub trait GitDiffProvider: Send + Sync {
28 fn changed_files(&self, project_root: &Path, base: &str, head: &str)
32 -> Result<Vec<FileChange>>;
33}
34
35pub trait GitWorkdirDiffProvider: Send + Sync {
36 fn uncommitted_changes(&self, project_root: &Path) -> Result<Vec<FileChange>>;
40}
41
42pub trait GitStatusProvider: Send + Sync {
43 fn is_working_tree_clean(&self, project_root: &Path) -> Result<bool>;
47
48 fn current_branch(&self, project_root: &Path) -> Result<String>;
52
53 fn remote_url(&self, project_root: &Path) -> Result<Option<String>>;
57}
58
59pub trait GitStagingProvider: Send + Sync {
60 fn stage_files(&self, project_root: &Path, paths: &[&Path]) -> Result<()>;
64
65 fn delete_files(&self, project_root: &Path, paths: &[&Path]) -> Result<()>;
72}
73
74pub trait GitCommitProvider: Send + Sync {
75 fn commit(&self, project_root: &Path, message: &str) -> Result<CommitInfo>;
79
80 fn reset_to_parent(&self, project_root: &Path) -> Result<()>;
86}
87
88pub trait GitTagProvider: Send + Sync {
89 fn create_tag(&self, project_root: &Path, tag_name: &str, message: &str) -> Result<TagInfo>;
93
94 fn delete_tag(&self, project_root: &Path, tag_name: &str) -> Result<bool>;
100}