-
Notifications
You must be signed in to change notification settings - Fork 55
/
commit_and_push.go
60 lines (51 loc) · 1.12 KB
/
commit_and_push.go
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
package main
import (
"os/exec"
"errors"
)
func CommitAll(dir string, comment string) (error) {
cmd_add := exec.Command("git", "add", ".")
cmd_add.Dir = dir
error := cmd_add.Run()
if error != nil {
return errors.New("Add Error")
}
//out, err := exec.Command("git", "commit", "-m", comment).Output()
//fmt.Println(string(out))
//if err != nil {
// return errors.New(err.Error())
//}
cmd_commit := exec.Command("git", "commit", "-m", comment)
cmd_commit.Dir = dir
error = cmd_commit.Run()
if error != nil {
return errors.New("Commit Error")
}
return nil
}
func PushRepos(dir string) (error) {
cmd := exec.Command("git", "push")
cmd.Dir = dir
error := cmd.Run()
if error != nil {
return errors.New("Push Error")
}
return nil
}
func CommitAndPush(dir string, comment string) (error) {
error := CommitAll(dir, comment)
if error != nil {
return error
}
error = PushRepos(dir)
if error != nil {
return error
}
return nil
}
func main() {
err := CommitAndPush("/Users/hackurity/Documents/it-chain/test/bloom", "It-Chain Smart Contract \"junbeomlee_bloom\" Deploy")
if err != nil {
panic(err.Error())
}
}