1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/pipeline/git/commit.go
Carlos Alexandro Becker 4af2cb00ea
ldflags template
2017-03-25 20:24:38 -03:00

22 lines
359 B
Go

package git
import (
"errors"
"os/exec"
"strings"
)
func commitHash() (string, error) {
cmd := exec.Command(
"git",
"show",
"--format='%H'",
"HEAD",
)
bts, err := cmd.CombinedOutput()
if err != nil {
return "", errors.New(err.Error() + ": " + string(bts))
}
return strings.Replace(strings.Split(string(bts), "\n")[0], "'", "", -1), err
}