Files
Kamino/scripts/dev-setup.sh
T
Defame1297andClaude Sonnet 5.5 44470c3bc3
Build / build (pull_request) Successful in 8s
Lint / lint (pull_request) Successful in 6s
chore: add scripts/dev-setup.sh and a CLAUDE.md for working in this repository
dev-setup.sh creates the virtualenv with the pinned tools and installs the git
hooks with the virtualenv first on PATH inside the hook scripts. Without that,
the language: system hooks (REUSE, changelog lint, ansible-lint) fail with
"No such file or directory: 'reuse'" on a plain `git commit`; found while testing
the hooks in a fresh clone.

CLAUDE.md records the rules of the repository for Claude Code: commit with git
so the hooks run (the Gitea API skips them, which let four lint failures reach
CI), feature branches and protected main/tags, the workflow rules, how the
images are versioned and pinned, and the 100 MB layer limit. It is written for
a repository that will be public: no addresses, no host names beyond the
public Gitea.

CONTRIBUTING.md points at the script.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-10-25 16:36:37 +00:00

37 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sets up a local checkout for development: a virtualenv with the pinned tools
# (requirements-dev.txt, the versions CI runs) and git hooks that find them.
#
# scripts/dev-setup.sh
#
# Some hooks of .pre-commit-config.yaml are `language: system` (REUSE, changelog lint,
# ansible-lint): they run their tools by name, so the tools must be on PATH when git
# runs the hook. `pre-commit install` does not arrange that, so this script puts the
# virtualenv first on PATH inside the installed hook scripts. It is idempotent; run it
# again after changing requirements-dev.txt or the hook types.
set -euo pipefail
root="$(git rev-parse --show-toplevel)"
cd "$root"
python3 -m venv .venv
.venv/bin/pip install --quiet --disable-pip-version-check -r requirements-dev.txt
.venv/bin/pre-commit install --install-hooks
marker="# kamino-dev-setup: virtualenv first on PATH"
for hook in pre-commit commit-msg; do
file="$(git rev-parse --git-path "hooks/$hook")"
if ! grep -qxF "$marker" "$file"; then
tmp="$(mktemp)"
{
head -n 1 "$file"
printf '%s\n' "$marker" "export PATH=\"$root/.venv/bin:\$PATH\""
tail -n +2 "$file"
} > "$tmp"
cat "$tmp" > "$file" # keeps the file mode of the hook
rm -f "$tmp"
fi
done
echo "Done: git commit now runs the hooks with the tools in $root/.venv/bin."