-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No exception handling for commit-msg hook (gitlint 0.14.0) #166
Comments
The problem here is:
In other words, gitlint is shelling out to git and |
➜ ~/Development/git-lint git:(main) ✗ git log
fatal: your current branch 'main' does not have any commits yet My repository is empty now. ➜ ~/Development/git-lint git:(main) ✗ git rev-parse --abbrev-ref HEAD
HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]' I deleted ➜ ~/Development/git-lint git:(main) ✗ git commit -am "test 2"
gitlint: checking commit message...
3: B6 Body message is missing
-----------------------------------------------
gitlint: Your commit message contains the above violations.
Continue with commit anyways (this keeps the current commit message)? [y(es)/n(no)/e(dit)] Need fix when the repository is empty. |
Hi, thanks for opening this issue, there's indeed a bug here related to exception handling. If you look at the last line in your error message, you'll see that gitlint already detects the empty repository scenario:
It's just that the exception isn't properly handled. This is because I overlooked the exception handling in the commit-msg hook when porting it to python in the last release (0.14.0). I'm a bit surprised testing didn't catch it 🤷♂️ What needs to happen here, is adding exception handling in the Line 341 in 92c7c4a
Basically identical to what is done here: Lines 241 to 249 in 92c7c4a
You'll notice that if you just run I'll happily accept a PR (note that it needs to include a test case for this particular scenario), or otherwise fix this myself later :-) |
- Gitlint now properly handles exceptions when using the `gitlint run-hook` command (#166) - Added missing test-case for this scenario - Also renamed some test methods in test_cli_hooks.py to better match the existing convention
Fixed on the |
This release drops support for Python 2.7 and Python 3.5 (both are EOL). Other than a few minor fixes, there are no functional differences from the 0.14.0 release. Other call-outs: - Mac users: Gitlint can now be installed using both homebrew (upgraded to latest) and macports. - Bugfix: Gitlint now properly handles exceptions when using its built-in commit-msg hook (#166) - All dependencies have been upgraded to the latest available versions (Click==7.1.2, arrow==0.17.0, sh==1.14.1) - Much under-the-hood refactoring as a result of dropping Python 2.7 Full Release details in CHANGELOG.md.
install gitlint
Error:
The text was updated successfully, but these errors were encountered: