{"id":31814659,"url":"https://github.com/prog-time/git-hooks","last_synced_at":"2026-02-18T22:03:02.658Z","repository":{"id":317421655,"uuid":"1020378279","full_name":"prog-time/git-hooks","owner":"prog-time","description":"Useful shell scripts for git hooks","archived":false,"fork":false,"pushed_at":"2026-02-17T20:13:35.000Z","size":116,"stargazers_count":19,"open_issues_count":7,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-17T22:30:04.202Z","etag":null,"topics":["bash","bash-script","eslint","flake8","git","hooks","phpstan","pint","prettier","pytest","shell","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prog-time.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-15T19:18:24.000Z","updated_at":"2026-02-17T20:13:34.000Z","dependencies_parsed_at":"2025-09-30T20:23:34.574Z","dependency_job_id":"20676d6e-f42e-4a10-90e6-c8e9b13cecbd","html_url":"https://github.com/prog-time/git-hooks","commit_stats":null,"previous_names":["prog-time/git-hooks"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/prog-time/git-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prog-time%2Fgit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prog-time%2Fgit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prog-time%2Fgit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prog-time%2Fgit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prog-time","download_url":"https://codeload.github.com/prog-time/git-hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prog-time%2Fgit-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-script","eslint","flake8","git","hooks","phpstan","pint","prettier","pytest","shell","shell-script"],"created_at":"2025-10-11T08:58:24.604Z","updated_at":"2026-02-18T22:03:02.651Z","avatar_url":"https://github.com/prog-time.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Hooks Collection\n\nA collection of reusable git hook scripts for automating code quality checks and developer workflows.\n\n## Features\n\n- **JavaScript/TypeScript**: ESLint, Prettier, TypeScript type checking, Vitest test runner, test existence validation\n- **Python**: Flake8 linting, Mypy static analysis, Pytest runner, service test validation (local and Docker modes)\n- **PHP/Laravel**: PHPStan analysis with progressive error reduction, Pint code style fixing, test coverage validation\n- **CSS/SCSS/Less**: Stylelint code style validation\n- **HTML**: HTMLHint linting\n- **Markdown**: markdownlint style validation\n- **YAML**: yamllint style validation\n- **Docker**: Dockerfile linting with Hadolint\n- **Shell**: Script validation with ShellCheck\n- **Git**: Branch naming conventions, automatic task ID injection in commits\n\n## Quick Start\n\n1. Clone the repository\n2. Copy desired scripts to your project's `.git/hooks/` directory\n3. Make scripts executable: `chmod +x .git/hooks/*`\n\n## Available Scripts\n\n### JavaScript / TypeScript\n\n| Script | Description |\n|--------|-------------|\n| `javascript/check_eslint_all.sh` | Runs ESLint with `--fix` across the entire project (`app/`, `components/`, `lib/`, `types/`). |\n| `javascript/check_prettier.sh` | Runs Prettier on staged `.ts` files passed as arguments. |\n| `javascript/check_prettier_all.sh` | Runs Prettier on all TypeScript files using glob patterns. |\n| `javascript/check_tsc_all.sh` | Runs TypeScript type checking via `tsconfig.check.json`. |\n| `javascript/check_vitest.sh` | Runs Vitest for specified files or the full suite. Supports `--watch` and `--coverage`. |\n| `javascript/check_vitest_all.sh` | Runs the full Vitest test suite. |\n| `javascript/check_tests.sh` | Runs Vitest only for changed/staged TypeScript files, auto-discovers matching test files. |\n| `javascript/check_tests_all.sh` | Runs the full Vitest test suite (simple wrapper). |\n| `javascript/check_test_coverage.sh` | Runs Vitest with optional `--watch` and `--coverage` flags. |\n| `javascript/check_tests_exist.sh` | Validates that each staged TypeScript source file has a corresponding `tests/...test.ts` file. |\n\n### Python\n\n| Script | Description |\n|--------|-------------|\n| `python/check_flake8.sh` | Runs Flake8 locally on Python files (line length 120). |\n| `python/check_flake8_in_docker.sh` | Runs Flake8 inside the `app_dev` Docker container. |\n| `python/check_mypy.sh` | Runs Mypy locally on changed `app/*.py` files. |\n| `python/check_mypy_in_docker.sh` | Runs Mypy inside the Docker container, maps host/container paths. |\n| `python/check_pytest.sh` | Runs the full Pytest suite locally with `PYTHONPATH=./app`. |\n| `python/check_pytest_in_docker.sh` | Runs Pytest inside the Docker container, converts container paths to host paths. |\n| `python/find_test.sh` | Validates that each service in `app/services/` has exactly one corresponding test file. |\n\n### PHP\n\n| Script | Description |\n|--------|-------------|\n| `php/check_phpstan.sh` | Runs PHPStan with progressive error reduction. Tracks error count per file and allows commits only when errors decrease. |\n| `php/laravel/check_pint.sh` | Runs Laravel Pint, auto-fixes code style issues, and stages corrected files. |\n| `php/find_test.sh` | Validates that modified PHP classes have corresponding unit tests. |\n| `php/start_test_in_docker.sh` | Runs PHPUnit tests inside Docker for modified files. |\n\n### CSS / SCSS / Less\n\n| Script | Description |\n|--------|-------------|\n| `css/check_stylelint.sh` | Runs Stylelint on staged CSS/SCSS/Less files passed as arguments. |\n| `css/check_stylelint_all.sh` | Runs Stylelint on all CSS/SCSS/Less files in the project. Used in pre-push hooks. |\n\n### HTML\n\n| Script | Description |\n|--------|-------------|\n| `html/check_htmlhint.sh` | Runs HTMLHint on staged HTML files passed as arguments. |\n| `html/check_htmlhint_all.sh` | Runs HTMLHint on all HTML files in the project. Used in pre-push hooks. |\n\n### Markdown\n\n| Script | Description |\n|--------|-------------|\n| `markdown/check_markdownlint.sh` | Runs markdownlint on staged `.md` files passed as arguments. |\n| `markdown/check_markdownlint_all.sh` | Runs markdownlint on all `.md` files in the project. Used in pre-push hooks. |\n\n### YAML\n\n| Script | Description |\n|--------|-------------|\n| `yml/check_yamllint.sh` | Runs yamllint on staged `.yml`/`.yaml` files passed as arguments. |\n| `yml/check_yamllint_all.sh` | Runs yamllint on all `.yml`/`.yaml` files in the project. Used in pre-push hooks. |\n\n### Git Workflow\n\n| Script | Description |\n|--------|-------------|\n| `git/check_branch_name.sh` | Validates branch names match pattern: `{type}/{task-id}_{description}` |\n| `git/preparations/add_task_id_in_commit.sh` | Prepends task ID from branch name to commit message. |\n| `git/preparations/prepare-commit-description.sh` | Appends list of changed files to commit message. |\n\n### Docker\n\n| Script | Description |\n|--------|-------------|\n| `docker/check_hadolint.sh` | Lints Dockerfiles using Hadolint. |\n\n### Shell\n\n| Script | Description |\n|--------|-------------|\n| `shell/check_shellcheck.sh` | Validates shell scripts using ShellCheck (via Docker). |\n| `scripts/check_shellcheck.sh` | Validates shell scripts using ShellCheck (local). |\n\n## Usage Examples\n\n### JavaScript/TypeScript\n\n```bash\n# ESLint — fix entire project\n./javascript/check_eslint_all.sh\n\n# Prettier — format specific files\n./javascript/check_prettier.sh app/utils.ts lib/helpers.ts\n\n# TypeScript type check\n./javascript/check_tsc_all.sh\n\n# Run tests for changed files (auto-discovers matching test files)\n./javascript/check_tests.sh app/utils.ts app/helpers.ts\n\n# Run Vitest with coverage\n./javascript/check_vitest.sh --coverage\n\n# Run Vitest for specific files in watch mode\n./javascript/check_vitest.sh app/utils.ts --watch\n\n# Verify test files exist for staged sources\n./javascript/check_tests_exist.sh app/utils.ts components/Header.tsx\n```\n\n### Python\n\n```bash\n# Flake8 — local\n./python/check_flake8.sh app/services/user_service.py app/routes/api.py\n\n# Flake8 — in Docker\n./python/check_flake8_in_docker.sh app/services/user_service.py\n\n# Mypy — local\n./python/check_mypy.sh app/services/auth.py app/models/user.py\n\n# Mypy — in Docker\n./python/check_mypy_in_docker.sh app/services/auth.py\n\n# Pytest — local\n./python/check_pytest.sh\n\n# Pytest — in Docker\n./python/check_pytest_in_docker.sh\n\n# Verify test files exist for services\n./python/find_test.sh app/services/user_service.py app/services/auth.py\n```\n\n### PHPStan with Progressive Error Reduction\n\n```bash\n# Default mode: requires error count to decrease by at least 1\n./php/check_phpstan.sh default src/Service.php src/Helper.php\n\n# Strict mode: requires zero errors\n./php/check_phpstan.sh strict src/Service.php\n```\n\n### CSS / SCSS / Less\n\n```bash\n# Check staged files\n./css/check_stylelint.sh styles/main.css components/button.scss\n\n# Check all files in the project\n./css/check_stylelint_all.sh\n```\n\n### HTML\n\n```bash\n# Check staged files\n./html/check_htmlhint.sh templates/index.html templates/layout.html\n\n# Check all files in the project\n./html/check_htmlhint_all.sh\n```\n\n### Markdown\n\n```bash\n# Check staged files\n./markdown/check_markdownlint.sh README.md docs/guide.md\n\n# Check all files in the project\n./markdown/check_markdownlint_all.sh\n```\n\n### YAML\n\n```bash\n# Check staged files\n./yml/check_yamllint.sh .github/workflows/ci.yml docker-compose.yml\n\n# Check all files in the project\n./yml/check_yamllint_all.sh\n```\n\n### Branch Name Validation\n\n```bash\n# In pre-commit hook\n./git/check_branch_name.sh\n# Valid: feature/dev-123_user_auth, bugfix/issue-456_fix_login\n# Invalid: main, my-branch, feature/no_task_id\n```\n\n### Task ID in Commits\n\n```bash\n# In prepare-commit-msg hook\n./git/preparations/add_task_id_in_commit.sh\n# Branch: feature/dev-123_new_feature\n# Commit: \"add validation\" → \"dev-123 | add validation\"\n```\n\n## Integration\n\n### Pre-commit Hook Example\n\n```bash\n#!/bin/bash\n# .git/hooks/pre-commit\n\nset -e\n\nFILES=$(git diff --cached --name-only --diff-filter=ACM)\n\n# JavaScript/TypeScript\nbash javascript/check_eslint_all.sh\nbash javascript/check_prettier.sh $FILES\nbash javascript/check_tests_exist.sh $FILES\nbash javascript/check_tests.sh $FILES\n\n# Python (local)\nbash python/check_flake8.sh $FILES\nbash python/check_mypy.sh $FILES\nbash python/find_test.sh $FILES\n\n# Python (Docker) — use instead of local variants if project runs in Docker\n# bash python/check_flake8_in_docker.sh $FILES\n# bash python/check_mypy_in_docker.sh $FILES\n# bash python/check_pytest_in_docker.sh\n\n# PHP\nPHP_FILES=$(echo \"$FILES\" | grep '\\.php$' || true)\n[[ -n \"$PHP_FILES\" ]] \u0026\u0026 bash php/check_phpstan.sh default $PHP_FILES\n\n# CSS/SCSS/Less\nbash css/check_stylelint.sh $FILES\n\n# HTML\nbash html/check_htmlhint.sh $FILES\n\n# Markdown\nbash markdown/check_markdownlint.sh $FILES\n\n# YAML\nbash yml/check_yamllint.sh $FILES\n\n# Shell\nSH_FILES=$(echo \"$FILES\" | grep '\\.sh$' || true)\n[[ -n \"$SH_FILES\" ]] \u0026\u0026 bash scripts/check_shellcheck.sh $SH_FILES\n```\n\n## Testing\n\n```bash\n# Run all tests\n./tests/run_all.sh\n\n# Run specific test suite\n./tests/php/phpstan/run.sh\n./tests/javascript/tests_exist/run.sh\n./tests/javascript/eslint_all/run.sh\n./tests/javascript/vitest/run.sh\n./tests/python/flake8/run.sh\n./tests/python/mypy/run.sh\n./tests/python/find_test/run.sh\n./tests/css/stylelint/run.sh\n./tests/css/stylelint_all/run.sh\n./tests/html/htmlhint/run.sh\n./tests/html/htmlhint_all/run.sh\n./tests/markdown/markdownlint/run.sh\n./tests/markdown/markdownlint_all/run.sh\n./tests/yml/yamllint/run.sh\n./tests/yml/yamllint_all/run.sh\n```\n\n## Requirements\n\n- Bash 4.0+\n- Git\n- jq\n- Node.js with npx (for JavaScript/TypeScript, CSS, HTML hooks)\n- Python 3, Flake8, Mypy, Pytest (for Python hooks)\n- PHP 8.1+ with Composer (for PHP hooks)\n- Stylelint (`npm install -g stylelint`) or via `npx`\n- HTMLHint (`npm install -g htmlhint`) or via `npx`\n- markdownlint-cli (`npm install -g markdownlint-cli`)\n- yamllint (`pip install yamllint` or system package)\n- Docker (optional, for Docker-based hooks)\n- ShellCheck (for shell validation)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprog-time%2Fgit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprog-time%2Fgit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprog-time%2Fgit-hooks/lists"}