Skip to content

Conversation

@josill
Copy link
Contributor

@josill josill commented Jan 10, 2026

This pull request adds a ReplaceAll feature to the version filter functionality, allowing users to apply regex-based transformations to version strings before filtering. This is particularly useful for normalizing version formats (e.g., converting curl-8_15_0 to curl-8.15.0) before regex extraction and semantic version matching.

Closes #5864

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/utils/version
go test -v

Or run the full test suite:

make test-short

Additional Information

  • Added ReplaceAll struct with Pattern and Replacement fields to the version filter
  • Implemented applyReplaceAll() method that applies regex replacements before filtering
  • Integrated ReplaceAll functionality into REGEXVERSIONKIND, REGEXSEMVERVERSIONKIND, and REGEXTIMEVERSIONKIND filter types
  • Added validation for ReplaceAll patterns in the Validate() method
  • Added unit tests covering various scenarios including:
    • Valid and invalid regex patterns
    • Different filter kinds (regex, regex/semver, regex/time)
    • Edge cases (empty replacement, no matches, capture groups)

Checklist

  • I have added unit tests for the new functionality
  • I have validated that tests pass with go test

Tradeoff

The ReplaceAll transformation is applied before regex extraction, which means:

  • Pros: Allows normalization of version strings that don't match expected formats (e.g., underscores vs dots)
  • Cons: Adds an extra processing step, but the performance impact is minimal as it only applies when ReplaceAll is configured

The validation happens at filter initialization time, catching invalid regex patterns early rather than at runtime.

@josill josill marked this pull request as draft January 10, 2026 15:30
@josill josill marked this pull request as ready for review January 10, 2026 15:37
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request including the tests

@olblak olblak enabled auto-merge (squash) January 11, 2026 07:50
@olblak olblak added enhancement New feature or request versionfilter labels Jan 11, 2026
@olblak olblak merged commit eb60ed8 into updatecli:main Jan 11, 2026
5 checks passed
ErickdelaCruzCas pushed a commit to ErickdelaCruzCas/updatecli that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request versionfilter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Allow transformation of versions before versionfilter

2 participants