-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (38 loc) · 827 Bytes
/
main.go
File metadata and controls
42 lines (38 loc) · 827 Bytes
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
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"strings"
)
// array of commands
var commands = []string{
"git add .",
"git commit -m",
"git push origin gitpush",
"git checkout main",
"git pull origin main",
"git merge gitpush",
"git push origin main",
"git checkout gitpush",
}
func main() {
fmt.Print("Enter Commit Message: ")
reader := bufio.NewReader(os.Stdin)
cmdString, err := reader.ReadString('\n')
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
cmdString = strings.Replace(cmdString, "\n", "", -1)
commands[1] = commands[1] + " " + `"` + cmdString + `"`
for _, cmd := range commands {
fmt.Println(cmd)
command := exec.Command("bash", "-c", cmd)
command.Stdout = os.Stdout
command.Stderr = os.Stderr
if err := command.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
}