feat(client): ignore rule in .lodge
This commit is contained in:
1 parent
4207f7e6f8
commit
45c81cfcaf
8 files changed
+146
-18
No files matched your search
@@ -207,6 +207,72 @@ func TestRulesFileTravelsAndHostileServerPathsAreIgnored(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIgnoredFilesNeverTravel(t *testing.T) {
|
||||
mac, dell := setup(t)
|
||||
rules := "shared vault\nignore vault/.obsidian/workspace*.json\nignore .DS_Store\nignore vault/cache\n"
|
||||
write(t, mac.root, RulesFile, rules)
|
||||
write(t, mac.root, "vault/note.md", "note")
|
||||
write(t, mac.root, "vault/.obsidian/app.json", "settings")
|
||||
write(t, mac.root, "vault/.obsidian/workspace.json", "mac layout")
|
||||
write(t, mac.root, "vault/.obsidian/workspace-mobile.json", "mac mobile")
|
||||
write(t, mac.root, "vault/deep/.DS_Store", "finder")
|
||||
write(t, mac.root, "vault/cache/index.bin", "cache")
|
||||
if res := mac.sync(); res.Pushed != 3 {
|
||||
t.Fatalf("pushed %d files, want the rules, the note and app.json", res.Pushed)
|
||||
}
|
||||
|
||||
write(t, dell.root, "vault/.obsidian/workspace.json", "dell layout")
|
||||
dell.sync()
|
||||
dell.expect("vault/note.md", "note")
|
||||
dell.expect("vault/.obsidian/app.json", "settings")
|
||||
dell.expect("vault/.obsidian/workspace.json", "dell layout")
|
||||
dell.expect("vault/.obsidian/workspace-mobile.json", "")
|
||||
dell.expect("vault/deep/.DS_Store", "")
|
||||
dell.expect("vault/cache/index.bin", "")
|
||||
|
||||
hash, _ := mac.client.cacheBlob([]byte("pushed by an old client"))
|
||||
if err := mac.client.uploadBlob(context.Background(), hash); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
push := protocol.Push{Changes: []protocol.Change{{Space: protocol.SharedSpace, Path: "vault/.obsidian/workspace.json", Hash: hash}}}
|
||||
if err := mac.client.call(context.Background(), http.MethodPost, "/api/repos/"+repoKey(t, mac)+"/revisions", push, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mac.sync()
|
||||
dell.sync()
|
||||
mac.expect("vault/.obsidian/workspace.json", "mac layout")
|
||||
dell.expect("vault/.obsidian/workspace.json", "dell layout")
|
||||
|
||||
exclude, _ := os.ReadFile(filepath.Join(dell.root, ".git/info/exclude"))
|
||||
if strings.Contains(string(exclude), "workspace") || strings.Contains(string(exclude), "DS_Store") {
|
||||
t.Fatalf("ignore rules leaked into exclude:\n%s", exclude)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIgnoreRuleMatching(t *testing.T) {
|
||||
rules := parseRules("shared vault\nbranch .agent\nignore vault/.obsidian/workspace*.json\nignore .DS_Store\nignore *.tmp\nignore .lodge\n")
|
||||
for file, want := range map[string]bool{
|
||||
"vault/note.md": true,
|
||||
"vault/.obsidian/workspace.json": false,
|
||||
"vault/.obsidian/workspace-mobile.json": false,
|
||||
"vault/.obsidian/workspaces.json": false,
|
||||
"vault/.obsidian/app.json": true,
|
||||
"vault/sub/.obsidian/workspace.json": true,
|
||||
"vault/.DS_Store": false,
|
||||
"vault/a/b/.DS_Store": false,
|
||||
"vault/.DS_Store/inside": false,
|
||||
"vault/draft.tmp": false,
|
||||
RulesFile: true,
|
||||
} {
|
||||
if got := rules.covers(file, true); got != want {
|
||||
t.Errorf("covers(%s) = %v, want %v", file, got, want)
|
||||
}
|
||||
}
|
||||
if rules.covers(".agent/.DS_Store", false) || !rules.covers(".agent/plan.md", false) {
|
||||
t.Error("ignore rules must apply to branch paths too")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeletingRepositoryOnServerKeepsFilesOnMachines(t *testing.T) {
|
||||
mac, _ := setup(t)
|
||||
write(t, mac.root, "docs/agents/plan.md", "v1")
|
||||
|
||||
Reference in new issue
Block a user