Skip to content

[Code Quality] Add recovery guidance to shared gitutil error wrappers (current directory, git root, home directory) #50962

Description

@github-actions

Description

An error-message quality audit (discussion #50886) found that shared low-level helpers in pkg/gitutil/gitutil.go wrap common failures ("failed to get current directory", "failed to find git root", "failed to get home directory") with bare fmt.Errorf("...: %w", err) and no recovery guidance, violating the repo's own style guide at .github/skills/error-messages/SKILL.md. These helpers are reused across 8+ call sites each in pkg/cli, so fixing them once fixes many.

Suggested Changes

  • Update pkg/gitutil/gitutil.go:134 and equivalent functions to follow [what's wrong]. [what's expected/how to fix] format, e.g.:
    • fmt.Errorf("failed to determine current working directory: %w (check that the process has a valid working directory and read permissions)", err)
    • fmt.Errorf("failed to find git repository root: %w (run this command from inside a git repository, or use 'git init')", err)
  • Search pkg/cli (e.g. trial_repository.go, actionlint.go, poutine.go, runner_guard.go) for local duplicates of the same wrap and route them through the shared pkg/gitutil helper instead.

Files Affected

  • pkg/gitutil/gitutil.go
  • pkg/cli/runner_guard.go:62
  • pkg/cli/actionlint.go:305
  • pkg/cli/poutine.go:83
  • pkg/cli/trial_repository.go:257,663

Success Criteria

  • Shared gitutil error messages include actionable recovery guidance per the style guide
  • No new duplicate literal error strings introduced; call sites route through the shared helper
  • make test-unit passes with no regressions

Source

Extracted from Repository Quality Improvement Report - Error Message & Diagnostics Quality (discussion #50886)

Priority

High - primary user-facing CLI error surface, small/mechanical fix

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 35.3 AIC · ⌖ 4.12 AIC · ⊞ 10.2K ·

  • expires on Aug 7, 2026, 5:44 PM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions