From a16efaa441bad8cb687aa5aede82684998291c99 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 6 Mar 2018 16:06:32 +0100 Subject: Show local branch and commit in updater --- tools/updater/main.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/updater/main.go b/tools/updater/main.go index e5e377c..eda229b 100644 --- a/tools/updater/main.go +++ b/tools/updater/main.go @@ -30,16 +30,17 @@ func branchmap(repository string) (branches map[string]string, err error) { return } -func poi(executable string) (version string, err error) { - cmd := exec.Command(executable, "--version") +func poi(executable string) (version string, commit string, err error) { + cmd := exec.Command(executable, "--build") // wait for complete err = cmd.Wait() // return output output, err := cmd.Output() - v := strings.Split(string(output), "-") - version = v[len(v)-1] + v := strings.Split(string(output), ":") + version = v[0] + commit = v[1] return } @@ -57,17 +58,21 @@ func main() { os.Exit(0) } - fmt.Println("Getting poi --version") - poi_version, err := poi(*execFlag) + fmt.Println("Getting poi build...") + if *verboseFlag { + fmt.Println("[exec =", *execFlag, "]") + } + + poi_branch, poi_commit, err := poi(*execFlag) if err != nil { fmt.Println("error:", err) } - fmt.Println(poi_version) + fmt.Println("-", poi_branch, ":", poi_commit) // get branchmap fmt.Println("Getting branchmap...") if *verboseFlag { - fmt.Println("for repository", *repoFlag) + fmt.Println("[repo =", *repoFlag, "]") } branches, err := branchmap(*repoFlag) @@ -77,7 +82,7 @@ func main() { } for branch, commit := range branches { - fmt.Println("-", branch, ":", commit[0:len(poi_version)-1]) + fmt.Println("-", branch, ":", commit[0:12]) } } -- cgit v1.2.1