Skip to content

Commit

Permalink
Revert "修复版本比较bug" (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
qjfoidnh authored Mar 6, 2021
1 parent ae82230 commit dcbc9a8
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions internal/pcsupdate/pcsupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func CheckUpdate(version string, yes bool) {
}

// 没有更新, 或忽略 Beta 版本, 和版本前缀不符的
if strings.Contains(releaseInfo.TagName, "Beta") || !strings.HasPrefix(releaseInfo.TagName, "v") || needUpdate(version, releaseInfo.TagName) {
if strings.Contains(releaseInfo.TagName, "Beta") || !strings.HasPrefix(releaseInfo.TagName, "v") || version >= releaseInfo.TagName {
fmt.Printf("未检测到更新!\n")
return
}
Expand Down Expand Up @@ -255,17 +255,3 @@ func CheckUpdate(version string, yes bool) {

fmt.Printf("更新完毕, 请重启程序\n")
}

func needUpdate(current, latest string) bool {
// 去除第一个字符'v'
v1 := strings.Split(current[1:], ".")
v2 := strings.Split(latest[1:], ".")
for i := range v1 {
a, _ := strconv.Atoi(v1[i])
b, _ := strconv.Atoi(v2[i])
if a < b {
return true
}
}
return false
}

0 comments on commit dcbc9a8

Please sign in to comment.