Skip to content

libs/fileset: cover leading-slash anchoring in glob patterns - #6345

Open
TangoEnSkai wants to merge 1 commit into
databricks:mainfrom
TangoEnSkai:test/glob-leading-slash-anchoring
Open

libs/fileset: cover leading-slash anchoring in glob patterns#6345
TangoEnSkai wants to merge 1 commit into
databricks:mainfrom
TangoEnSkai:test/glob-leading-slash-anchoring

Conversation

@TangoEnSkai

Copy link
Copy Markdown

Changes

Adds a test for how NewGlobSet treats a leading slash in an include pattern.

NewGlobSet compiles patterns with go-gitignore, so gitignore anchoring
rules apply: /dir/ matches only a dir at the fileset root, while dir/
matches a directory of that name at any depth. glob_test.go covered
recursive patterns, directory patterns and quoted file patterns, but nothing
pinned that anchored/unanchored distinction.

The new test asserts both halves against a temporary tree holding dir/ and
nested/dir/.

Why

sync.include passes user patterns straight through to NewGlobSet
(bundle.GetSyncIncludePatternssync.NewFileListfileset.NewGlobSet),
so this anchoring is user-visible bundle behaviour: it is what lets someone
include a top-level directory without also sweeping in same-named directories
nested elsewhere in the tree.

It is currently unprotected. Normalising the pattern slightly differently in
NewGlobSet — for example trimming the leading slash before compiling —
silently widens every anchored include, and the existing suite stays green. I
checked that by making exactly that change locally: only the new test fails.

This came up while looking at #3456, which reports anchored sync.include
patterns matching nested directories. I could not reproduce that against
main — the behaviour is correct today, at the pattern level and end to end
through NewGlobSet — so this PR only locks the current behaviour in rather
than changing anything. I have left a note on the issue with the details.

Tests

go test ./libs/fileset/ — all green, including the new
TestGlobFilesetLeadingSlashAnchorsToRoot.

Test-only change, so no changelog fragment.

NewGlobSet compiles include patterns with go-gitignore, so a leading slash
anchors the pattern to the fileset root while a bare name matches at any
depth. Nothing tested that distinction, even though sync.include depends on
it to select a top-level directory without also matching same-named
directories nested deeper.

Add a test that pins both halves: "/dir/" selects only the root directory,
"dir/" selects the nested one as well.
@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 6345
  • Commit SHA: e742d83fa0d896b1311c987dfe1dd86d2bb5a318

Checks will be approved automatically on success.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @pietern -- recent work in libs/fileset/

Eligible reviewers: @andrewnester, @anton-107, @denik, @janniklasrose, @lennartkats-db, @rclarey, @renaudhartert-db, @rugpanov, @shreyas-goenka, @simonfaltum

Suggestions based on git history. See OWNERS for ownership rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant