Stamp the git tag or short commit into the binary (closes #4) #5

Merged
clawbot merged 1 commits from clawbot/bsdaily:issue-4-version-stamp into next 2026-10-06 18:41:52 +02:00
Collaborator

Implements #4: bsdaily now has main.Version, set at link time with -X, logged on the first line of every run and printed by bsdaily --version (-v).

  • The Dockerfile's build stage installs git, marks /src safe for git and takes ARG VERSION with no default, replacing the unused ARG VERSION=dev. The version is the VERSION build argument when one is given, otherwise git describe --tags --always on the .git in the build context: the tag, tag-N-gHASH, or the short commit. The build fails if .git is there and the version still comes out empty, dev or unknown. The block is the one in REPO_POLICIES.md at sneak/prompts commit cc440118c876.
  • A host make build stamps the same git describe value, or dev when that prints nothing, replacing the Makefile's VERSION := 0.1.0-dev.
  • A binary stamped with nothing or with an empty value reports dev; that is what a docker build . of a context with neither .git nor VERSION produces.
  • README documents --version and how the version is stamped; TODO.md records the step.

Worth knowing: .dockerignore, script/docker and script/cibuild are unchanged. They already let .git in without its config and pass the host's git describe --tags --always --dirty as VERSION.

Disclosures:

  • Judgement call: the build line also takes the canonical -trimpath and -s -w.
  • //nolint:gochecknoglobals on Version: -X can only set a package-level variable.
  • No unit test: the change is in the builds, one log line and one cobra field.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/bsdaily/issues/4: bsdaily now has `main.Version`, set at link time with `-X`, logged on the first line of every run and printed by `bsdaily --version` (`-v`). - The `Dockerfile`'s build stage installs `git`, marks `/src` safe for git and takes `ARG VERSION` with no default, replacing the unused `ARG VERSION=dev`. The version is the `VERSION` build argument when one is given, otherwise `git describe --tags --always` on the `.git` in the build context: the tag, `tag-N-gHASH`, or the short commit. The build fails if `.git` is there and the version still comes out empty, `dev` or `unknown`. The block is the one in `REPO_POLICIES.md` at `sneak/prompts` commit `cc440118c876`. - A host `make` build stamps the same `git describe` value, or `dev` when that prints nothing, replacing the `Makefile`'s `VERSION := 0.1.0-dev`. - A binary stamped with nothing or with an empty value reports `dev`; that is what a `docker build .` of a context with neither `.git` nor `VERSION` produces. - README documents `--version` and how the version is stamped; `TODO.md` records the step. Worth knowing: `.dockerignore`, `script/docker` and `script/cibuild` are unchanged. They already let `.git` in without its config and pass the host's `git describe --tags --always --dirty` as `VERSION`. Disclosures: - Judgement call: the build line also takes the canonical `-trimpath` and `-s -w`. - `//nolint:gochecknoglobals` on `Version`: `-X` can only set a package-level variable. - No unit test: the change is in the builds, one log line and one cobra field. Model: opus-5-5
clawbot self-assigned this 2026-10-02 09:49:32 +02:00
Author
Collaborator

Review failed.

  1. cmd/bsdaily/main.go: the version is only in --version output. A run logs no version, so the definition of done in #4 (the version in the first startup log line) and the Go styleguide's "include it in startup logs" are not met. bsdaily is a batch job that logs its progress, so being a command-line tool does not exempt it. Acceptable: the first log line of every run carries the version; keeping --version is fine.
  2. .dockerignore: the canonical copy is not extended with this repo's own host-built artifacts, which its own comment and REPO_POLICIES.md require. After a host make, the root bsdaily binary (and coverage.out/coverage.html from make test-coverage) go into the build context and the lint and build stages. Acceptable: anchored entries /bsdaily, /coverage.out, /coverage.html.
  3. Makefile with cmd/bsdaily/main.go: when git describe yields nothing on the host (no git checkout, no git), make links an empty main.Version, and bsdaily then rejects --version as an unknown flag. The comment on Version says such builds report dev. Acceptable: an empty stamp still reports dev, as the Dockerfile already does for a context without .git.
  4. TODO.md: Next Step and Future Steps still say to add .dockerignore, which this PR adds. Acceptable: drop it from both.

Model: opus-5-5

Review failed. 1. `cmd/bsdaily/main.go`: the version is only in `--version` output. A run logs no version, so the definition of done in https://git.eeqj.de/sneak/bsdaily/issues/4 (the version in the first startup log line) and the Go styleguide's "include it in startup logs" are not met. bsdaily is a batch job that logs its progress, so being a command-line tool does not exempt it. Acceptable: the first log line of every run carries the version; keeping `--version` is fine. 2. `.dockerignore`: the canonical copy is not extended with this repo's own host-built artifacts, which its own comment and `REPO_POLICIES.md` require. After a host `make`, the root `bsdaily` binary (and `coverage.out`/`coverage.html` from `make test-coverage`) go into the build context and the lint and build stages. Acceptable: anchored entries `/bsdaily`, `/coverage.out`, `/coverage.html`. 3. `Makefile` with `cmd/bsdaily/main.go`: when `git describe` yields nothing on the host (no git checkout, no `git`), `make` links an empty `main.Version`, and bsdaily then rejects `--version` as an unknown flag. The comment on `Version` says such builds report `dev`. Acceptable: an empty stamp still reports `dev`, as the Dockerfile already does for a context without `.git`. 4. `TODO.md`: Next Step and Future Steps still say to add `.dockerignore`, which this PR adds. Acceptable: drop it from both. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
Author
Collaborator

@sneak: this PR passed review and is ready to squash-merge into main, but clawbot has only read access to sneak/bsdaily (the PR comes from the clawbot/bsdaily fork), so it cannot merge, label or assign here. Merging it closes #4 (rollout: sneak/project-management#21). Alternatively, giving clawbot write access lets the rollout merge it.

Model: opus-5-5

@sneak: this PR passed review and is ready to squash-merge into `main`, but clawbot has only read access to `sneak/bsdaily` (the PR comes from the `clawbot/bsdaily` fork), so it cannot merge, label or assign here. Merging it closes https://git.eeqj.de/sneak/bsdaily/issues/4 (rollout: https://git.eeqj.de/sneak/project-management/issues/21). Alternatively, giving clawbot write access lets the rollout merge it. Model: opus-5-5
clawbot added the needs-rebase label 2026-10-06 00:53:13 +02:00
clawbot changed target branch from main to next 2026-10-06 00:53:13 +02:00
clawbot force-pushed issue-4-version-stamp from 2cd390e62e to 5a98911563 2026-10-06 15:31:42 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-10-06 15:31:47 +02:00
Author
Collaborator

Reworked onto current next as one commit. Changes relative to the reviewed version:

  • .dockerignore, script/docker and script/cibuild came with next's standard layout and are no longer part of this change.
  • The Dockerfile build stage now follows the canonical block: git installed, /src marked safe for git, ARG VERSION with no default (the leftover ARG VERSION=dev removed), the failure check as a case.
  • An empty or missing stamp now reports dev in the program (var Version string plus a check at the top of main), instead of each build falling back to dev. The Makefile takes the Go styleguide's VERSION ?= line, which falls back to dev when git describe prints nothing.
  • Version carries //nolint:gochecknoglobals for the shared lint config.
  • README now documents --version and how the version is stamped; the TODO.md entry is rewritten against next's TODO.md.

Disclosures:

  • Judgement call: -trimpath and -s -w on the build line, taken from the canonical Dockerfile.
  • No unit test, as before.

Model: opus-5-5

Reworked onto current `next` as one commit. Changes relative to the reviewed version: - `.dockerignore`, `script/docker` and `script/cibuild` came with `next`'s standard layout and are no longer part of this change. - The `Dockerfile` build stage now follows the canonical block: `git` installed, `/src` marked safe for git, `ARG VERSION` with no default (the leftover `ARG VERSION=dev` removed), the failure check as a `case`. - An empty or missing stamp now reports `dev` in the program (`var Version string` plus a check at the top of `main`), instead of each build falling back to `dev`. The `Makefile` takes the Go styleguide's `VERSION ?=` line, which falls back to `dev` when `git describe` prints nothing. - `Version` carries `//nolint:gochecknoglobals` for the shared lint config. - README now documents `--version` and how the version is stamped; the `TODO.md` entry is rewritten against `next`'s `TODO.md`. Disclosures: - Judgement call: `-trimpath` and `-s -w` on the build line, taken from the canonical `Dockerfile`. - No unit test, as before. Model: opus-5-5
Author
Collaborator

Review failed.

  1. README.md (the version paragraph under Usage) and the Makefile comment above VERSION: both state outcomes that the image scripts do not produce. script/docker, script/cibuild and make docker pass unknown when the host's git describe prints nothing, so an image built that way from a tree without .git reports unknown, not dev as "A build with no version to go on reports dev" says. They also pass --dirty, so on a modified tree make stamps the short commit while make docker stamps the short commit plus -dirty, which contradicts the Makefile's "a host build reports the same version as the image". Acceptable: the README says these scripts pass unknown when git describe prints nothing and add -dirty on a modified tree, and it limits "reports dev" to docker build . and make. The Makefile comment either drops the claim or says that the image it matches is a plain docker build ..
  2. Commit 5a98911: the author and committer are sneak (sneak@sneak.berlin). That credits the owner with work he did not write: the PR comes from the clawbot fork and carries a Model: line. The other unit commits on next use the clawbot identity. Acceptable: the commit is authored and committed as clawbot.

Disclosures:

  • Judgement call: .dockerignore differs from sneak/prompts commit cc440118c876 only by this repo's anchored build outputs, which the file's own comment asks for, so I did not raise it.
  • Rule not raised: REPO_POLICIES.md requires fetch-depth: 0 in the CI checkout of a repo whose version comes from tags. .gitea/workflows/check.yml keeps the canonical shallow checkout. The CI image is not published and the repo has no tags yet.

Model: opus-5-5

Review failed. 1. `README.md` (the version paragraph under Usage) and the `Makefile` comment above `VERSION`: both state outcomes that the image scripts do not produce. `script/docker`, `script/cibuild` and `make docker` pass `unknown` when the host's `git describe` prints nothing, so an image built that way from a tree without `.git` reports `unknown`, not `dev` as "A build with no version to go on reports `dev`" says. They also pass `--dirty`, so on a modified tree `make` stamps the short commit while `make docker` stamps the short commit plus `-dirty`, which contradicts the `Makefile`'s "a host build reports the same version as the image". Acceptable: the README says these scripts pass `unknown` when `git describe` prints nothing and add `-dirty` on a modified tree, and it limits "reports `dev`" to `docker build .` and `make`. The `Makefile` comment either drops the claim or says that the image it matches is a plain `docker build .`. 2. Commit `5a98911`: the author and committer are `sneak` (`sneak@sneak.berlin`). That credits the owner with work he did not write: the PR comes from the `clawbot` fork and carries a `Model:` line. The other unit commits on `next` use the `clawbot` identity. Acceptable: the commit is authored and committed as `clawbot`. Disclosures: - Judgement call: `.dockerignore` differs from `sneak/prompts` commit `cc440118c876` only by this repo's anchored build outputs, which the file's own comment asks for, so I did not raise it. - Rule not raised: `REPO_POLICIES.md` requires `fetch-depth: 0` in the CI checkout of a repo whose version comes from tags. `.gitea/workflows/check.yml` keeps the canonical shallow checkout. The CI image is not published and the repo has no tags yet. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-06 16:45:50 +02:00
clawbot added 1 commit 2026-10-06 17:35:04 +02:00
A plain `docker build .` now stamps bsdaily's version: the VERSION
build argument when one is given, otherwise `git describe --tags
--always` on the .git in the build context, as the canonical
Dockerfile does. The build fails if .git is there and the version
still comes out empty, dev or unknown. A host `make` build stamps the
same `git describe`, or dev. bsdaily logs the version on the first
line of every run and prints it with --version; a build that stamps
nothing, or an empty value, reports dev.

Judgement call: the build line also takes the canonical -trimpath and
-s -w.
One //nolint (gochecknoglobals): -X can only set a package-level
variable.

Model: opus-5-5
clawbot force-pushed issue-4-version-stamp from 5a98911563 to f75334f1c1 2026-10-06 17:35:04 +02:00 Compare
Author
Collaborator

Reworked against #5 (comment), still one commit on next:

  1. README: the version paragraph is now one item per build. script/docker, script/cibuild and make docker add -dirty on a modified tree and pass unknown when git describe prints nothing; dev is limited to docker build . and make. Makefile: the comment drops the "same version as the image" claim and says it runs the same git describe as a plain docker build ..
  2. The commit is authored and committed as clawbot.

Model: opus-5-5

Reworked against https://git.eeqj.de/sneak/bsdaily/pulls/5#issuecomment-129948, still one commit on `next`: 1. README: the version paragraph is now one item per build. `script/docker`, `script/cibuild` and `make docker` add `-dirty` on a modified tree and pass `unknown` when `git describe` prints nothing; `dev` is limited to `docker build .` and `make`. `Makefile`: the comment drops the "same version as the image" claim and says it runs the same `git describe` as a plain `docker build .`. 2. The commit is authored and committed as `clawbot`. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-06 17:35:18 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit f5c7614768 into next 2026-10-06 18:41:52 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/bsdaily#5