1use std::process::Command;
2
3use pretty_log::PrettyError;
4
5pub struct Git;
6
7impl Git {
8 pub fn stash() {
9 Command::new("git")
10 .arg("stash")
11 .spawn()
12 .expect_p("[gou] Failed to stash changes")
13 .wait()
14 .expect_p("[gou] Failed to wait for stash changes");
15 }
16
17 pub fn stash_pop() {
18 Command::new("git")
19 .arg("stash")
20 .arg("pop")
21 .spawn()
22 .expect_p("[gou] Failed to pop stash")
23 .wait()
24 .expect_p("[gou] Failed to wait for pop stash");
25 }
26
27 pub fn checkout_create(branch_name: &str) {
28 Command::new("git")
29 .arg("checkout")
30 .arg("-b")
31 .arg(branch_name)
32 .spawn()
33 .expect_p("[gou] Failed to create feat branch")
34 .wait()
35 .expect_p("[gou] Failed to wait for feat branch");
36 }
37
38 pub fn checkout(branch_name: &str) {
39 Command::new("git")
40 .arg("checkout")
41 .arg(branch_name)
42 .spawn()
43 .expect_p("[gou] Failed to checkout feat branch")
44 .wait()
45 .expect_p("[gou] Failed to wait for checkout feat branch");
46 }
47
48 pub fn add() {
49 Command::new("git")
50 .arg("add")
51 .arg(".")
52 .spawn()
53 .expect_p("[gou] Failed to add changes")
54 .wait()
55 .expect_p("[gou] Failed to wait for add changes");
56 }
57
58 pub fn commit(message: &str) {
59 Command::new("git")
60 .arg("commit")
61 .arg("-m")
62 .arg(message)
63 .spawn()
64 .expect_p("[gou] Failed to commit changes")
65 .wait()
66 .expect_p("[gou] Failed to wait for commit changes");
67 }
68
69 pub fn push_set_upstream(branch_name: &str) {
70 Command::new("git")
71 .arg("push")
72 .arg("--set-upstream")
73 .arg("origin")
74 .arg(&branch_name)
75 .spawn()
76 .expect_p("[gou] Failed to push changes")
77 .wait()
78 .expect_p("[gou] Failed to wait for push changes");
79 }
80
81 pub fn pull() {
82 Command::new("git")
83 .arg("pull")
84 .spawn()
85 .expect_p("[gou] Failed to pull changes")
86 .wait()
87 .expect_p("[gou] Failed to wait for pull changes");
88 }
89}