From fd8b956ab23176e669c29e4086c1f016be419ed9 Mon Sep 17 00:00:00 2001 From: t Date: Mon, 13 Jul 2026 11:38:42 -0600 Subject: Skip symlinked outputs in the managed .gitignore --- main_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go index 66d793f..f6c943e 100644 --- a/main_test.go +++ b/main_test.go @@ -354,6 +354,28 @@ func TestGitignoreTracksOnlyCurrentGeneratedOutputs(t *testing.T) { } } +func TestGitignoreOmitsOutputsBelowSymlinks(t *testing.T) { + root := t.TempDir() + vault := t.TempDir() + writeTestFile(t, root, ".gitignore", gitignoreStart+"\n/notes/note.html\n"+gitignoreEnd+"\n") + writeTestFile(t, root, "layouts.tmpl", testLayouts()) + writeTestFile(t, root, "local.md", "# Local\n") + writeTestFile(t, vault, "note.md", "# Note\n") + if err := os.Symlink(vault, filepath.Join(root, "notes")); err != nil { + t.Skipf("symlinks unavailable: %v", err) + } + if err := buildWithFallback(root, "https://example.com", "page", true); err != nil { + t.Fatal(err) + } + want := gitignoreStart + "\n/local.html\n" + gitignoreEnd + "\n" + if raw, _ := os.ReadFile(filepath.Join(root, ".gitignore")); string(raw) != want { + t.Fatalf(".gitignore = %q, want %q", raw, want) + } + if raw, _ := os.ReadFile(filepath.Join(root, manifestName)); !strings.Contains(string(raw), `"notes/note.html"`) { + t.Fatalf("manifest does not own symlinked output: %s", raw) + } +} + func TestSortingFilteringSlicing(t *testing.T) { a := &Page{Title: "A", Meta: map[string]any{"post_date": "2024-01-01", "kind": "x"}, ModTime: time.Unix(1, 0)} b := &Page{Title: "B", Meta: map[string]any{"post_date": "2025-01-01", "kind": "y"}, ModTime: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)} -- cgit v1.3