@@ -22,10 +22,9 @@ def md5(s): # pragma: windows no cover
2222 return hashlib .md5 (five .to_bytes (s )).hexdigest ()
2323
2424
25- def docker_tag (repo_cmd_runner ): # pragma: windows no cover
26- return 'pre-commit-{}' .format (
27- md5 (os .path .basename (repo_cmd_runner .path ())),
28- ).lower ()
25+ def docker_tag (prefix ): # pragma: windows no cover
26+ md5sum = md5 (os .path .basename (prefix .prefix_dir )).lower ()
27+ return 'pre-commit-{}' .format (md5sum )
2928
3029
3130def docker_is_running (): # pragma: windows no cover
@@ -41,39 +40,36 @@ def assert_docker_available(): # pragma: windows no cover
4140 )
4241
4342
44- def build_docker_image (repo_cmd_runner , ** kwargs ): # pragma: windows no cover
43+ def build_docker_image (prefix , ** kwargs ): # pragma: windows no cover
4544 pull = kwargs .pop ('pull' )
4645 assert not kwargs , kwargs
4746 cmd = (
4847 'docker' , 'build' ,
49- '--tag' , docker_tag (repo_cmd_runner ),
48+ '--tag' , docker_tag (prefix ),
5049 '--label' , PRE_COMMIT_LABEL ,
5150 )
5251 if pull :
5352 cmd += ('--pull' ,)
5453 # This must come last for old versions of docker. See #477
5554 cmd += ('.' ,)
56- helpers .run_setup_cmd (repo_cmd_runner , cmd )
55+ helpers .run_setup_cmd (prefix , cmd )
5756
5857
5958def install_environment (
60- repo_cmd_runner , version , additional_dependencies ,
59+ prefix , version , additional_dependencies ,
6160): # pragma: windows no cover
62- assert repo_cmd_runner .exists ('Dockerfile' ), (
63- 'No Dockerfile was found in the hook repository'
64- )
6561 helpers .assert_version_default ('docker' , version )
6662 helpers .assert_no_additional_deps ('docker' , additional_dependencies )
6763 assert_docker_available ()
6864
69- directory = repo_cmd_runner .path (
65+ directory = prefix .path (
7066 helpers .environment_dir (ENVIRONMENT_DIR , 'default' ),
7167 )
7268
7369 # Docker doesn't really have relevant disk environment, but pre-commit
7470 # still needs to cleanup it's state files on failure
7571 with clean_path_on_failure (directory ):
76- build_docker_image (repo_cmd_runner , pull = True )
72+ build_docker_image (prefix , pull = True )
7773 os .mkdir (directory )
7874
7975
@@ -90,15 +86,15 @@ def docker_cmd():
9086 )
9187
9288
93- def run_hook (repo_cmd_runner , hook , file_args ): # pragma: windows no cover
89+ def run_hook (prefix , hook , file_args ): # pragma: windows no cover
9490 assert_docker_available ()
9591 # Rebuild the docker image in case it has gone missing, as many people do
9692 # automated cleanup of docker images.
97- build_docker_image (repo_cmd_runner , pull = False )
93+ build_docker_image (prefix , pull = False )
9894
9995 hook_cmd = helpers .to_cmd (hook )
10096 entry_exe , cmd_rest = hook_cmd [0 ], hook_cmd [1 :]
10197
102- entry_tag = ('--entrypoint' , entry_exe , docker_tag (repo_cmd_runner ))
98+ entry_tag = ('--entrypoint' , entry_exe , docker_tag (prefix ))
10399 cmd = docker_cmd () + entry_tag + cmd_rest
104100 return xargs (cmd , file_args )
0 commit comments