Skip to content

Commit 48fc289

Browse files
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>
1 parent a91954a commit 48fc289

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

pkg/actionpins/actionpins.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,12 @@ func buildByRepoIndex(pins []ActionPin) map[string][]ActionPin {
170170
for _, pin := range pins {
171171
byRepo[pin.Repo] = append(byRepo[pin.Repo], pin)
172172
}
173-
for repo, repoPins := range byRepo {
173+
for _, repoPins := range byRepo {
174174
slices.SortFunc(repoPins, func(a, b ActionPin) int {
175175
v1 := strings.TrimPrefix(a.Version, "v")
176176
v2 := strings.TrimPrefix(b.Version, "v")
177177
return semverutil.Compare(v2, v1) // descending by semver
178178
})
179-
byRepo[repo] = repoPins
180179
}
181180
return byRepo
182181
}
@@ -337,7 +336,7 @@ func ResolveActionPin(actionRepo, version string, ctx *PinContext) (string, erro
337336
if !ctx.Warnings[cacheKey] {
338337
warningMsg := fmt.Sprintf("Unable to pin action %s@%s", actionRepo, version)
339338
if ctx.Resolver != nil {
340-
warningMsg = fmt.Sprintf("Unable to pin action %s@%s: resolution failed", actionRepo, version)
339+
warningMsg += ": resolution failed"
341340
}
342341
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(warningMsg))
343342
ctx.Warnings[cacheKey] = true

0 commit comments

Comments
 (0)