Avoid erroneous developer commits to main branch
Issue Resolves developers forgetting to checkout a new branch before commiting.
Approach
pre-commit
Example of classical developer error that is guarded by this commit:
HAVB@AC-Y72WJR4W4M:~/projects/ert] main$ git commit -am "Avoid erroneous developer commits to main branch"
don't commit to branch...................................................Failed
- hook id: no-commit-to-branch
- exit code: 1
check json...........................................(no files to check)Skipped
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
ruff.................................................(no files to check)Skipped
ruff-format..........................................(no files to check)Skipped
clang-format.........................................(no files to check)Skipped
cmake-format.........................................(no files to check)Skipped
cmake-lint...........................................(no files to check)Skipped
- [x] PR title captures the intent of the changes, and is fitting for release notes.
- [x] Added appropriate release note label
- [x] Commit history is consistent and clean, in line with the contribution guidelines.
- [ ] Make sure tests pass locally (after every commit!)
When applicable
- [ ] When there are user facing changes: Updated documentation
- [ ] New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
- [ ] Large PR: Prepare changes in small commits for more convenient review
- [ ] Bug fix: Add regression test for the bug
- [ ] Bug fix: Create Backport PR to latest release
Don't understand this tbh. What's the issue - is it to avoid force-push?
We should never commit to our local main, we should only ever do git commit when another branch is checked out.
When we commit to local main branch, we need to clean up with git reset --hard origin main.
This PR will make git commit fail unless you have checked out another branch than main
Can we change the commit message to something like
Have pre-commit protect main branch?
Fixed!
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 85.20%. Comparing base (
0e3f9b5) to head (92d655c). Report is 8 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #7585 +/- ##
==========================================
+ Coverage 85.18% 85.20% +0.02%
==========================================
Files 383 383
Lines 23275 23293 +18
Branches 893 879 -14
==========================================
+ Hits 19827 19847 +20
+ Misses 3339 3335 -4
- Partials 109 111 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.