Skip to content

Commit c9cc5e4

Browse files
committed
test(memory): exercise native link and document parsing paths
1 parent 1928c10 commit c9cc5e4

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

‎internal/memory/escape_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func TestALinkedIgnoreIsNotProofOfPrivacy(t *testing.T) {
284284
if err := os.MkdirAll(filepath.Join(paths.LocalDir, "decoy"), 0o700); err != nil {
285285
t.Fatal(err)
286286
}
287-
linkDir(t, "decoy", filepath.Join(paths.LocalDir, ".gitignore"))
287+
linkDir(t, filepath.Join(paths.LocalDir, "decoy"), filepath.Join(paths.LocalDir, ".gitignore"))
288288
if _, err := Write(paths, ScopeLocal, "private", "d", "secret"); err == nil {
289289
t.Error("a reparse point at the ignore path was accepted as privacy")
290290
}

‎internal/memory/memory.go‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,22 +1102,6 @@ func renderNote(name, description, body string) string {
11021102
return b.String()
11031103
}
11041104

1105-
// splitFrontmatter returns the description and the body. A note without
1106-
// frontmatter is not an error — it is a file someone wrote by hand, and losing
1107-
// it because it lacks a header would be the store punishing the reader it exists
1108-
// to serve.
1109-
//
1110-
// CRLF is accepted as well as LF. Project-scope notes are checked in, and Git for
1111-
// Windows defaults to autocrlf=true, so a note that merely round-trips through a
1112-
// clone comes back with "---\r\n" — under an LF-only split the whole header,
1113-
// delimiters included, fell through into the body and the description was lost.
1114-
//
1115-
// LINE ENDINGS ARE NORMALISED TO LF in what this returns, on every path. The
1116-
// earlier version normalised only for the split and then returned the body from
1117-
// whichever string that path happened to hold, so a note WITH frontmatter came
1118-
// back as LF and one WITHOUT kept its CRLF — a difference no caller asked for and
1119-
// nothing documented. The file on disk is untouched either way; this is only
1120-
// what the reader is handed.
11211105
// boundedDescription caps the summary so one note cannot crowd out the listing.
11221106
// Truncated on a rune boundary with an ellipsis, so the result stays readable and
11231107
// is visibly cut rather than looking like the whole of a short description.
@@ -1147,6 +1131,22 @@ func boundedDescription(text string) string {
11471131
return text[:cut] + ellipsis
11481132
}
11491133

1134+
// splitFrontmatter returns the description and the body. A note without
1135+
// frontmatter is not an error — it is a file someone wrote by hand, and losing
1136+
// it because it lacks a header would be the store punishing the reader it exists
1137+
// to serve.
1138+
//
1139+
// CRLF is accepted as well as LF. Project-scope notes are checked in, and Git for
1140+
// Windows defaults to autocrlf=true, so a note that merely round-trips through a
1141+
// clone comes back with "---\r\n" — under an LF-only split the whole header,
1142+
// delimiters included, fell through into the body and the description was lost.
1143+
//
1144+
// LINE ENDINGS ARE NORMALISED TO LF in what this returns, on every path. The
1145+
// earlier version normalised only for the split and then returned the body from
1146+
// whichever string that path happened to hold, so a note WITH frontmatter came
1147+
// back as LF and one WITHOUT kept its CRLF — a difference no caller asked for and
1148+
// nothing documented. The file on disk is untouched either way; this is only
1149+
// what the reader is handed.
11501150
func splitFrontmatter(content string) (description string, body string) {
11511151
normalized := strings.ReplaceAll(content, "\r\n", "\n")
11521152
if !strings.HasPrefix(normalized, "---\n") {

0 commit comments

Comments
 (0)