mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Hashlib doesn't take unicode.
This commit is contained in:
parent
a34f3fc7c9
commit
5d1ffcba75
3 changed files with 14 additions and 11 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
|
|
@ -11,6 +10,7 @@ from plumbum import local
|
|||
|
||||
from pre_commit.prefixed_command_runner import PrefixedCommandRunner
|
||||
from pre_commit.util import clean_path_on_failure
|
||||
from pre_commit.util import hex_md5
|
||||
|
||||
|
||||
logger = logging.getLogger('pre_commit')
|
||||
|
|
@ -75,9 +75,7 @@ class Store(object):
|
|||
self.require_created()
|
||||
|
||||
# Check if we already exist
|
||||
sha_path = os.path.join(
|
||||
self.directory, sha + '_' + hashlib.md5(url).hexdigest()
|
||||
)
|
||||
sha_path = os.path.join(self.directory, sha + '_' + hex_md5(url))
|
||||
if os.path.exists(sha_path):
|
||||
return os.readlink(sha_path)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import contextlib
|
||||
import functools
|
||||
import hashlib
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
|
|
@ -56,3 +57,11 @@ def noop_context():
|
|||
|
||||
def shell_escape(arg):
|
||||
return "'" + arg.replace("'", "'\"'\"'".strip()) + "'"
|
||||
|
||||
|
||||
def hex_md5(s):
|
||||
"""Hexdigest an md5 of the string.
|
||||
|
||||
:param text s:
|
||||
"""
|
||||
return hashlib.md5(s.encode('utf-8')).hexdigest()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue