1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00

Sort later, so it is sorted in restarts too

This commit is contained in:
Laszlo Fogas 2019-06-16 15:27:40 +02:00
parent a37866179f
commit a22747f5c3
4 changed files with 10 additions and 9 deletions

View File

@ -79,6 +79,12 @@ type FileMeta struct {
Data []byte Data []byte
} }
type ByName []*FileMeta
func (a ByName) Len() int { return len(a) }
func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name }
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// Refresher refreshes an oauth token and expiration for the given user. It // Refresher refreshes an oauth token and expiration for the given user. It
// returns true if the token was refreshed, false if the token was not refreshed, // returns true if the token was refreshed, false if the token was not refreshed,
// and error if it failed to refersh. // and error if it failed to refersh.

View File

@ -5,8 +5,6 @@ import (
"github.com/laszlocph/drone-oss-08/model" "github.com/laszlocph/drone-oss-08/model"
"github.com/laszlocph/drone-oss-08/remote" "github.com/laszlocph/drone-oss-08/remote"
"sort"
) )
type configFetcher struct { type configFetcher struct {
@ -33,15 +31,8 @@ func (cf *configFetcher) Fetch() ([]*remote.FileMeta, error) {
return nil, direrr return nil, direrr
} }
sort.Sort(byName(dir))
return dir, nil return dir, nil
} }
} }
return []*remote.FileMeta{}, nil return []*remote.FileMeta{}, nil
} }
type byName []*remote.FileMeta
func (a byName) Len() int { return len(a) }
func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name }
func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

View File

@ -321,6 +321,7 @@ func queueBuild(build *model.Build, repo *model.Repo, buildItems []*buildItem) {
task.Labels["platform"] = item.Platform task.Labels["platform"] = item.Platform
task.Labels["repo"] = repo.FullName task.Labels["repo"] = repo.FullName
task.Dependencies = taskIds(item.DependsOn, buildItems) task.Dependencies = taskIds(item.DependsOn, buildItems)
task.DepStatus = make(map[string]bool)
task.Data, _ = json.Marshal(rpc.Pipeline{ task.Data, _ = json.Marshal(rpc.Pipeline{
ID: fmt.Sprint(item.Proc.ID), ID: fmt.Sprint(item.Proc.ID),

View File

@ -18,6 +18,7 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"net/url" "net/url"
"sort"
"strings" "strings"
"github.com/drone/envsubst" "github.com/drone/envsubst"
@ -55,6 +56,8 @@ type buildItem struct {
func (b *procBuilder) Build() ([]*buildItem, error) { func (b *procBuilder) Build() ([]*buildItem, error) {
var items []*buildItem var items []*buildItem
sort.Sort(remote.ByName(b.Yamls))
for j, y := range b.Yamls { for j, y := range b.Yamls {
// matrix axes // matrix axes
axes, err := matrix.ParseString(string(y.Data)) axes, err := matrix.ParseString(string(y.Data))