MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / formatVerion

Function formatVerion

cli/main.go:65–89  ·  view source on GitHub ↗

格式化版本号,在stable.txt文件中读取 注:embed 不支持 “..”, 即上级目录

()

Source from the content-addressed store, hash-verified

63// 格式化版本号,在stable.txt文件中读取
64// 注:embed 不支持 “..”, 即上级目录
65func formatVerion() (smartVersion cmd.SmartVersion) {
66
67 // 转换为结构体
68 json.Unmarshal([]byte(stableJson), &smartVersion)
69
70 // 编译时间
71 smartVersion.BuildTime, _ = time.ParseInLocation("2006-01-02 15:04:05", BuildTime, time.Local)
72
73 // 版本号赋值
74 smartVersion.VersionNumber = stable
75 if stable == "$(version)" {
76 smartVersion.VersionNumber = fmt.Sprintf(i18n.GetInstance().Main.Info_version_local, smartVersion.BuildTime.Format("2006-01-02 15:04:05"))
77 common.SmartIDELog.Importance(i18n.GetInstance().Main.Err_version_not_build)
78 } else if stable != "" && !strings.Contains(strings.ToLower(stable), "v") {
79 smartVersion.VersionNumber = "v" + smartVersion.VersionNumber
80 }
81
82 // commit id 截取最后8位
83 if len(smartVersion.TargetCommitish) > 8 {
84 smartVersion.TargetCommitishShort = smartVersion.TargetCommitish[(len(smartVersion.TargetCommitish) - 8):]
85 }
86
87 return smartVersion
88
89}

Callers 1

mainFunction · 0.85

Calls 1

ImportanceMethod · 0.80

Tested by

no test coverage detected