From 925f7f18f565675cbb4769371cb6915e2f8c25fe Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 4 Jan 2023 18:51:28 +0800 Subject: [PATCH] chore: new way to trim entries --- modules/actions/workflows.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go index 8ae38a8f26..c2a1544d32 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -32,16 +32,13 @@ func ListWorkflows(commit *git.Commit) (git.Entries, error) { return nil, err } - idx := 0 + ret := make(git.Entries, 0, len(entries)) for _, entry := range entries { - if !strings.HasSuffix(entry.Name(), ".yml") && !strings.HasSuffix(entry.Name(), ".yaml") { - continue + if strings.HasSuffix(entry.Name(), ".yml") || strings.HasSuffix(entry.Name(), ".yaml") { + ret = append(ret, entry) } - entries[idx] = entry - idx++ } - - return entries[:idx], nil + return ret, nil } func DetectWorkflows(commit *git.Commit, event webhook.HookEventType) (map[string][]byte, error) {