fix check-versions

This commit is contained in:
Greg Gauthier 2021-03-10 11:19:50 +00:00
parent f8c371d0a2
commit c4f3cc5afc
2 changed files with 8 additions and 26 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@
build/
vendor/
*.code-workspace
*.iml
*.iml

View File

@ -2,43 +2,25 @@ package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"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 {
validateos()
var cmdargs = strings.Split(cmdstr, " ") // string arrayified
var cmd = cmdargs[0] // command
func execute(cmdstr string) (string, error) {
cmdargs := strings.Split(cmdstr, " ") // string arrayified
cmd := cmdargs[0] // command
cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd
out, err := exec.Command(cmd, cmdargs...).CombinedOutput()
var output string
if err != nil {
output = err.Error()
} else {
output = string(out[:])
}
return output
return string(out[:]), err
}
func main() {
gitver := execute("git --version")
gitver, _ := execute("git --version")
verno := strings.Split(gitver, " ")[2]
fmt.Println(verno)
gcnf := execute("git config -l")
gcnf, _ := execute("git config -l")
config := strings.Split(gcnf, "\n")
for i, v := range config {
@ -51,7 +33,7 @@ func main() {
fmt.Printf("%d: %s = '%s' \n", i, key, val)
}
glog := execute("git log --oneline")
glog, _ := execute("git log --oneline")
logarray := strings.Split(glog, "\n")
for _, v := range logarray {
entryarray := strings.SplitN(v, " ", 2)