Skip to content

Normalize relative paths in nebel add - #9

Merged
MuffinUser merged 1 commit into
mainfrom
worktree-fix-relative-path-issue8
Sep 29, 2026
Merged

MuffinUser merged 1 commit into
mainfrom
worktree-fix-relative-path-issue8

Conversation

@MuffinUser

Copy link
Copy Markdown
Owner

Summary

  • nebel add field ./test.yaml ... and nebel add file ./*.yaml wrote the raw, un-normalized path/glob straight into .gitattributes and .nebel.yaml.
  • git never reports a leading ./ for tracked files, so the pattern silently failed to match and the file was left unencrypted.
  • Adds a normalizePath helper (filepath.Clean + filepath.ToSlash) applied to the CLI argument in both runAddField and runAddFile, before it's used for the file read, the config rule, and the .gitattributes line.

Fixes #8

Note for anyone with an already-affected repo

Existing .nebel.yaml / .gitattributes entries with a literal ./ prefix (written before this fix) are dead weight after upgrading — they can be deleted by hand; re-running nebel add will add the correctly normalized rule alongside them.

Test plan

  • go build ./...
  • go test ./... (full suite passes)
  • New regression tests: TestAddFieldNormalizesRelativePath, TestAddFileNormalizesRelativePath in cmd/nebel/addfield_e2e_test.go

nebel add field ./test.yaml and nebel add file ./*.yaml wrote the raw,
un-normalized path/glob into .gitattributes and .nebel.yaml. git never
reports a leading "./" for tracked files, so the pattern silently
failed to match and the file was left unencrypted.

Fixes #8

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@MuffinUser
MuffinUser marked this pull request as ready for review September 29, 2026 13:40
@MuffinUser
MuffinUser merged commit c0aa2c2 into main Sep 29, 2026
6 checks passed
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.

Wrong path resolution when a file is added with Relative Path

1 participant