Merge pull request #1813 from pre-commit/fix_without_us_test

fix _path_without_us under test when path segment ends in slash
This commit is contained in:
Anthony Sottile 2021-02-23 18:54:13 -08:00 committed by GitHub
commit 616249e680
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -259,7 +259,10 @@ def _path_without_us():
exe = find_executable('pre-commit', _environ=env)
while exe:
parts = env['PATH'].split(os.pathsep)
after = [x for x in parts if x.lower() != os.path.dirname(exe).lower()]
after = [
x for x in parts
if x.lower().rstrip(os.sep) != os.path.dirname(exe).lower()
]
if parts == after:
raise AssertionError(exe, parts)
env['PATH'] = os.pathsep.join(after)