Commit msg not re-read after edit (using run-hook)
See original GitHub issueSetup: gitlint as a commit-msg hook (installed using the install-hook command)
Repo steps:
- A commit msg violating the configured linting rules is used (e.g. git commit -m “This fails linting”)
- gitlint will report the problem(s) and ask the (y)es/(n)o/(e)dit question.
- edit is chosen, and the message is re-written in the editor (vim in my case). New message is know to pass linting.
- gitlint will report the same problem(s) as in step 2
Looking at the code, I think the problem is that the message file loaded (via --msg-filename) is kept open (reading position is reset to zero). It is not closed and re-opened after the edit. My guess is that on Linux, the editor will re-write the file (causing it to get a new inode) while gitlint (via Click) keeps a handle to the old file (old inode). Because the file reading position is just set to zero, the contents of the old file will get re-read after the edit is completed. (On Windows, this will most likely work because of different file system behavior).
The above behavior on Linux makes the current commit-msg hook implementation non-functional as the user will never be able to fix a linting error using the editor option.
I have reverted to the old (v. 0.10.0) hook implementation (which works fine for 0.15.0 also) as a work-around.
Otherwise: Thanks for a nice tool!
Br Lars Marqvart
Top output from gitlint --debug:
DEBUG: gitlint.cli To report issues, please visit https://github.com/jorisroovers/gitlint/issues
DEBUG: gitlint.cli Platform: Linux-5.4.0-65-generic-x86_64-with-glibc2.29
DEBUG: gitlint.cli Python version: 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
DEBUG: gitlint.git ('--version',)
DEBUG: gitlint.cli Git version: git version 2.25.1
DEBUG: gitlint.cli Gitlint version: 0.15.0
DEBUG: gitlint.cli GITLINT_USE_SH_LIB: [NOT SET]
DEBUG: gitlint.cli DEFAULT_ENCODING: UTF-8
DEBUG: gitlint.cli Configuration
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
It was consistent then, I kept editing to see if I’d missed whitespace. I haven’t seen it since but I think that’s because I haven’t left a trailing whitespace in again. It’s my work-provided laptop it was happening on. I’ll double check today and provide debugging info if I can repro
Would love to have this working. I have it consistently under different Linux (Ubuntu, Manjaro) Systems.