Conversation
…mations Replace imperative sort.Slice and manual map-to-slice loops with stdlib declarative equivalents: - Use slices.Collect(maps.Values(...)) to convert map entries to a slice, replacing the explicit append loop - Use slices.SortFunc with cmp.Compare for cleaner sort comparisons in both getActionPins and buildByRepoIndex - Simplify nil container-pin check to idiomatic positive-first form Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors pkg/actionpins to use newer Go stdlib maps/slices helpers for more declarative transformations and sorting, without intended behavior changes.
Changes:
- Replace imperative map-to-slice loop with
slices.Collect(maps.Values(...)). - Replace
sort.Slicecomparators withslices.SortFunc+cmp.Compare(including semver-descending sort). - Simplify container pin nil initialization logic.
Show a summary per file
| File | Description |
|---|---|
| pkg/actionpins/actionpins.go | Refactors pin collection and sorting to maps/slices/cmp, plus minor nil-guard simplification. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Applied moderate functional/immutability improvements to
pkg/actionpins(round-robin pass 1/22).Changes in
pkg/actionpins/actionpins.go:1. Declarative map-to-slice conversion
Replaced an imperative
make+appendloop withslices.Collect(maps.Values(...)):2.
slices.SortFuncwithcmp.Compare(two call sites)Replaced
sort.Slice(index-based closure) withslices.SortFunc(value-based closure) for cleaner, safer comparisons:3. Idiomatic nil-check for container pins
Simplified the if/else nil-guard to a positive-first pattern:
Benefits
slices.SortFuncreceives values directly (not indices), making comparisons easier to read and reviewmaps.Copy,slices.Collect,maps.Keysusage elsewhere in the codebaseTesting
pkg/actionpinstests passgo vetcleango build ./pkg/actionpins/succeedsRound-Robin Progress
pkg/actionpins(1 of 22 packages)pkg/agentdrainReferences: §24828978425