88from pre_commit .util import cached_property
99
1010
11+ def install_python (repo ):
12+ assert local .path ('setup.py' ).exists ()
13+ local ['virtualenv' ]['py_env' ]()
14+ local ['bash' ]['-c' , 'source py_env/bin/activate && pip install .' ]()
15+
16+
17+ def install_ruby (repo ):
18+ raise NotImplementedError
19+
20+
21+ def install_node (repo ):
22+ raise NotImplementedError
23+
24+
25+ language_to_repo_setup_strategy = {
26+ 'python' : install_python ,
27+ 'ruby' : install_ruby ,
28+ 'node' : install_node ,
29+ }
30+
31+
1132class Repository (object ):
1233 def __init__ (self , repo_config ):
1334 self .repo_config = repo_config
@@ -59,25 +80,8 @@ def create(self):
5980 with self .in_checkout ():
6081 local ['git' ]['checkout' , self .sha ]()
6182
62- # TODO: make this shit polymorphic
63-
64- def _install_python (self ):
65- assert local .path ('setup.py' ).exists ()
66- local ['virtualenv' ]['py_env' ]()
67- local ['bash' ]['-c' , 'source py_env/bin/activate && pip install .' ]()
68-
69- def _install_ruby (self ):
70- raise NotImplementedError
71-
72- def _install_node (self ):
73- raise NotImplementedError
74-
7583 def install (self ):
76- # Create if we have not already
77- self .create ()
78- # TODO: need to take in the config here and determine if we actually
79- # need to run any installers (and what languages to install)
8084 with self .in_checkout ():
81- if local . path ( 'setup.py' ). exists () :
82- local [ 'virtualenv' ][ 'py_env' ]()
83- local [ 'bash' ][ '-c' , 'source py_env/bin/activate && pip install .' ]( )
85+ for language in C . SUPPORTED_LANGUAGES :
86+ if language in self . languages :
87+ language_to_repo_setup_strategy [ language ]( self )
0 commit comments