package issue import "strings" // The type templates, verbatim from references/format.md. // // Section headers are fixed English literals in a fixed order; body prose is // Russian. Both halves of that rule are in the strings below, and the format // document is the source of truth for them. const specSection = "## Spec\nnone\n" var templates = map[string]string{ "bug": `## Summary Что сломано и где проявляется, одно-два предложения. ` + specSection + ` ## Steps to reproduce 1. … 2. … ## Expected Что должно было произойти. ## Actual Что происходит на самом деле: вывод команды, лог. ## Environment Только релевантное: версии, ОС, конфигурация. ## Acceptance criteria - [ ] баг не воспроизводится по шагам выше - [ ] добавлена проверка на регрессию (если применимо) `, "task": `## Summary Что нужно сделать, одно-два предложения. ` + specSection + ` ## Motivation Какую проблему пользователя/системы это решает. ## Acceptance criteria - [ ] проверяемое условие - [ ] … `, "refactor": `## Summary Что перестраиваем и в каких файлах (` + "`path/file:line`" + `). ` + specSection + ` ## Motivation Чем плохо текущее состояние: дублирование, связность, читаемость. ## Invariants Что НЕ должно измениться: поведение, публичные API, форматы данных. ## Acceptance criteria - [ ] проверяемое условие (тесты зелёные, старый путь удалён, …) `, "test": `## Summary Что покрываем тестами и где (` + "`path/file:line`" + `). ` + specSection + ` ## Motivation Зачем: регрессия после бага, пробел в покрытии, флаки-тест. ## Test cases - сценарий → ожидаемый результат - … ## Acceptance criteria - [ ] перечисленные кейсы покрыты и зелёные - [ ] тесты проходят в CI `, "feature": `## Summary Бизнес-ценность одним-двумя предложениями. ` + specSection + ` ## Motivation Какую проблему пользователя/системы это решает. ## Issues - [ ] slug-дочернего-issue — краткое описание части - [ ] … ## Acceptance criteria - [ ] все дочерние issues закрыты - [ ] проверяемое условие уровня фичи `, "draft": `## Summary Идея одним-двумя предложениями. ` + specSection + ` ## Notes Свободные заметки: что известно, открытые вопросы, варианты. `, } // Template is the prefilled body for a type, with `## Depends on` inserted // right after `## Spec` when the issue has dependencies. func Template(typ string, depends []string) string { return withDepends(templates[typ], depends) } // withDepends places the section where the format says it goes: after // `## Spec`, before everything else. Appended at the end only when the // template has no third section to sit in front of. func withDepends(body string, depends []string) string { if len(depends) == 0 { return body } var b strings.Builder b.WriteString("## Depends on\n") for _, d := range depends { b.WriteString("- " + d + "\n") } block := b.String() var out []string placed := false for _, line := range strings.SplitAfter(body, "\n") { if !placed && len(out) > 0 && strings.HasPrefix(line, "## ") && !strings.HasPrefix(line, SummarySection) && !strings.HasPrefix(line, SpecSection) { out = append(out, block+"\n") placed = true } out = append(out, line) } if !placed { out = append(out, "\n"+block) } return strings.Join(out, "") }