mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
parent
0b610017ea
commit
d1e0a38c04
21
build.go
21
build.go
@ -654,7 +654,11 @@ func shouldBuildSyso(dir string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsonPath := filepath.Join(dir, "versioninfo.json")
|
jsonPath := filepath.Join(dir, "versioninfo.json")
|
||||||
ioutil.WriteFile(jsonPath, bs, 0644)
|
err = ioutil.WriteFile(jsonPath, bs, 0644)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.New("failed to create " + jsonPath + ": " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.Remove(jsonPath); err != nil {
|
if err := os.Remove(jsonPath); err != nil {
|
||||||
log.Printf("Warning: unable to remove generated %s: %v. Please remove it manually.", jsonPath, err)
|
log.Printf("Warning: unable to remove generated %s: %v. Please remove it manually.", jsonPath, err)
|
||||||
@ -860,13 +864,22 @@ func getVersion() string {
|
|||||||
return "unknown-dev"
|
return "unknown-dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
func semanticVersion() (major, minor, patch, build string) {
|
func semanticVersion() (major, minor, patch, build int) {
|
||||||
r := regexp.MustCompile(`v(?P<Major>\d+)\.(?P<Minor>\d+).(?P<Patch>\d+).*\+(?P<CommitsAhead>\d+)`)
|
r := regexp.MustCompile(`v(?P<Major>\d+)\.(?P<Minor>\d+).(?P<Patch>\d+).*\+(?P<CommitsAhead>\d+)`)
|
||||||
matches := r.FindStringSubmatch(getVersion())
|
matches := r.FindStringSubmatch(getVersion())
|
||||||
if len(matches) != 5 {
|
if len(matches) != 5 {
|
||||||
return "0", "0", "0", "0"
|
return 0, 0, 0, 0
|
||||||
}
|
}
|
||||||
return matches[1], matches[2], matches[3], matches[4]
|
|
||||||
|
var ints [4]int
|
||||||
|
for i := 1; i < 5; i++ {
|
||||||
|
value, err := strconv.Atoi(matches[i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, 0, 0
|
||||||
|
}
|
||||||
|
ints[i-1] = value
|
||||||
|
}
|
||||||
|
return ints[0], ints[1], ints[2], ints[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBranchSuffix() string {
|
func getBranchSuffix() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user