add some other git examples

This commit is contained in:
Greg Gauthier 2021-03-08 22:43:59 +00:00
parent 64431969ad
commit 45fca69634

View File

@ -36,4 +36,29 @@ func execute(cmdstr string) string {
func main() { func main() {
gitver := execute("git --version") gitver := execute("git --version")
fmt.Println(gitver) fmt.Println(gitver)
gcnf := execute("git config -l")
config := strings.Split(gcnf, "\n")
for i, v := range config {
entry := strings.Split(v, "=")
if len(entry) < 2 {
continue
}
key := entry[0]
val := entry[1]
fmt.Printf("%d: %s = '%s' \n", i, key, val)
}
glog := execute("git log --oneline")
logarray := strings.Split(glog, "\n")
for _, v := range logarray {
entryarray := strings.SplitN(v, " ", 2)
if len(entryarray) < 2 {
continue
}
commitid := entryarray[0]
reason := entryarray[1]
fmt.Println(commitid, reason)
}
} }