From 48fc289a8ba568c1d5ce821292bb6b7f1e42c8fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2026 11:32:19 +0000 Subject: [PATCH] refactor(actionpins): remove redundant slice write-back and simplify warning message - buildByRepoIndex: slices.SortFunc sorts the backing array in-place; the subsequent byRepo[repo] = repoPins write-back was a no-op since both the map value and the range variable share the same underlying array. Remove the redundant assignment and the unused loop key. - ResolveActionPin: replace a full fmt.Sprintf reassignment of warningMsg with a string append (warningMsg += ": resolution failed"), making it clear the base message is fixed and only the suffix varies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/actionpins/actionpins.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/actionpins/actionpins.go b/pkg/actionpins/actionpins.go index 26f070ac6a7..2e81464281d 100644 --- a/pkg/actionpins/actionpins.go +++ b/pkg/actionpins/actionpins.go @@ -170,13 +170,12 @@ func buildByRepoIndex(pins []ActionPin) map[string][]ActionPin { for _, pin := range pins { byRepo[pin.Repo] = append(byRepo[pin.Repo], pin) } - for repo, repoPins := range byRepo { + for _, repoPins := range byRepo { slices.SortFunc(repoPins, func(a, b ActionPin) int { v1 := strings.TrimPrefix(a.Version, "v") v2 := strings.TrimPrefix(b.Version, "v") return semverutil.Compare(v2, v1) // descending by semver }) - byRepo[repo] = repoPins } return byRepo } @@ -337,7 +336,7 @@ func ResolveActionPin(actionRepo, version string, ctx *PinContext) (string, erro if !ctx.Warnings[cacheKey] { warningMsg := fmt.Sprintf("Unable to pin action %s@%s", actionRepo, version) if ctx.Resolver != nil { - warningMsg = fmt.Sprintf("Unable to pin action %s@%s: resolution failed", actionRepo, version) + warningMsg += ": resolution failed" } fmt.Fprintln(os.Stderr, console.FormatWarningMessage(warningMsg)) ctx.Warnings[cacheKey] = true