Skip to content

Sync → Ignore patterns#70

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

Sync → Ignore patterns#70
kwame-Owusu wants to merge 13 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

Test Plan

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

Greptile Summary

This PR adds ignore-pattern support to vault sync. Files are filtered at the listFiles layer in createObsidianReader, so ignored paths never enter the snapshot system and previously-synced files that become ignored appear as local deletions on the next sync run.

  • src/ignore.ts — new pure module implementing hasLocalPrefix (built-in local_ convention), globToRegex, compilePatterns, shouldIgnoreCompiled, and the convenience wrapper shouldIgnore; well-tested with table-driven cases in ignore.test.ts.
  • src/settings/ignorePatterns: string[] added to GeodeSettings with a stringArrayOr normalizer, arraysEqual helper wired into settingsEqual, and a renderSyncSection textarea in the settings tab that splits/trims/filters user input on change.
  • src/vault/obsidian.ts and src/main.tscreateObsidianReader updated to accept and apply the patterns; both call-sites pass this.settings.ignorePatterns, which is updated synchronously by save() before any subsequent sync.

Confidence Score: 5/5

Safe to merge; filtering is correctly applied at the reader layer and all call-sites pass live settings.

The core filtering logic in ignore.ts is well-covered by unit tests, the two createObsidianReader call-sites in main.ts both use the updated signature, and settingsEqual is correctly extended for array comparison. The only open items are a style nit on a function comment and a minor performance opportunity in obsidian.ts, neither of which affects correctness.

No files require special attention beyond the two inline comments already left.

Important Files Changed

Filename Overview
src/ignore.ts New module implementing hasLocalPrefix, globToRegex, compilePatterns, shouldIgnoreCompiled, and shouldIgnore. Logic is correct; glob-to-regex conversion handles **, *, ?, leading slash, and regex metachar escaping cleanly.
src/ignore.test.ts Comprehensive table-driven tests for all three exported functions; covers edge cases (empty path, empty pattern, double-star at start/middle/end, question mark, leading slash).
src/vault/obsidian.ts createObsidianReader now accepts ignorePatterns and filters listFiles correctly; calls shouldIgnore per file rather than using the pre-compiled API added in ignore.ts this same PR.
src/settings/tab.ts Adds renderSyncSection with a textarea for ignore patterns; onChange correctly splits/trims/filters lines into the draft array and calls onFieldChanged. Stale function comment is the only issue.
src/settings/settings.ts Adds ignorePatterns field with default empty array, stringArrayOr normalizer, arraysEqual helper, and settingsEqual update. All correct and well-tested.
src/main.ts Both createObsidianReader call sites updated to pass this.settings.ignorePatterns; settings are updated synchronously in save() before the next sync, so patterns take effect immediately.
src/settings/settings.test.ts New normalizeSettings and settingsEqual cases for ignorePatterns cover missing, non-array, array-with-non-strings, and valid inputs.
src/sync/sync.itest.ts Updated to pass liveSettings.ignorePatterns (empty array from DEFAULT_SETTINGS) to createObsidianReader; no ignore filtering exercised in the integration test but that is covered by the unit tests.
styles.css Adds .geode-sync-anchor margin-top rule, consistent with the existing .geode-support-anchor pattern.

Reviews (8): 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 👍

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