mirror of https://github.com/perkeep/perkeep.git
make.go: increase, and enforce, git rev to 10 chars
Issue #839 suggests to not cut the rev at all, and let it be user defined. I have no good argument against, but I'm taking the more conservative approach suggested by others in issue #888. Fixes #888 Change-Id: Id65b1b074e6646a756353119a12081330775e066
This commit is contained in:
parent
66eb0f6c38
commit
02548899a8
5
make.go
5
make.go
|
@ -814,13 +814,14 @@ func getVersion() string {
|
||||||
return gitVersion()
|
return gitVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
var gitVersionRx = regexp.MustCompile(`\b\d\d\d\d-\d\d-\d\d-[0-9a-f]{7,7}\b`)
|
var gitVersionRx = regexp.MustCompile(`\b\d\d\d\d-\d\d-\d\d-[0-9a-f]{10,10}\b`)
|
||||||
|
|
||||||
// gitVersion returns the git version of the git repo at camRoot as a
|
// gitVersion returns the git version of the git repo at camRoot as a
|
||||||
// string of the form "yyyy-mm-dd-xxxxxxx", with an optional trailing
|
// string of the form "yyyy-mm-dd-xxxxxxx", with an optional trailing
|
||||||
// '+' if there are any local uncomitted modifications to the tree.
|
// '+' if there are any local uncomitted modifications to the tree.
|
||||||
func gitVersion() string {
|
func gitVersion() string {
|
||||||
cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'", "--date=short", "HEAD")
|
cmd := exec.Command("git", "rev-list", "--max-count=1", "--pretty=format:'%ad-%h'",
|
||||||
|
"--date=short", "--abbrev=10", "HEAD")
|
||||||
cmd.Dir = camRoot
|
cmd.Dir = camRoot
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -81,6 +81,7 @@ func rev() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func version() string {
|
func version() string {
|
||||||
|
// TODO(mpl): cut the rev to 10 chars, like make.go would do?
|
||||||
if *flagVersion != "" {
|
if *flagVersion != "" {
|
||||||
return fmt.Sprintf("%v (git rev %v)", *flagVersion, rev())
|
return fmt.Sprintf("%v (git rev %v)", *flagVersion, rev())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue