Skip to content

[#52] Sync → Ignore patterns - #70

Open
kwame-Owusu wants to merge 14 commits into
8thpark:mainfrom
kwame-Owusu:feat/ignore-patterns
Open

[#52] Sync → Ignore patterns#70
kwame-Owusu wants to merge 14 commits into
8thpark:mainfrom
kwame-Owusu:feat/ignore-patterns

Conversation

@kwame-Owusu

@kwame-Owusu kwame-Owusu commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Resolves #52

Feature

There's no way to exclude a folder or file pattern from sync, every file the vault reader sees becomes a candidate for push or pull. Users will want to keep some folders local only (a private notes folder, a large attachments folder) without excluding them from Obsidian entirely.

Needs a settings field for glob style ignore patterns, applied before takeSnapshot/planSync ever sees those paths.

Changes

Added the ability to exclude files and folders from sync via two layers:

  1. Built-in local_ convention, any path segment starting with local_ is always excluded from sync, no configuration needed
  2. User-configurable glob patterns, stored in settings, editable via a textarea in the Sync section of the settings tab. Supports * (any chars in segment), ** (any depth), ? (single char)
    Filtering happens at the vault reader level so ignored files never enter the snapshot system. Previously-synced files that become ignored will appear as deletions and be cleaned from remote on next sync.

UI

Look of the UI in the settings tab for geod, users will be able to add their glob style patterns line by line. Similar to how we do in a .gitignore file.

image

Tests

Added new tests in ignore.test.ts, and they all pass

Greptile Summary

This PR adds file/folder exclusion from sync via two layers: a built-in local_ path-segment convention and user-configurable glob patterns editable in a new Sync section of the settings tab. Filtering is applied inside createObsidianReader so ignored paths never enter the snapshot pipeline; previously-synced files that match a new pattern appear as local deletions and are cleaned from remote on the next sync pass.

  • New src/ignore.ts module implements hasLocalPrefix, a glob-to-regex compiler, and both a per-call (shouldIgnore) and pre-compiled (shouldIgnoreCompiled/compilePatterns) API; companion ignore.test.ts covers edge cases thoroughly.
  • Settings schema gains an ignorePatterns: string[] field with default [], proper coercion in normalizeSettings, and an arraysEqual helper wired into settingsEqual.
  • Settings tab renders a 5-row textarea under a new "Sync" heading; the description now correctly uses string concatenation for a single setDesc argument and includes the private/** folder hint.

Confidence Score: 5/5

Safe to merge — the ignore logic is correct, filtering happens before any file enters the snapshot, and the settings round-trip is validated end-to-end.

The core filtering logic is sound: shouldIgnore is called inside listFiles so ignored paths never reach takeSnapshot or planSync. Both the per-call and pre-compiled variants are exported and tests cover all documented glob forms. Settings persistence and equality checks are correct. Two issues flagged in earlier review rounds were partially or fully addressed in this diff.

Files Needing Attention: src/vault/obsidian.ts — listFiles still calls shouldIgnore (which recompiles patterns per file) rather than the exported compilePatterns/shouldIgnoreCompiled pair; noted in a previous review thread.

Important Files Changed

Filename Overview
src/ignore.ts New module implementing hasLocalPrefix, globToRegex, compilePatterns, shouldIgnoreCompiled, and shouldIgnore; logic is correct and both the pre-compiled and per-call variants are exported.
src/ignore.test.ts Comprehensive table-driven tests covering hasLocalPrefix, matchesGlob (including **, *, ?, edge cases), and shouldIgnore; all cases are correct.
src/vault/obsidian.ts createObsidianReader now accepts ignorePatterns and calls shouldIgnore per file; compilePatterns/shouldIgnoreCompiled were exported to enable pre-compilation but listFiles still recompiles patterns on every invocation (covered by existing review thread).
src/settings/settings.ts Adds ignorePatterns field to GeodeSettings with default [], proper stringArrayOr validation, arraysEqual helper, and settingsEqual update.
src/settings/tab.ts Adds renderSyncSection with a textarea for ignore patterns; setDesc now uses proper single-string concatenation and includes the private/** folder hint.
src/main.ts Both createObsidianReader call sites updated to pass this.settings.ignorePatterns; each call creates a fresh reader so the latest patterns are always used.
src/settings/settings.test.ts Adds normalize and settingsEqual test cases for ignorePatterns covering missing, non-array, array-with-non-strings, and valid-array inputs.
src/sync/sync.itest.ts Updated newDevice to pass liveSettings.ignorePatterns to createObsidianReader; no functional change to integration test behaviour.
styles.css Adds .geode-sync-anchor margin-top rule consistent with the existing .geode-support-anchor pattern.

Reviews (9): Last reviewed commit: "Merge branch 'main' into feat/ignore-pat..." | Re-trigger Greptile

Comment thread src/ignore.ts
Comment thread src/settings/tab.ts
Comment thread src/settings/tab.ts
@revett revett changed the title Feat: ignore patterns Sync → Ignore patterns Jul 17, 2026
@revett

revett commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@kwame-Owusu Thanks for the PR, will leave this for after the v0.1.0 release to merge.

@kwame-Owusu

Copy link
Copy Markdown
Contributor Author

@kwame-Owusu Thanks for the PR, will leave this for after the v0.1.0 release to merge.

Cool 👍

@revett revett changed the title Sync → Ignore patterns [#52] Sync → Ignore patterns Aug 2, 2026
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.

Ignore patterns for excluded files and folders

2 participants