fix: expand user in the default dir for the store

fixes https://github.com/pre-commit/pre-commit/issues/2189
This commit is contained in:
Tencho Tenev 2022-01-05 21:19:53 +02:00 committed by GitHub
parent cccbc9d280
commit 79727b14bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,10 +31,11 @@ def _get_default_directory() -> str:
`_get_default_directory` can be tested. `_get_default_directory` can be tested.
""" """
ret = os.environ.get('PRE_COMMIT_HOME') or os.path.join( ret = os.environ.get('PRE_COMMIT_HOME') or os.path.join(
os.environ.get('XDG_CACHE_HOME') or os.path.expanduser('~/.cache'), os.environ.get('XDG_CACHE_HOME') or '~/.cache',
'pre-commit', 'pre-commit',
) )
return os.path.realpath(ret)
return os.path.realpath(os.path.expanduser(ret))
class Store: class Store: