diff --git a/prompts/REPO_POLICIES.md b/prompts/REPO_POLICIES.md index 1a39f0e..2e867eb 100644 --- a/prompts/REPO_POLICIES.md +++ b/prompts/REPO_POLICIES.md @@ -543,6 +543,8 @@ style conventions are in separate documents: - fails on a Mac without `timeout`, until it is installed. - needs `$HOME/.pipenv/bin` on `PATH`. +## Version + - **A plain `docker build .` of a clone stamps the version that `git describe --tags --always` gives.** The version is derived from the `.git` in the build context, as the `prompts` repo's `examples/go.Dockerfile` shows. @@ -563,15 +565,11 @@ style conventions are in separate documents: `--always` makes an untagged repo yield an abbreviated commit hash rather than failing. The `[ -n "$version" ]` line is the single place the fallback - is applied. That line is a live check that fires on a build from an export - with no `.git`, and on a repository with no commits yet. Do not fold it into - the substitution as `|| echo unknown`, which makes the guard unreachable. - The Dockerfile's side is `ARG VERSION` in the stage that compiles, declared - there because `ARG` is stage-scoped. Passing `VERSION` to a repo whose - Dockerfile declares no such `ARG` is ignored and costs nothing, which is why - the scripts stay byte-identical. One consequence for CI: the standard - checkout action clones shallow and fetches no tags, so the canonical - `.gitea/workflows/check.yml` sets `fetch-depth: 0` on its checkout step. + is applied. It is a live check that fires on a build from an export with no + `.git`, and on a repository with no commits yet. Do not fold it into the + substitution as `|| echo unknown`, which makes the guard unreachable. + Passing `VERSION` to a repo whose Dockerfile declares no such `ARG` is + ignored and costs nothing, which is why the scripts stay byte-identical. - `.dockerignore` lets `.git` into the build context. It keeps out every git `config` at any depth (`**/.git/config`, `**/.git/modules/**/config`): - the repository's own @@ -598,15 +596,16 @@ style conventions are in separate documents: (`git config --system --add safe.directory /src`). A context sent as a tar stream keeps the sender's file owners, and git refuses a checkout owned by another user, so the version would come out empty. - `ARG VERSION` has no default. The build fails if the context carries - `.git` and the version still comes out empty, `dev` or `unknown`. A - plain `docker build .` with no build arguments must succeed; a - Dockerfile that refuses an empty build argument drops that refusal and - keeps the argument. A checkout whose `.git` is a file is the exception: - a linked worktree, or a repository checked out as a submodule. That file - points to a git directory outside the build context, so the build cannot - read the version and a plain `docker build .` fails. Pass the version - with `--build-arg VERSION=...`, as `script/docker` and `script/cibuild` + `ARG VERSION` is declared in that stage, because `ARG` is stage-scoped. + It has no default. The build fails if the context carries `.git` and the + version still comes out empty, `dev` or `unknown`. A plain + `docker build .` with no build arguments must succeed; a Dockerfile that + refuses an empty build argument drops that refusal and keeps the + argument. A checkout whose `.git` is a file is the exception: a linked + worktree, or a repository checked out as a submodule. That file points + to a git directory outside the build context, so the build cannot read + the version and a plain `docker build .` fails. Pass the version with + `--build-arg VERSION=...`, as `script/docker` and `script/cibuild` already do. - Every repo should have a Gitea Actions workflow (`.gitea/workflows/`) that