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
use color_eyre::eyre::Result;
use std::process::Command;

use crate::Vcs;

const TOOL: &str = "git";

#[derive(Default)]
pub struct Git;

impl Vcs for Git {
    fn commit(&self, path: &str, message: &str) -> Result<()> {
        let mut child = Command::new(TOOL)
            .current_dir(path)
            .arg("commit")
            .arg("-a")
            .arg("-m")
            .arg(message)
            .spawn()?;
        child.wait()?;
        Ok(())
    }

    fn create_tag(&self, path: &str, tag: &str) -> Result<()> {
        let mut child = Command::new(TOOL)
            .current_dir(path)
            .arg("tag")
            .arg(tag)
            .spawn()?;
        child.wait()?;
        Ok(())
    }

    fn push_tag(&self, path: &str, tag: &str) -> Result<()> {
        let mut child = Command::new(TOOL)
            .current_dir(path)
            .arg("push")
            .arg("origin")
            .arg("tag")
            .arg(tag)
            .spawn()?;
        child.wait()?;
        Ok(())
    }
}