add ldflags for branch to gothub update
このコミットが含まれているのは:
コミット
6a30308d82
|
@ -3,6 +3,7 @@ package gothub
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
@ -30,6 +31,9 @@ func update() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
gitPull := exec.Command("git", "pull")
|
gitPull := exec.Command("git", "pull")
|
||||||
|
curBranch := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||||
|
curBranchOut, _ := curBranch.CombinedOutput()
|
||||||
|
ldFlags := "-X codeberg.org/gothub/gothub/utils.Branch=" + strings.Replace(string(curBranchOut), "\n", "", -1)
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
gitPull.Stdout = &out
|
gitPull.Stdout = &out
|
||||||
err := gitPull.Run()
|
err := gitPull.Run()
|
||||||
|
@ -42,7 +46,7 @@ func update() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
err := exec.Command("go", "build", "-o", "gothub.exe").Run()
|
err := exec.Command("go", "build", "-o", "gothub.exe", ldFlags).Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Couldn't build GotHub.", err)
|
fmt.Println("Couldn't build GotHub.", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -51,7 +55,7 @@ func update() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := exec.Command("go", "build").Run()
|
err := exec.Command("go", "build", "-ldflags", ldFlags).Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Couldn't build GotHub.", err)
|
fmt.Println("Couldn't build GotHub.", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
読み込み中…
新しいイシューから参照