File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ MAX=$(( 102760448 )) # 98MB in bytes
5+
6+ echo " [pre-commit] Checking file sizes (max 98MB)..."
7+ # Check staged files
8+ while IFS= read -r -d ' ' f; do
9+ if [ -f " $f " ]; then
10+ sz=$( wc -c < " $f " | tr -d ' ' )
11+ if [ " $sz " -ge " $MAX " ]; then
12+ echo " Error: staged file exceeds 98MB: $f ($sz bytes)" >&2
13+ exit 1
14+ fi
15+ fi
16+ done < <( git diff --cached --name-only -z)
17+
18+ # Check tracked files as extra safety
19+ while IFS= read -r -d ' ' f; do
20+ if [ -f " $f " ]; then
21+ sz=$( wc -c < " $f " | tr -d ' ' )
22+ if [ " $sz " -ge " $MAX " ]; then
23+ echo " Error: tracked file exceeds 98MB: $f ($sz bytes)" >&2
24+ exit 1
25+ fi
26+ fi
27+ done < <( git ls-files -z)
28+
29+ echo " [pre-commit] Running pytest (if available)..."
30+ if command -v pytest > /dev/null 2>&1 ; then
31+ QT_QPA_PLATFORM=offscreen pytest -q
32+ elif [ -x " .venv/bin/pytest" ]; then
33+ QT_QPA_PLATFORM=offscreen .venv/bin/pytest -q
34+ else
35+ echo " pytest not found, skipping tests. Install with: python -m pip install -r requirements.txt" >&2
36+ fi
37+
38+ echo " [pre-commit] OK"
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 2.0.0" ,
3+ "tasks" : [
4+ {
5+ "label" : " setup venv" ,
6+ "type" : " shell" ,
7+ "command" : " python3 -m venv .venv && . .venv/bin/activate && python -m pip install --upgrade pip" ,
8+ "problemMatcher" : []
9+ },
10+ {
11+ "label" : " install deps" ,
12+ "type" : " shell" ,
13+ "command" : " . .venv/bin/activate && python -m pip install -r requirements.txt" ,
14+ "problemMatcher" : []
15+ },
16+ {
17+ "label" : " pytest" ,
18+ "type" : " shell" ,
19+ "command" : " QT_QPA_PLATFORM=offscreen . .venv/bin/activate && pytest -q" ,
20+ "problemMatcher" : []
21+ },
22+ {
23+ "label" : " run PyQt6 GUI" ,
24+ "type" : " shell" ,
25+ "command" : " . .venv/bin/activate && python GUI_pyqt6_WINFF.py" ,
26+ "problemMatcher" : []
27+ },
28+ {
29+ "label" : " run Tkinter GUI" ,
30+ "type" : " shell" ,
31+ "command" : " . .venv/bin/activate && python GUI_tkinter_WINFF.py" ,
32+ "problemMatcher" : []
33+ },
34+ {
35+ "label" : " install hooks" ,
36+ "type" : " shell" ,
37+ "command" : " git config core.hooksPath .githooks && chmod +x .githooks/pre-commit" ,
38+ "problemMatcher" : []
39+ }
40+ ]
41+ }
Original file line number Diff line number Diff line change 1+ PY ?= python
2+ PIP ?= $(PY ) -m pip
3+
4+ .PHONY : venv install test lint run-pyqt run-tk hooks
5+
6+ venv :
7+ $(PY ) -m venv .venv
8+ . .venv/bin/activate && $(PIP ) install --upgrade pip
9+
10+ install :
11+ . .venv/bin/activate && $(PIP ) install -r requirements.txt
12+
13+ test :
14+ QT_QPA_PLATFORM=offscreen . .venv/bin/activate && pytest -q
15+
16+ run-pyqt :
17+ . .venv/bin/activate && $(PY ) GUI_pyqt6_WINFF.py
18+
19+ run-tk :
20+ . .venv/bin/activate && $(PY ) GUI_tkinter_WINFF.py
21+
22+ hooks :
23+ git config core.hooksPath .githooks
24+ chmod +x .githooks/pre-commit
25+ @echo " Git hooks installed."
You can’t perform that action at this time.
0 commit comments