mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
719c24829a
Follow-up to #22612. Running `git status --short` in a loop during `make -B -j gen` still showed intermediate states for several files. This PR fixes the remaining ones. The main issues: - `generate.sh` ran `gofmt` and `goimports` in-place after moving files into the source tree. Now it formats in a workdir first and only `mv`s the final result. - `protoc` targets wrote directly to the source tree. Wrapped with `scripts/atomic_protoc.sh` which redirects output to a tmpdir. - Several generators used hardcoded `/tmp/` paths. On systems where `/tmp` is tmpfs, `mv` degrades to copy+delete. Switched to a project-local `_gen/` directory (gitignored, same filesystem). - `apidoc/.gen` and `cli/index.md` used `cp` for final output. Replaced with `mv`. - `manifest.json` was written twice (unformatted, then formatted). Now `.gen` writes to a staging file and the manifest target does one formatted atomic write. - `biome_format.sh` silently skipped files in gitignored dirs. Added `--vcs-enabled=false`. Two helpers reduce the Makefile boilerplate: `scripts/atomic_protoc.sh` (wraps protoc) and an `atomic_write` Make define (stdout-to-temp-to-target pattern). `.PRECIOUS` now also covers `.pb.go` and mock files. Verification: `make -B -j gen` x3 with `git status` polling, no changes. Refs #22612
34 lines
794 B
Bash
Executable File
34 lines
794 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
echo "usage: $0 <path-relative-to-site>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
repo_root=$(cd "$script_dir/.." && pwd)
|
|
target=$1
|
|
|
|
output_file=$(mktemp)
|
|
trap 'rm -f "$output_file"' EXIT
|
|
|
|
if (
|
|
cd "$repo_root/site"
|
|
pnpm exec biome format --write --vcs-enabled=false "$target"
|
|
) >"$output_file" 2>&1; then
|
|
cat "$output_file"
|
|
exit 0
|
|
fi
|
|
status=$?
|
|
|
|
cat "$output_file" >&2
|
|
|
|
if [[ $status -eq 127 ]] || grep -q "Could not start dynamically linked executable" "$output_file" || grep -q "NixOS cannot run dynamically linked executables" "$output_file"; then
|
|
echo "WARNING: skipping biome format for '$target' because the biome binary is unavailable in this environment." >&2
|
|
exit 0
|
|
fi
|
|
|
|
exit $status
|