git_prole/git/
git_like.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use std::process::Command;

use camino::Utf8Path;

use super::Git;
use super::GitBranch;
use super::GitConfig;
use super::GitPath;
use super::GitRefs;
use super::GitRemote;
use super::GitStatus;
use super::GitWorktree;

pub trait GitLike: Sized {
    type CurrentDir: AsRef<Utf8Path>;

    fn as_git(&self) -> &Git<Self::CurrentDir>;

    #[inline]
    fn get_current_dir(&self) -> &Self::CurrentDir {
        self.as_git().get_current_dir()
    }

    /// Get a `git` command.
    #[inline]
    fn command(&self) -> Command {
        self.as_git().command()
    }

    /// Methods for dealing with Git remotes.
    #[inline]
    fn remote(&self) -> GitRemote<'_, Self> {
        GitRemote::new(self)
    }

    /// Methods for dealing with Git remotes.
    #[inline]
    fn path(&self) -> GitPath<'_, Self> {
        GitPath::new(self)
    }

    /// Methods for dealing with Git remotes.
    #[inline]
    fn worktree(&self) -> GitWorktree<'_, Self> {
        GitWorktree::new(self)
    }

    /// Methods for dealing with Git refs.
    #[inline]
    fn refs(&self) -> GitRefs<'_, Self> {
        GitRefs::new(self)
    }

    /// Methods for dealing with Git statuses and the working tree.
    #[inline]
    fn status(&self) -> GitStatus<'_, Self> {
        GitStatus::new(self)
    }

    /// Methods for dealing with Git statuses and the working tree.
    #[inline]
    fn config(&self) -> GitConfig<'_, Self> {
        GitConfig::new(self)
    }

    /// Methods for dealing with Git statuses and the working tree.
    #[inline]
    fn branch(&self) -> GitBranch<'_, Self> {
        GitBranch::new(self)
    }
}