fix: add missing run-mockery.sh for the pre-commit mockery hook#92
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅MegaLinter analysis: Success
Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts
|
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.

Problem
.pre-commit-config.yamlwires a localmockeryhook that runs.github/scripts/run-mockery.sh:…but that script does not exist (
.github/scripts/is absent). Withlanguage: script, pre-commit executes the entry directly, so every committhat touches a
.gofile fails the hook on a fresh clone of the scaffold —and the README advertises this very feature: "A pre-commit hook runs
golangci-lintformatting (andmockerymock generation) locally on commit."Because this is a template, the broken hook propagates to every project
scaffolded from it.
mockery is clearly intended:
.github/workflows/copilot-setup-steps.ymlinstalls it (
go install github.com/vektra/mockery/v3@v3.5.4). The fix is tosupply the missing script, not to remove the hook.
Fix
Add
.github/scripts/run-mockery.sh(executable,100755). It is written to betemplate-friendly:
config — so there is nothing to generate yet. The script no-ops (exit 0)
until a
.mockery.yml/.mockery.yamlexists, keeping the pre-commit hookgreen on a fresh clone.
mockery(resolved fromPATH, matching thego install …/mockery/v3@v3.5.4the Copilot setupworkflow performs). If a config is present but mockery is not installed, it
exits non-zero with a clear install hint rather than silently skipping
(stale-mock safety).
No behaviour change for the empty scaffold beyond unbreaking the hook;
golangci-lint-fmtis untouched.Validation
shellcheck .github/scripts/run-mockery.sh→ clean.exit 0. ✓exit 1with install hint. ✓git ls-files -s→100755).go build/go testunaffected).Trade-offs / alternatives considered
setup workflow installs mockery, so the feature is intended; removing it would
drop advertised functionality.
.mockery.yml— out of scope: the scaffold has no interfacesto mock, and ksail's config enumerates project-specific packages (not
portable). Generating mock config belongs to the consumer, hence the
no-op-until-configured design.