Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/actionpins/actionpins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/zoom-out] The write-back removal is correct, but a brief inline comment would future-proof this against someone re-adding it as a perceived bug fix.

slices.SortFunc only rearranges elements in the backing array — it never modifies the slice header (pointer/len/cap). The range copy repoPins shares that same backing array, so after sorting, reading byRepo[repo] already reflects the sorted order. Without a comment, future readers might mistake the missing write-back for a bug.

💡 Suggested comment
for _, repoPins := range byRepo {
    // slices.SortFunc sorts the backing array in-place; repoPins shares
    // the same pointer as the map value, so no write-back is needed.
    slices.SortFunc(repoPins, func(a, b ActionPin) int {

This mirrors the existing // descending by semver comment that already documents the other non-obvious aspect of the sort.

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
}
Expand Down Expand Up @@ -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
Expand Down
Loading