Skip to content

Commit 266c9da

Browse files
committed
better Version and BuildTime handle
1 parent f0f82fb commit 266c9da

File tree

1 file changed

+10
-1
lines changed
  • core/src/main/golang/native/delegate

1 file changed

+10
-1
lines changed

core/src/main/golang/native/delegate/init.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package delegate
22

33
import (
44
"errors"
5+
"fmt"
6+
"strings"
57
"syscall"
68

79
"github.com/metacubex/mihomo/component/process"
@@ -19,7 +21,14 @@ var errBlocked = errors.New("blocked")
1921
func Init(home, versionName, gitVersion string, platformVersion int) {
2022
log.Infoln("Init core, home: %s, versionName: %s, gitVersion: %s, platformVersion: %d", home, versionName, gitVersion, platformVersion)
2123
constant.SetHomeDir(home)
22-
constant.Version = gitVersion
24+
// gitVersion = ${CURRENT_BRANCH}_${COMMIT_HASH}_${COMPILE_TIME}
25+
if versions := strings.Split(gitVersion, "_"); len(versions) == 3 {
26+
constant.Version = fmt.Sprintf("%s-%s-CMFA-%s", strings.ToLower(versions[0]), versions[1], strings.ToLower(versionName))
27+
constant.BuildTime = versions[2]
28+
} else {
29+
constant.Version = gitVersion
30+
}
31+
constant.Version = strings.ToLower(constant.Version)
2332
app.ApplyVersionName(versionName)
2433
app.ApplyPlatformVersion(platformVersion)
2534

0 commit comments

Comments
 (0)