Refactor duplicated update-check state helpers and centralize repo/API normalization#41985
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hey Tests are in place for the new
|
There was a problem hiding this comment.
Pull request overview
This refactor consolidates small duplicated helpers in pkg/cli and centralizes repository “[HOST/]owner/repo” normalization into pkg/repoutil, while also removing a few local helper re-implementations in pkg/workflow and pkg/cli.
Changes:
- Centralized repo parsing as
repoutil.NormalizeRepoForAPIand updated CLI call sites to use it. - Extracted shared update-check marker-file helpers into
pkg/cli/update_check_state.goand reused them from both update-check paths. - Removed a few local helper reinventions (Actions single-quote escaper colocation, permission key sorting via
sliceutil.SortedKeys, SHA shortening viastringutil).
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/strings.go | Adds shared Actions single-quoted string escaping alongside existing YAML escaping helpers. |
| pkg/workflow/strings_test.go | Adds unit coverage for the Actions single-quote escaping helper. |
| pkg/workflow/compiler_safe_output_jobs.go | Removes the local Actions single-quote escaper in favor of the shared helper. |
| pkg/workflow/action_cache.go | Replaces local SHA-shortening logic with a shared truncation utility. |
| pkg/repoutil/repoutil.go | Introduces NormalizeRepoForAPI in the central repo utilities package. |
| pkg/repoutil/repoutil_test.go | Adds tests for the new repo normalization helper. |
| pkg/repoutil/README.md | Updates repoutil docs to include the new public API helper. |
| pkg/cli/update_check.go | Switches update-check state handling to shared marker-file helpers. |
| pkg/cli/update_check_state.go | New shared helper file for marker path creation, interval gating, and timestamp writes. |
| pkg/cli/outcome_eval.go | Moves host-aware repo normalization usage to repoutil.NormalizeRepoForAPI. |
| pkg/cli/outcome_eval_test.go | Updates existing tests to call the new repoutil normalization helper. |
| pkg/cli/logs_command.go | Updates local-repo detection to use the shared repoutil normalization helper. |
| pkg/cli/compile_update_check.go | Switches compile-update-check state handling to shared marker-file helpers. |
| pkg/cli/codemod_dependabot_permissions.go | Replaces manual key sorting with sliceutil.SortedKeys. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Low
| func truncateSHAForLog(sha string) string { | ||
| if len(sha) > 8 { | ||
| return sha[:8] | ||
| } | ||
| return sha | ||
| return stringutil.Truncate(sha, 8) | ||
| } |
|
@copilot please run the
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
PR Triage — Run §28315307719
Deduplicates update-check state marker-file helpers and moves
|
This refactor removes a few verified helper reinventions and consolidates small but repeated logic in
pkg/cli. It also moves the host-aware repo parser topkg/repoutil, where the rest of the repo string handling already lives.CLI update-check state
update_check.goandcompile_update_check.goinstead of keeping parallel implementations.Repository normalization
[HOST/]owner/repoparsing frompkg/cli/outcome_eval.gointopkg/repoutilasNormalizeRepoForAPI.owner/repo.Helper reinventions removed
sliceutil.SortedKeys.pkg/workflow/strings.go.Tests and package docs
repoutiltests/docs to cover the new normalization helper.Example of the repo normalization now living in
repoutil:pr-sous-chef run 28311797805