Repository navigation
Commit d90f98f
fix(store): keep ADR line endings intact when splicing a section
Every ADR fixture in the tree used \n, so nothing exercised a CRLF-stored
document — and CI could not have found this, because the fixtures are LF
whichever platform runs them. A red would only have appeared once a real
user's CRLF ADR met this code.
The exposure is specific to splicing. The old rebuild normalised everything
on the way out, so line-ending confusion was invisible; a byte-span
replacement can miscount a separator run, and byte-identity is the property
the splice design exists to provide.
Two of the three paths were already correct, and now say so in tests:
- Replacing a section preserves CRLF exactly. The walk-back over a trailing
break run steps across both '\r' and '\n', so it cannot cut mid-pair.
- Heading matching is ending-agnostic: "## PURPOSE\r\n" locates the same as
"## PURPOSE\n", because the scanner trims '\r' from the name. Trimming and
matching were different claims and only trimming was pinned.
Appending a new section was wrong. It counted trailing '\n' characters, so a
document ending "...Foo\r\n" was read as having one break but then had a
BARE '\n' appended, and the "## NAME" line it wrote used '\n' too — leaving a
mixed document that neither the author nor the tool asked for. A CRLF file
ending in a blank line also gained a spurious extra break.
Appends now count a "\r\n" pair as one break, and write the separator and
heading line using the document's own ending.
The contract, now that a document can be mixed:
- Bytes that already exist are never rewritten, so each line keeps whatever
ending it had. This follows from splicing and is what the acceptance
property already guaranteed.
- Text this code writes itself — the separator and the "## NAME" line —
follows the document's majority ending, LF on a tie.
- A caller's body is inserted verbatim. Rewriting bytes a caller supplied
would be the same silent modification this whole change set removes.
Co-authored-by: andis777 <24672074+andis777@users.noreply.github.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent d013555 commit d90f98f
2 files changed
Lines changed: 162 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8900 | 8900 | | |
8901 | 8901 | | |
8902 | 8902 | | |
| 8903 | + | |
| 8904 | + | |
| 8905 | + | |
| 8906 | + | |
| 8907 | + | |
| 8908 | + | |
| 8909 | + | |
| 8910 | + | |
| 8911 | + | |
| 8912 | + | |
| 8913 | + | |
| 8914 | + | |
| 8915 | + | |
| 8916 | + | |
| 8917 | + | |
| 8918 | + | |
| 8919 | + | |
| 8920 | + | |
| 8921 | + | |
| 8922 | + | |
| 8923 | + | |
| 8924 | + | |
| 8925 | + | |
| 8926 | + | |
| 8927 | + | |
| 8928 | + | |
| 8929 | + | |
| 8930 | + | |
| 8931 | + | |
| 8932 | + | |
| 8933 | + | |
| 8934 | + | |
| 8935 | + | |
| 8936 | + | |
| 8937 | + | |
| 8938 | + | |
| 8939 | + | |
| 8940 | + | |
8903 | 8941 | | |
8904 | 8942 | | |
8905 | 8943 | | |
| |||
8951 | 8989 | | |
8952 | 8990 | | |
8953 | 8991 | | |
8954 | | - | |
| 8992 | + | |
8955 | 8993 | | |
8956 | | - | |
8957 | | - | |
8958 | | - | |
8959 | | - | |
8960 | | - | |
| 8994 | + | |
| 8995 | + | |
| 8996 | + | |
| 8997 | + | |
| 8998 | + | |
| 8999 | + | |
8961 | 9000 | | |
8962 | | - | |
8963 | | - | |
| 9001 | + | |
| 9002 | + | |
8964 | 9003 | | |
8965 | 9004 | | |
8966 | | - | |
| 9005 | + | |
8967 | 9006 | | |
8968 | 9007 | | |
8969 | 9008 | | |
8970 | 9009 | | |
8971 | | - | |
| 9010 | + | |
8972 | 9011 | | |
8973 | | - | |
| 9012 | + | |
8974 | 9013 | | |
8975 | | - | |
8976 | | - | |
8977 | | - | |
8978 | | - | |
8979 | | - | |
8980 | | - | |
8981 | | - | |
8982 | | - | |
8983 | | - | |
8984 | | - | |
| 9014 | + | |
| 9015 | + | |
| 9016 | + | |
| 9017 | + | |
| 9018 | + | |
| 9019 | + | |
| 9020 | + | |
| 9021 | + | |
| 9022 | + | |
| 9023 | + | |
| 9024 | + | |
| 9025 | + | |
8985 | 9026 | | |
8986 | 9027 | | |
8987 | 9028 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1014 | 1111 | | |
1015 | 1112 | | |
1016 | 1113 | | |
| |||
1620 | 1717 | | |
1621 | 1718 | | |
1622 | 1719 | | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1623 | 1723 | | |
1624 | 1724 | | |
1625 | 1725 | | |
| |||
0 commit comments