chore: add pre-commit hook to block direct pushes to main
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- bash, git, yaml
- Domain
- developer-experience, documentation, tooling
Research direction
Start with the proposed .pre-commit-config.yaml in the repository root and the README setup section. Install pre-commit, run the hook on a feature branch and on main, and verify that direct pushes to main are blocked while the setup instructions are complete and accurate.
Written by the indexing model from the issue text.
Description
Problem
AI-assisted sessions occasionally push commits directly to main instead of creating a feature branch first. This bypasses code review and can introduce unreviewed changes to production pipelines.
Proposed fix
Add a pre-commit hook that blocks direct pushes to main.
.pre-commit-config.yaml in repo root:
repos:
- repo: local
hooks:
- id: no-direct-main-push
name: Block direct push to main
entry: bash -c 'branch=$(git rev-parse --abbrev-ref HEAD); if [ "$branch" = "main" ]; then echo "ERROR: Direct push to main is blocked. Create a feature branch and open a PR."; exit 1; fi'
language: system
stages: [pre-push]
One-time setup per clone:
pip install pre-commit
pre-commit install --hook-type pre-push
This should also be documented in the repo README setup section.
Notes
pre-commitis already a standard tool in data engineering repos- The hook is bypassable with
--no-verify(intentional escape hatch for genuine emergencies) - Branch protection rules would be the stronger fix but require a paid GitHub plan
- Dominant language
- HTML
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataStrategist/notes2kg
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in DataStrategist/notes2kg
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hemilabs/ui-monorepo#2332 ·
-
Help-Wanted Needs-Triage Package-Update
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/winget-pkgs#438662 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
olcf/olcf-test-harness#278 · 1 comment ·