fix(be): checking build version by nil

This commit is contained in:
Denis Gukov 2022-01-26 16:52:31 +05:00
parent a68c64cbaa
commit f5ad81f7c0
2 changed files with 6 additions and 3 deletions

View File

@ -90,7 +90,7 @@ func AddTaskToPool(d db.Store, taskObj db.Task, userID *int, projectID int) (new
if err != nil { if err != nil {
return return
} }
if len(builds) == 0 { if len(builds) == 0 || builds[0].Version == nil {
taskObj.Version = tpl.StartVersion taskObj.Version = tpl.StartVersion
} else { } else {
v := getNextBuildVersion(*tpl.StartVersion, *builds[0].Version) v := getNextBuildVersion(*tpl.StartVersion, *builds[0].Version)
@ -180,7 +180,7 @@ func GetAllTasks(w http.ResponseWriter, r *http.Request) {
func GetLastTasks(w http.ResponseWriter, r *http.Request) { func GetLastTasks(w http.ResponseWriter, r *http.Request) {
str := r.URL.Query().Get("limit") str := r.URL.Query().Get("limit")
limit, err := strconv.Atoi(str) limit, err := strconv.Atoi(str)
if err != nil || limit <= 0 || limit > 200 { if err != nil || limit <= 0 || limit > 200 {
limit = 200 limit = 200
} }
GetTasksList(w, r, uint64(limit)) GetTasksList(w, r, uint64(limit))

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings"
"time" "time"
) )
@ -75,7 +76,9 @@ func doUpgrade() error {
// findAsset returns the binary for this platform. // findAsset returns the binary for this platform.
func findAsset(release *github.RepositoryRelease) *github.ReleaseAsset { func findAsset(release *github.RepositoryRelease) *github.ReleaseAsset {
for _, asset := range release.Assets { for _, asset := range release.Assets {
if *asset.Name == fmt.Sprintf("semaphore_%s_%s", runtime.GOOS, runtime.GOARCH) { suffix := fmt.Sprintf("_%s_%s.tar.gz", runtime.GOOS, runtime.GOARCH)
if strings.HasPrefix(*asset.Name, "semaphore_") &&
strings.HasSuffix(*asset.Name, suffix) {
return &asset return &asset
} }
} }