fix(hooks): fail loudly when compose_service is not a service #25
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PC-19-compose-service-preflight-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
pre-commit-composealready resolves the dev service throughcompose_service(it stopped hardcodingappin7397c2a), so a convention-named repo like roci runs its checks withcompose_service := "roci". What was still missing is the diagnosis when the name is wrong: docker answersno such service: app, which never mentions that a just variable picks the name, so the reader has nothing to act on and the practical response isgit commit --no-verify.Add
_check-compose-service, a private dependency ofpre-commit-composethat runs afterensure-envand before_pre-commit-prepare, so the failure lands before any container or host prepare step. It readsdocker compose -f compose.dev.yml config --services --no-interpolateand, whencompose_serviceis absent, prints the configured value, the services the file does define, and the variable to set, then exits non-zero.--no-interpolatekeeps the guard from failing on an unset .env variable: that is the build step's error to report, not this one's. A non-zero exit from docker itself is not swallowed either, it prints docker's stderr and the exit code.The recipe joins the
check-justfileprotected list, so a consumer cannot shadow the guard away.PC-19 proposed the variable be named
dev_service, assuming none existed. It does:compose_servicelanded in7397c2aand psa-systems/roci already sets it on its default branch (justfile:26), so renaming would break that repo on its next submodule bump and violates the blast-radius rule that variable changes stay backward compatible. The variable keeps its shipped name; the criterion is met in substance.Header contract and README no longer state the compose service must be named
app; both now namecompose_service(defaultapp) as what picks it.#PC-19
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.