generated from mathias/template-go-web
Initial commit
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Is this checkout still a raw, unsubstituted template?
|
||||
#
|
||||
# Prints "true" or "false". cd.yml's guard job reads it and skips check/build/
|
||||
# deploy when true, so that a template repo does not try to build itself.
|
||||
#
|
||||
# WHY A PATTERN AND NOT A LITERAL
|
||||
#
|
||||
# The scaffolders (gitea-mcp create_project_from_template, local-dev
|
||||
# scripts/new-project.sh) substitute placeholders in EVERY file of the tree —
|
||||
# including this one. So a guard that greps a whole placeholder token is
|
||||
# rewritten by the very substitution it exists to detect: in the template it
|
||||
# greps the module-path placeholder, and in the generated repo that same line
|
||||
# has become a grep for the real module path — which the generated go.mod
|
||||
# declares on its first line. It matches forever, every job below skips, and the
|
||||
# run reports green having built nothing.
|
||||
#
|
||||
# That shipped twice: #9 (cad-atlas) and #10 (openbanking-api), the second one
|
||||
# sitting directly under a comment warning against exactly this.
|
||||
#
|
||||
# Note this comment names no placeholder literally, for the same reason. A
|
||||
# comment that gets substituted stops explaining the thing it documents — and
|
||||
# scripts/tests/is-template_test.sh enforces that, which is how the first draft
|
||||
# of this file was caught.
|
||||
#
|
||||
# The regex below matches the SHAPE of a placeholder and contains no complete
|
||||
# token, so there is nothing for a scaffolder to rewrite. It also catches any
|
||||
# other leftover placeholder, not just the two the scaffolders know about.
|
||||
#
|
||||
# scripts/tests/is-template_test.sh substitutes a copy of this file and asserts
|
||||
# it still answers correctly — that case is the regression test for the class.
|
||||
set -euo pipefail
|
||||
|
||||
target="${1:-go.mod}"
|
||||
|
||||
if [ ! -f "$target" ]; then
|
||||
# Never answer "false" here. A missing target would skip CI on a repo that is
|
||||
# not a template at all, which is the same fake-green failure by another road.
|
||||
echo "is-template: no such file: $target" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if grep -qE '__[A-Z][A-Z0-9_]*__' "$target"; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
Reference in New Issue
Block a user