Skip to content

Commit db5b9f8

Browse files
committed
[cmd/mdatagen] Enforce tab indentation in Go template files
Add a check-template-tabs Makefile target and CI step that fails if any .go.tmpl file under cmd/mdatagen or cmd/builder contains lines with leading spaces. Convert the two remaining offending templates (config_from_cfggen.go.tmpl and config_from_cfggen_test.go.tmpl) from space to tab indentation. Fixes #14698 Assisted-by: Claude Sonnet 4.6
1 parent 767b013 commit db5b9f8

5 files changed

Lines changed: 412 additions & 396 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
change_type: enhancement
2+
component: cmd/mdatagen
3+
note: Add CI check to ensure Go template files use tabs for indentation; fix remaining space-indented templates.
4+
issues: [14698]
5+
subtext:
6+
change_logs: [user]

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ jobs:
163163
run: |
164164
make generate-chloggen-components
165165
git diff --exit-code || (echo '.chloggen/config.yaml is out of date, please run "make generate-chloggen-components" and commit the changes.' && exit 1)
166+
- name: check-template-tabs
167+
run: make check-template-tabs
166168

167169
unittest-matrix:
168170
strategy:

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ mdatagen-test:
402402
cd cmd/mdatagen && $(MAKE) fmt
403403
cd cmd/mdatagen && $(GOCMD) test ./...
404404

405+
.PHONY: check-template-tabs
406+
check-template-tabs:
407+
@if grep -rqP "^ " cmd/mdatagen/internal/templates/*.go.tmpl cmd/builder/internal/builder/templates/*.go.tmpl; then \
408+
echo "ERROR: Go template files must use tabs for indentation, not spaces."; \
409+
grep -rPn "^ " cmd/mdatagen/internal/templates/*.go.tmpl cmd/builder/internal/builder/templates/*.go.tmpl; \
410+
exit 1; \
411+
fi
412+
405413
GITHUBGEN_ARGS ?= -skipgithub
406414
GITHUBGEN := $(GO_TOOL) githubgen $(GITHUBGEN_ARGS)
407415

0 commit comments

Comments
 (0)