Fix ignore patterns
This commit is contained in:
parent
287a4e15b4
commit
b17f34d402
4 changed files with 30 additions and 2 deletions
|
|
@ -26,7 +26,9 @@ export class ObsidianFileSystemOperations implements FileSystemOperations {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folder.includes(".obsidian")) {
|
// This would be a very bad idea to sync as it would mess with
|
||||||
|
// the integrity of the sync database.
|
||||||
|
if (folder.endsWith(".obsidian/plugins/vault-link/data.json")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export default class VaultLinkPlugin extends Plugin {
|
||||||
>();
|
>();
|
||||||
|
|
||||||
public async onload(): Promise<void> {
|
public async onload(): Promise<void> {
|
||||||
DEFAULT_SETTINGS.ignorePatterns.push(".obsidian", ".git");
|
DEFAULT_SETTINGS.ignorePatterns.push(".obsidian/**", ".git/**");
|
||||||
|
|
||||||
this.client = await SyncClient.create({
|
this.client = await SyncClient.create({
|
||||||
fs: new ObsidianFileSystemOperations(
|
fs: new ObsidianFileSystemOperations(
|
||||||
|
|
|
||||||
10
frontend/sync-client/src/utils/globs-to-regexes.test.ts
Normal file
10
frontend/sync-client/src/utils/globs-to-regexes.test.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { Logger } from "../tracing/logger";
|
||||||
|
import { globsToRegex } from "./globs-to-regexes";
|
||||||
|
|
||||||
|
describe("globsToRegexes", () => {
|
||||||
|
it("basicExample", async () => {
|
||||||
|
const regex = globsToRegex([".git/**"], new Logger())[0];
|
||||||
|
|
||||||
|
expect(regex.test(".git/objects/object")).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
16
frontend/sync-client/src/utils/globs-to-regexes.ts
Normal file
16
frontend/sync-client/src/utils/globs-to-regexes.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { makeRe } from "minimatch";
|
||||||
|
import { Logger } from "../tracing/logger";
|
||||||
|
|
||||||
|
export function globsToRegex(globs: string[], logger: Logger): RegExp[] {
|
||||||
|
return globs
|
||||||
|
.map((pattern) => {
|
||||||
|
const result = makeRe(pattern);
|
||||||
|
if (result === false) {
|
||||||
|
logger.warn(
|
||||||
|
`Failed to parse ${pattern}' as a glob pattern, skipping it`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
})
|
||||||
|
.filter((pattern) => pattern !== false);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue