feat(cli): support glob patterns in .blaxelignore - #354
Conversation
🧪 Testing GuideWhat this PR addressesReplaces the literal string-matching logic in Steps to reproduce the original issue
What to verify (expected behavior)Unit tests: go test -count=1 ./cli/...All existing and new tests should pass, including:
Behavioral checks:
Build & lint: go build ./...
golangci-lint runNote Posted by PR Testing Guide · Tag @mendral-app with feedback. |
🔀 Interaction FlowHere's how the new glob-based ignore matching flows through the affected components: sequenceDiagram
participant CA as createArchive()
participant IP as IgnoredPaths()
participant NM as newIgnoredPathMatcher()
participant NP as normalizeIgnorePattern()
participant PM as moby/patternmatcher
participant IM as ignoredPathMatcher.matches()
CA->>IP: Load .blaxelignore patterns
IP-->>IP: Read file, split lines, skip comments/blanks
IP-->>IP: Append ".env.build" (unconditional)
IP-->>CA: []string patterns
CA->>NM: Compile patterns (root, patterns)
loop For each pattern
NM->>NP: normalizeIgnorePattern(pattern)
NP-->>NP: Handle ! negation prefix
NP-->>NP: Handle / or ./ anchor prefix
NP-->>NP: Prepend **/ if unanchored literal
NP-->>NM: normalized pattern
end
NM->>PM: patternmatcher.New(normalizedPatterns)
PM-->>NM: compiled PatternMatcher
NM-->>CA: &ignoredPathMatcher{root, matcher}
loop filepath.Walk directory tree
CA->>IM: matches(absolutePath)
IM-->>IM: filepath.Rel → toArchivePath
IM->>PM: MatchesOrParentMatches(relativePath)
PM-->>IM: bool (ignored?)
IM-->>CA: true → skip / false → add to archive
end
SummaryThe PR replaces the old
This enables Docker-style glob patterns ( Note Posted by PR Sequence Diagram · Tag @mendral-app with feedback. |
There was a problem hiding this comment.
LGTM
The implementation is clean and well-tested. The riskiest part—normalizeIgnorePattern—correctly handles negation, anchoring, and the **/ prefix for backward-compat literals. One pre-existing concern worth noting: the inline comment stripping at line 1991 (strings.Index(line, "#")) will now corrupt glob patterns containing # (e.g., character classes [#abc]), but since that code is unchanged, it's outside the scope of this review. The changed code itself is correct.
Tag @mendral-app with feedback or questions. View session
|
📋 Created Linear issue ENG-4085 — status: In Progress
Auto-created because no Linear reference was found in the PR title, description, or branch name. Note Posted by Linear Issue Enforcer · Tag @mendral-app with feedback. |
Fixes ENG-4085
Summary
.blaxelignoreentries with Docker's maintained pattern matcher*,?,**, character classes, and ordered!exclusions.env.buildunconditionally excludedThis makes it practical to share one ignore policy between
.dockerignoreand.blaxelignore, including patterns such as**/*.test.tsand**/.env.*.Testing
go test -count=1 ./...go build ./...golangci-lint run --new-from-rev=origin/main(0 new issues)Lint baseline
make lintstill reports 15 pre-existing findings in unrelated files onmain; this change introduces none.Note
Replaces the simple string-prefix/contains/suffix ignore-path matching with Docker's
patternmatcherlibrary, enabling glob patterns (*,**,?,[...]) and ordered!exclusions in.blaxelignore. Unanchored literal paths are automatically prefixed with**/to preserve existing depth-agnostic matching behavior..env.buildis appended last to remain unconditionally excluded.Written by Mendral for commit 53d41e8.