fix check-versions
This commit is contained in:
parent
f8c371d0a2
commit
c4f3cc5afc
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,4 +2,4 @@
|
|||||||
build/
|
build/
|
||||||
vendor/
|
vendor/
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
*.iml
|
*.iml
|
||||||
|
@ -2,43 +2,25 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func validateos() {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
fmt.Println("Can't Execute this on a windows machine")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func execute(cmdstr string) string {
|
func execute(cmdstr string) (string, error) {
|
||||||
|
cmdargs := strings.Split(cmdstr, " ") // string arrayified
|
||||||
validateos()
|
cmd := cmdargs[0] // command
|
||||||
|
|
||||||
var cmdargs = strings.Split(cmdstr, " ") // string arrayified
|
|
||||||
var cmd = cmdargs[0] // command
|
|
||||||
cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd
|
cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd
|
||||||
out, err := exec.Command(cmd, cmdargs...).CombinedOutput()
|
out, err := exec.Command(cmd, cmdargs...).CombinedOutput()
|
||||||
var output string
|
return string(out[:]), err
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
output = err.Error()
|
|
||||||
} else {
|
|
||||||
output = string(out[:])
|
|
||||||
}
|
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gitver := execute("git --version")
|
gitver, _ := execute("git --version")
|
||||||
verno := strings.Split(gitver, " ")[2]
|
verno := strings.Split(gitver, " ")[2]
|
||||||
fmt.Println(verno)
|
fmt.Println(verno)
|
||||||
|
|
||||||
gcnf := execute("git config -l")
|
gcnf, _ := execute("git config -l")
|
||||||
|
|
||||||
config := strings.Split(gcnf, "\n")
|
config := strings.Split(gcnf, "\n")
|
||||||
for i, v := range config {
|
for i, v := range config {
|
||||||
@ -51,7 +33,7 @@ func main() {
|
|||||||
fmt.Printf("%d: %s = '%s' \n", i, key, val)
|
fmt.Printf("%d: %s = '%s' \n", i, key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
glog := execute("git log --oneline")
|
glog, _ := execute("git log --oneline")
|
||||||
logarray := strings.Split(glog, "\n")
|
logarray := strings.Split(glog, "\n")
|
||||||
for _, v := range logarray {
|
for _, v := range logarray {
|
||||||
entryarray := strings.SplitN(v, " ", 2)
|
entryarray := strings.SplitN(v, " ", 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user