-
Notifications
You must be signed in to change notification settings - Fork 100
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
Line-length-rules don't work correctly with german umlauts #310
Comments
AFAIK, that’s only the case in Python 2, not python 3. See below: $ python
Python 3.10.2 (main, Feb 13 2022, 14:37:03) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> len("123456789012345678901234567890123456789012345678901234567890123456789012")
72
>>> len("12345678901234567890123456789012345678901234567890123456789012345678901ä")
72
$ python2
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len("123456789012345678901234567890123456789012345678901234567890123456789012")
72
>>> len("12345678901234567890123456789012345678901234567890123456789012345678901ä")
73 I double checked this with git and gitlint, just to check nothing else is going on and I can’t reproduce this. $ git log -1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
commit d42be31a32c1c60b517d06b11dc70b4af2a07dee (HEAD -> master) ┃
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Author: gïtlint-test-user <gitlint@test.com>
Date: Mon Aug 1 09:18:51 2022 +0200
12345678901234567890123456789012345678901234567890123456789012345678901ä
$ gitlint -c T1.line-length=50
1: T1 Title exceeds max length (72>50): "12345678901234567890123456789012345678901234567890123456789012345678901ä"
3: B6 Body message is missing Can you provide a reproducible example? Thanks! |
We have added gitlint as hook via |
This might be clue! Gitlint has known issues with unicode on Windows; it's complicated (see #96). For debugging, can you set your [title-max-length]
line-length=5 Please then rerun your test, but set GITLINT_DEBUG=1 Please paste all the hook output here after committing. Thanks! |
If it can't be fixed, I can live with that. Gitlint is a great tool for improving our commit messages with umlaut-support and without. From my understanding Gitlint uses gits COMMIT_EDITMSG-file to analyse the message. I have opened this file in Notepad++ and it counts the same way as Gitlint. Umlauts are counted as two characters in Notepad++ too. I get this output:
|
Ok, thanks for the debug output. The fact that Notepad++ is giving the same result seems to indicate "it's complicated" and not just a gitlint specific issue. I will keep this open but likely won't immediately work on this given I've tried (and failed) to fix Unicode on Windows multiple times. It also involves working in a virtual windows environment (I'm not a daily windows user), which is a bit tedious in terms of workflow for me. Thanks for the bug report! |
I had a chance to look at the sourcecode the last days myself and i think i found the issue - at least for windows. |
Great find! Give me some time to try this out and get back to you, probably next week. |
This fixes encoding issues which occur more commonly when invoking the commit-msg hook on Windows. Fixes #310
Ok, I just pushed a variation of this suggested fix to https://github.com/jorisroovers/gitlint/tree/issue-310-umlauts-windows. My fix uses You can try this out using:
I'll try this out myself on Windows before merging the branch. |
This fixes encoding issues which occur more commonly when invoking the commit-msg hook on Windows. Fixes #310
Manually verified on Windows, merged the fix. Will go out with 0.18.0, whenever that is :) Thanks for the bug report! |
No longer used for development purposes by maintainer, is only adding maintenance overhead at this point. Fixes #310
No longer used for development purposes by maintainer, is only adding maintenance overhead at this point. Fixes #310
- Python 3.11 support - Last release to support Python 3.6 - Behavior Change: In a future release, gitlint will be switching to use `re.search` instead of `re.match` semantics for all rules. (#254) - gitlint no longer uses the `sh` library by default in an attempt to reduce external dependencies. - `--commits` now also accepts a comma-separated list of commit hashes, making it possible to lint a list of non-contiguous commits without invoking gitlint multiple times (#283) - Improved handling of branches that have no commits (#188) - Support for `GITLINT_CONFIG` env variable (#189) - Added a new `gitlint-ci` pre-commit hook, making it easier to run gitlint through pre-commit in CI (#191) - Contrib Rules: - New `contrib-disallow-cleanup-commits` rule (#312) - New `contrib-allowed-authors` rule (#358) - User Defined rules: - Gitlint now recognizes `fixup=amend` commits, available as `commit.is_fixup_amend_commit=True` - Gitlint now parses diff **stat** information, available in `commit.changed_files_stats` (#314) - Bugfixes: - Use correct encoding when using `--msg-filename` parameter (#310) - Various documentation fixes (#244) (#263) (#266) (#294) (#295) (#347) (#364) - Under-the-hood: - Dependencies updated - Moved to blacked for formatting - Fixed nasty CI issue (#298) - Unit tests fix (#256) - Vagrant box removed in favor of github dev containers (#348) - Removed a few lingering references to the `master` branch in favor of `main` - Moved roadmap and project planning to github projects Full Release details in CHANGELOG.md.
We have configured the length-rules for title and body and all of them seem to count german umlauts as two characters. I suppose this is an issue of the python len-function which uses the byte-length of a string.
We are currently using python 3.10.4 and gitlint 0.17.0.
Example:
123456789012345678901234567890123456789012345678901234567890123456789012 -> evaluates as 72 characters
12345678901234567890123456789012345678901234567890123456789012345678901ä -> evaluates as 73 characters
The text was updated successfully, but these errors were encountered: