chore: new way to trim entries

This commit is contained in:
Jason Song 2023-01-04 18:51:28 +08:00
parent a222cb5c1e
commit 925f7f18f5
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5

View File

@ -32,16 +32,13 @@ func ListWorkflows(commit *git.Commit) (git.Entries, error) {
return nil, err return nil, err
} }
idx := 0 ret := make(git.Entries, 0, len(entries))
for _, entry := range entries { for _, entry := range entries {
if !strings.HasSuffix(entry.Name(), ".yml") && !strings.HasSuffix(entry.Name(), ".yaml") { if strings.HasSuffix(entry.Name(), ".yml") || strings.HasSuffix(entry.Name(), ".yaml") {
continue ret = append(ret, entry)
} }
entries[idx] = entry
idx++
} }
return ret, nil
return entries[:idx], nil
} }
func DetectWorkflows(commit *git.Commit, event webhook.HookEventType) (map[string][]byte, error) { func DetectWorkflows(commit *git.Commit, event webhook.HookEventType) (map[string][]byte, error) {