feat: add commit branch to extra
This commit is contained in:
parent
7b53901a34
commit
0a50f77815
@ -47,6 +47,7 @@ var (
|
|||||||
cond = sync.NewCond(&sync.Mutex{})
|
cond = sync.NewCond(&sync.Mutex{})
|
||||||
register_extra = ""
|
register_extra = ""
|
||||||
commitID string = "{{.CommitID}}"
|
commitID string = "{{.CommitID}}"
|
||||||
|
branch string = "{{.Branch}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -118,7 +119,7 @@ func register (host string) {
|
|||||||
}
|
}
|
||||||
app := os.Getenv("ECHO_APP_ID")
|
app := os.Getenv("ECHO_APP_ID")
|
||||||
log.Printf("app: %v, commit: %v", app, commitID)
|
log.Printf("app: %v, commit: %v", app, commitID)
|
||||||
register_extra = fmt.Sprintf("%v_%v", app, commitID)
|
register_extra = fmt.Sprintf("%v_%v_%v", app, branch, commitID)
|
||||||
// 注册,直接将元信息放在 ws 地址中
|
// 注册,直接将元信息放在 ws 地址中
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("hostname", ps.hostname)
|
v.Set("hostname", ps.hostname)
|
||||||
|
@ -199,7 +199,16 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
|
|||||||
} else {
|
} else {
|
||||||
commitID = strings.TrimRight(string(output), "\n")
|
commitID = strings.TrimRight(string(output), "\n")
|
||||||
}
|
}
|
||||||
log.Infof("[goc][info] commitID: %v", commitID)
|
var branch string
|
||||||
|
cmd = exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||||
|
br, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("git rev-parse Error:", err)
|
||||||
|
} else {
|
||||||
|
branch = strings.TrimRight(string(br), "\n")
|
||||||
|
branch = strings.TrimLeft(string(br), "heads/")
|
||||||
|
}
|
||||||
|
log.Infof("[goc][info] branch: %v --- commitID: %v", branch, commitID)
|
||||||
tmplData := struct {
|
tmplData := struct {
|
||||||
Covers []*PackageCover
|
Covers []*PackageCover
|
||||||
GlobalCoverVarImportPath string
|
GlobalCoverVarImportPath string
|
||||||
@ -207,12 +216,14 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
|
|||||||
Host string
|
Host string
|
||||||
Mode string
|
Mode string
|
||||||
CommitID string
|
CommitID string
|
||||||
|
Branch 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,
|
||||||
|
Branch: branch,
|
||||||
CommitID: commitID,
|
CommitID: commitID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user