Dev setup: correct the hook claim, ship an opt-in committed hook
The naming check was documented as an auto-running pre-commit hook, but .git/hooks is never cloned and no installer existed - a fresh clone had nothing, and the real enforcement is CI. Say that plainly. Ship .githooks/pre-commit (LF-pinned) so a dev who wants the local check can opt in with 'git config core.hooksPath .githooks'; CI stays the backstop that fails the build on a bad name.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -3,3 +3,4 @@
|
||||
# Shell scripts must stay LF so Git Bash on Windows can run them
|
||||
*.sh text eol=lf
|
||||
scripts/check-naming-and-style.sh text eol=lf
|
||||
.githooks/pre-commit text eol=lf
|
||||
|
||||
5
.githooks/pre-commit
Executable file
5
.githooks/pre-commit
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Committed pre-commit hook. Activate per clone with:
|
||||
# git config core.hooksPath .githooks
|
||||
# Runs the naming/style gate; blocks the commit on failure.
|
||||
exec bash "$(git rev-parse --show-toplevel)/scripts/check-naming-and-style.sh"
|
||||
@@ -32,14 +32,14 @@ sane, then use manual for day-to-day work.
|
||||
|
||||
## 1. Get the code
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
git clone https://github.com/ge-aero/shopdb-flask.git
|
||||
cd shopdb-flask
|
||||
```
|
||||
|
||||
Never work on `main`. Branch for your change:
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
git checkout -b feat/<short-description>
|
||||
```
|
||||
|
||||
@@ -47,8 +47,8 @@ git checkout -b feat/<short-description>
|
||||
|
||||
## 2a. Fast path - Docker (a working site in one command)
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```powershell
|
||||
copy .env.example .env
|
||||
# Edit .env: set SECRET_KEY, JWT_SECRET_KEY, and the MYSQL_* passwords.
|
||||
# Generate a secret: python -c "import secrets;print(secrets.token_urlsafe(64))"
|
||||
|
||||
@@ -76,7 +76,7 @@ hot-reloads.
|
||||
Either point at an existing MySQL 8, or bring one up with just the db service
|
||||
from compose:
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
docker compose up -d db # MySQL on 127.0.0.1:3306
|
||||
```
|
||||
|
||||
@@ -130,13 +130,13 @@ foreach ($p in "computers","employees","machines","measuringtools","network",
|
||||
Run the backend ON PORT 5001 - the frontend dev server proxies `/api` and
|
||||
`/static` there (a bare `flask run` uses 5000 and nothing will load):
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
flask run --port 5001
|
||||
```
|
||||
|
||||
### Frontend (a second terminal)
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev # http://localhost:5173
|
||||
@@ -173,17 +173,27 @@ tasks call `venv/` and `frontend/node_modules`).
|
||||
## 3. The development loop
|
||||
|
||||
1. Make a change. Backend: `flask run` auto-reloads. Frontend: Vite hot-reloads.
|
||||
2. Before committing, run the same three gates CI runs. In VS Code the
|
||||
task **Check: naming + tests + build** runs all three; by hand:
|
||||
2. Before committing, run the three gates. Easiest: in VS Code, Command
|
||||
Palette > "Tasks: Run Task" > **Check: naming + tests + build**. By hand
|
||||
in PowerShell:
|
||||
```powershell
|
||||
bash scripts/check-naming-and-style.sh # naming hook - needs Git Bash
|
||||
venv\Scripts\python -m pytest tests/ -q # backend
|
||||
cd frontend; npx vitest run; npm run build
|
||||
cd frontend; npx vitest run; npm run build; cd ..
|
||||
bash scripts/check-naming-and-style.sh # naming - runs via Git Bash
|
||||
```
|
||||
The naming check is a bash script; on Windows it runs under Git Bash
|
||||
(installed with Git for Windows). The git PRE-COMMIT hook runs it
|
||||
automatically on every `git commit`, so a bad name is caught even if you
|
||||
forget to run it - just make sure Git for Windows is installed.
|
||||
There is NO auto-installed git hook - you run these yourself (or the
|
||||
VS Code task). CI runs all three on every push and will fail the build
|
||||
if a name is wrong, so nothing bad reaches `main`; running them locally
|
||||
just saves the round trip. The naming check is a shell script, so that
|
||||
one line needs Git Bash (installed with Git for Windows).
|
||||
|
||||
Want it automatic? The repo ships a hook; enable it once per clone:
|
||||
```powershell
|
||||
git config core.hooksPath .githooks
|
||||
```
|
||||
Now every `git commit` runs the naming check first (Git for Windows
|
||||
executes the hook under its bundled bash) and blocks the commit if a name
|
||||
is wrong. Purely local convenience; CI is the real backstop.
|
||||
3. Commit in small, working steps. Subject: short, present tense, plain
|
||||
English; body says WHY. Read `CONTRIBUTING.md` before naming anything - the
|
||||
naming hook will reject snake_case DB columns, banned shorthand, and
|
||||
@@ -206,7 +216,7 @@ answer key. It touches every hook the framework has.
|
||||
|
||||
## 5. Contributing back
|
||||
|
||||
```bash
|
||||
```powershell
|
||||
git push -u origin feat/<short-description>
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user