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 {
return
}
if len(builds) == 0 {
if len(builds) == 0 || builds[0].Version == nil {
taskObj.Version = tpl.StartVersion
} else {
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) {
str := r.URL.Query().Get("limit")
limit, err := strconv.Atoi(str)
if err != nil || limit <= 0 || limit > 200 {
if err != nil || limit <= 0 || limit > 200 {
limit = 200
}
GetTasksList(w, r, uint64(limit))

View File

@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"time"
)
@ -75,7 +76,9 @@ func doUpgrade() error {
// findAsset returns the binary for this platform.
func findAsset(release *github.RepositoryRelease) *github.ReleaseAsset {
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
}
}