git_prole/git/
git_like.rs

1use std::process::Command;
2
3use camino::Utf8Path;
4
5use super::Git;
6use super::GitBranch;
7use super::GitConfig;
8use super::GitPath;
9use super::GitRefs;
10use super::GitRemote;
11use super::GitStatus;
12use super::GitWorktree;
13
14pub trait GitLike: Sized {
15    type CurrentDir: AsRef<Utf8Path>;
16
17    fn as_git(&self) -> &Git<Self::CurrentDir>;
18
19    #[inline]
20    fn get_current_dir(&self) -> &Self::CurrentDir {
21        self.as_git().get_current_dir()
22    }
23
24    /// Get a `git` command.
25    #[inline]
26    fn command(&self) -> Command {
27        self.as_git().command()
28    }
29
30    /// Methods for dealing with Git remotes.
31    #[inline]
32    fn remote(&self) -> GitRemote<'_, Self> {
33        GitRemote::new(self)
34    }
35
36    /// Methods for dealing with Git remotes.
37    #[inline]
38    fn path(&self) -> GitPath<'_, Self> {
39        GitPath::new(self)
40    }
41
42    /// Methods for dealing with Git remotes.
43    #[inline]
44    fn worktree(&self) -> GitWorktree<'_, Self> {
45        GitWorktree::new(self)
46    }
47
48    /// Methods for dealing with Git refs.
49    #[inline]
50    fn refs(&self) -> GitRefs<'_, Self> {
51        GitRefs::new(self)
52    }
53
54    /// Methods for dealing with Git statuses and the working tree.
55    #[inline]
56    fn status(&self) -> GitStatus<'_, Self> {
57        GitStatus::new(self)
58    }
59
60    /// Methods for dealing with Git statuses and the working tree.
61    #[inline]
62    fn config(&self) -> GitConfig<'_, Self> {
63        GitConfig::new(self)
64    }
65
66    /// Methods for dealing with Git statuses and the working tree.
67    #[inline]
68    fn branch(&self) -> GitBranch<'_, Self> {
69        GitBranch::new(self)
70    }
71}