X Tutup
Skip to content

fix(file): file condition bug with searchpattern and matchpattern#7619

Merged
olblak merged 1 commit intoupdatecli:mainfrom
olblak:fix/file/matchpattern
Jan 30, 2026
Merged

fix(file): file condition bug with searchpattern and matchpattern#7619
olblak merged 1 commit intoupdatecli:mainfrom
olblak:fix/file/matchpattern

Conversation

@olblak
Copy link
Member

@olblak olblak commented Jan 27, 2026

While reviewing #7614 I realize that the condition file match pattern was also broken

Note that #7614 should be merged first

Test

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

go build -o bin/updatecli .
./bin/updatecli diff --config e2e/updatecli.d/success.d/file/noscm.yaml

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

Potential improvement

@olblak olblak added bug Something isn't working resource-file Resource of kind File labels Jan 27, 2026
@olblak olblak changed the title Fix/file/matchpattern fix: file condition bug with searchpattern and matchpattern Jan 27, 2026
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak force-pushed the fix/file/matchpattern branch from 38bacc3 to a4c6f63 Compare January 30, 2026 13:05
@olblak olblak requested a review from Copilot January 30, 2026 13:06
@olblak olblak enabled auto-merge (squash) January 30, 2026 13:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a bug in the file condition logic when using searchpattern: true with matchpattern. The issue was that the check for empty files (when all files are filtered out) was placed incorrectly in the code, making it unreachable. This PR moves the check to the correct location, ensuring consistent behavior between file conditions and targets.

Changes:

  • Fixed the file condition check placement to properly detect when all files are filtered out by matchpattern
  • Added e2e test coverage for the failing scenario with searchpattern and non-matching matchpattern
  • Removed unnecessary blank lines for cleaner formatting

Reviewed changes

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

File Description
pkg/plugins/resources/file/condition.go Moved the empty files check inside the file deletion block to properly detect when all files are filtered out, fixing the bug where conditions would incorrectly succeed when all files failed to match the content pattern
e2e/updatecli.d/success.d/file/noscm.yaml Added test case for condition with searchpattern and matchpattern that filters out all files, demonstrating the fix works correctly

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

@olblak olblak disabled auto-merge January 30, 2026 15:06
@olblak olblak merged commit 1c3612d into updatecli:main Jan 30, 2026
11 checks passed
@olblak olblak changed the title fix: file condition bug with searchpattern and matchpattern fix(file): file condition bug with searchpattern and matchpattern Feb 6, 2026
@olblak olblak deleted the fix/file/matchpattern branch February 6, 2026 13:52
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-file Resource of kind File

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup