feat: add commit HASH to extra v2

This commit is contained in:
liruichen 2023-09-07 18:54:17 +08:00
parent 6c11041d9c
commit cb8592a567
3 changed files with 9 additions and 1 deletions

View File

@ -115,7 +115,7 @@ func register (host string) {
time.Sleep(waitDelay)
continue
}
register_extra = os.Getenv("ECHO_APP_ID") + {{.CommitID}}
// 注册,直接将元信息放在 ws 地址中
v := url.Values{}
v.Set("hostname", ps.hostname)

View File

@ -50,6 +50,7 @@ type Build struct {
Pkgs map[string]*Package
GlobalCoverVarImportPath string
GlobalCoverVarImportPathDir string
CommitID string
}
// NewBuild creates a Build struct

View File

@ -64,6 +64,13 @@ func (b *Build) readProjectMetaInfo() {
// get GlobalCoverVarImportPath
b.GlobalCoverVarImportPath = path.Join(b.ImportPath, TmpFolderName(b.CurModProjectDir))
log.Donef("project meta information parsed")
cmd := exec.Command("git", "describe", "--abbrev=8", "--always")
output, err := cmd.Output()
if err != nil {
log.Errorf("git describe Error:", err)
} else {
b.CommitID = string(output)
}
}
// displayProjectMetaInfo prints basic infomation of this project to stdout