add ldflags for branch to gothub update
このコミットが含まれているのは:
コミット
6a30308d82
|
@ -3,6 +3,7 @@ package gothub
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -30,6 +31,9 @@ func update() {
|
|||
os.Exit(1)
|
||||
}
|
||||
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
|
||||
gitPull.Stdout = &out
|
||||
err := gitPull.Run()
|
||||
|
@ -42,7 +46,7 @@ func update() {
|
|||
os.Exit(1)
|
||||
}
|
||||
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 {
|
||||
fmt.Println("Couldn't build GotHub.", err)
|
||||
os.Exit(1)
|
||||
|
@ -51,7 +55,7 @@ func update() {
|
|||
os.Exit(0)
|
||||
}
|
||||
} else {
|
||||
err := exec.Command("go", "build").Run()
|
||||
err := exec.Command("go", "build", "-ldflags", ldFlags).Run()
|
||||
if err != nil {
|
||||
fmt.Println("Couldn't build GotHub.", err)
|
||||
os.Exit(1)
|
||||
|
|
読み込み中…
新しいイシューから参照