Skip to content

feat(autodiscovery/precommit): detect rev version from comment#8402

Merged
olblak merged 9 commits into
updatecli:mainfrom
nickzerjeski:feat-precommit-comment-version-7740
Apr 26, 2026
Merged

feat(autodiscovery/precommit): detect rev version from comment#8402
olblak merged 9 commits into
updatecli:mainfrom
nickzerjeski:feat-precommit-comment-version-7740

Conversation

@nickzerjeski

Copy link
Copy Markdown
Contributor

Summary

Detect semver versions in pre-commit rev inline comments during autodiscovery.

This fixes cases where rev is a frozen digest and the version is stored in a comment, e.g.:

rev: e2e40021c9007020676c93680a36e3ab06c6cd33 # v2.8.0

Fixes #7740

Changes

  • Parse .pre-commit-config.yaml as YAML AST and capture rev line comments per repo.
  • Add fallback logic in precommit autodiscovery:
    • when rev is not semver-compatible,
    • extract semver token from rev comment (e.g. v2.8.0),
    • use that for the generated versionfilter.pattern.
  • Add regression fixture and test scenario (testdata/digestcomment) covering digest+comment behavior.

Backward Compatibility

  • Existing behavior is unchanged when rev is already semver-compatible.
  • New behavior only applies as fallback when parsing rev fails.

Validation

  • go test ./pkg/plugins/autodiscovery/precommit -run 'TestDiscoverManifests'

Signed-off-by: nickzerjeski <nick@zerjeski.de>
Copilot AI review requested due to automatic review settings April 13, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds fallback semver detection for pre-commit repos whose rev is a digest by extracting a semver token from the inline comment, enabling correct versionfilter.pattern generation.

Changes:

  • Parse .pre-commit-config.yaml via YAML AST to capture rev line comments per repo.
  • Add fallback logic to extract semver from rev comments when rev parsing fails.
  • Add regression fixture + test scenario for digest rev with semver comment.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/plugins/autodiscovery/precommit/precommit.go Captures rev inline comments using YAML AST and stores them on discovered repos.
pkg/plugins/autodiscovery/precommit/dependency.go Extracts semver from rev comments and uses it as a fallback for version filtering.
pkg/plugins/autodiscovery/precommit/main_test.go Adds a scenario covering digest rev with semver in the comment.
pkg/plugins/autodiscovery/precommit/testdata/digestcomment/.pre-commit-config.yaml Adds fixture manifest with digest rev and semver comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/plugins/autodiscovery/precommit/precommit.go Outdated
Comment thread pkg/plugins/autodiscovery/precommit/precommit.go Outdated
Comment thread pkg/plugins/autodiscovery/precommit/precommit.go
Comment thread pkg/plugins/autodiscovery/precommit/dependency.go Outdated
@olblak olblak added bug Something isn't working resource-precommit labels Apr 26, 2026
@olblak olblak merged commit d18076e into updatecli:main Apr 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working resource-precommit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Precommit autodiscovery detect version from comment

3 participants