feat: add commit HASH to extra v2
This commit is contained in:
parent
5666ec4b51
commit
8a3b9214ae
@ -16,6 +16,7 @@ package build
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -189,18 +190,28 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
|
|||||||
} else {
|
} else {
|
||||||
_coverMode = b.Mode
|
_coverMode = b.Mode
|
||||||
}
|
}
|
||||||
|
var CommitID string
|
||||||
|
cmd := exec.Command("git", "describe", "--abbrev=8", "--always")
|
||||||
|
output, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("git describe Error:", err)
|
||||||
|
} else {
|
||||||
|
CommitID = string(output)
|
||||||
|
}
|
||||||
tmplData := struct {
|
tmplData := struct {
|
||||||
Covers []*PackageCover
|
Covers []*PackageCover
|
||||||
GlobalCoverVarImportPath string
|
GlobalCoverVarImportPath string
|
||||||
Package string
|
Package string
|
||||||
Host string
|
Host string
|
||||||
Mode string
|
Mode string
|
||||||
|
CommitID string
|
||||||
}{
|
}{
|
||||||
Covers: covers,
|
Covers: covers,
|
||||||
GlobalCoverVarImportPath: b.GlobalCoverVarImportPath,
|
GlobalCoverVarImportPath: b.GlobalCoverVarImportPath,
|
||||||
Package: injectPkgName,
|
Package: injectPkgName,
|
||||||
Host: b.Host,
|
Host: b.Host,
|
||||||
Mode: _coverMode,
|
Mode: _coverMode,
|
||||||
|
CommitID: CommitID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := coverMainTmpl.Execute(f2, tmplData); err != nil {
|
if err := coverMainTmpl.Execute(f2, tmplData); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user