mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add-date-to unstable
This commit is contained in:
parent
5036992b06
commit
4263000f2c
2 changed files with 28 additions and 5 deletions
|
|
@ -98,11 +98,7 @@ func NewApp(gitCommit, usage string) *cli.App {
|
|||
app.Author = ""
|
||||
//app.Authors = nil
|
||||
app.Email = ""
|
||||
app.Version = params.VersionWithMeta
|
||||
if len(gitCommit) >= 8 {
|
||||
app.Version += "-" + gitCommit[:8]
|
||||
}
|
||||
app.Usage = usage
|
||||
app.Version = params.VersionWithCommit(gitCommit)
|
||||
return app
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ package params
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -60,5 +64,28 @@ func VersionWithCommit(gitCommit string) string {
|
|||
if len(gitCommit) >= 8 {
|
||||
vsn += "-" + gitCommit[:8]
|
||||
}
|
||||
if VersionMeta != "stable" {
|
||||
d := getCommitDate(gitCommit)
|
||||
if d != "" {
|
||||
vsn += "-" + d
|
||||
}
|
||||
}
|
||||
return vsn
|
||||
}
|
||||
|
||||
func getCommitDate(commit string) string {
|
||||
if commit != "" {
|
||||
out, err := exec.Command("git", "show", "-s", "--format=%ct", commit).CombinedOutput()
|
||||
if err != nil {
|
||||
log.Println("Could not get gitCommit date: " + string(out))
|
||||
return ""
|
||||
}
|
||||
ti, err := strconv.ParseInt(string(out), 10, 64)
|
||||
if err != nil {
|
||||
log.Println("Could not convert gitCommit date. Parsed timestap is: " + string(out))
|
||||
return ""
|
||||
}
|
||||
return time.Unix(ti, 0).Format("20060102")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue