исправлены находки ревью проектной стороны

- манифест читается так, как записан: решётка внутри строки не открывает
  комментарий, скобка внутри комментария не закрывает массив, имя внутри
  комментария не становится подпиской; новый ключ встаёт после массива,
  а не внутрь него
- всё записываемое проходит через manifest.Quote — обратный слэш в пути
  делал файл, который инструмент сам не читает
- маркер локальной части переехал в doc и пропускает огороженные блоки:
  процитированный в примере маркер больше не считается границей, а копия
  без маркера не перезаписывается молча
- лишний позиционный аргумент отсекается: flag прекращал разбор и прятал
  флаги после себя, из-за чего pull, list и check игнорировали --for
- заведены тесты проверок копий, включая молчание на исправной копии
This commit is contained in:
av
2026-07-27 21:16:29 +03:00
parent 23d88c4048
commit b6b0976c19
19 changed files with 904 additions and 197 deletions
+18 -23
View File
@@ -19,9 +19,10 @@ import (
// below it takes a prefix on X.
// CopyMarker is the boundary between what the suite wrote and what the
// repository wrote. It is passed in rather than known here: the marker belongs
// to the model of assembly, and the checks merely respect it.
const CopyMarker = "<!-- conv:local -->"
// repository wrote. It is one constant, defined next to the parsing that has to
// respect it: two of them would drift apart in silence, and each half of the
// tool would then read a different file.
const CopyMarker = doc.LocalMarker
// Copy checks one assembled convention.
func Copy(d *doc.Document, rep *Report) {
@@ -34,8 +35,12 @@ func Copy(d *doc.Document, rep *Report) {
}
d.Blocks(v)
marker := markerLine(d)
checkMarker(d, marker, rep)
markers := d.Markers()
marker := 0
if len(markers) > 0 {
marker = markers[0]
}
checkMarker(d, markers, rep)
checkCopyHeadings(d, marker, rep)
checkHeadingHierarchy(d, rep)
for _, prefix := range prefixes(d) {
@@ -87,28 +92,18 @@ func recognize(d *doc.Document, rep *Report) (lang.Vocabulary, bool) {
return v, true
}
// markerLine finds the line the local marker stands on, or zero.
func markerLine(d *doc.Document) int {
for n := 1; n <= d.Len(); n++ {
if strings.TrimSpace(d.Line(n)) == CopyMarker {
return n
}
}
return 0
}
func checkMarker(d *doc.Document, marker int, rep *Report) {
if marker == 0 {
// checkMarker checks the boundary of the local part. A marker quoted inside a
// fenced block is not one — a convention about keeping copies carries such a
// quotation — and the parser has already left those out.
func checkMarker(d *doc.Document, markers []int, rep *Report) {
if len(markers) == 0 {
rep.Errorf(Spread, d.Path, d.Len(),
"the copy carries no %s marker: there is nowhere to write a derogation, and a reassembly would overwrite whatever was written instead", CopyMarker)
return
}
for n := marker + 1; n <= d.Len(); n++ {
if strings.TrimSpace(d.Line(n)) == CopyMarker {
rep.Errorf(Spread, d.Path, n,
"the copy carries a second %s marker: the marker is one, and everything below the first belongs to the repository", CopyMarker)
return
}
if len(markers) > 1 {
rep.Errorf(Spread, d.Path, markers[1],
"the copy carries a second %s marker: the marker is one, and everything below the first belongs to the repository", CopyMarker)
}
}