@@ -101,8 +101,9 @@ def commit_changed_files(
101101 commit = confirm ("Commit?" , default = True )
102102
103103 if commit :
104- # Ensure the working directory for pre-commit is correct
105- r .hooks ["pre-commit" ].cwd = str (repo_path .absolute ()) # type: ignore
104+ if enable_pre_commit or "pre-commit" in r .hooks :
105+ # Ensure the working directory for pre-commit is correct
106+ r .hooks ["pre-commit" ].cwd = str (repo_path .absolute ()) # type: ignore
106107
107108 try :
108109 commit_id = commit_changes (r , message .decode ("UTF-8" ))
@@ -125,6 +126,7 @@ def run_repo_helper(
125126 initialise : bool ,
126127 commit : Optional [bool ],
127128 message : str ,
129+ enable_pre_commit : bool = True ,
128130 ) -> int :
129131 """
130132 Run repo_helper.
@@ -134,6 +136,7 @@ def run_repo_helper(
134136 :param initialise: Whether to initialise the repository.
135137 :param commit: Whether to commit unchanged files.
136138 :param message: The commit message.
139+ :param enable_pre_commit: Whether to install and configure pre-commit. Default :py:obj`True`.
137140 """
138141
139142 # this package
@@ -166,6 +169,7 @@ def run_repo_helper(
166169 managed_files = managed_files ,
167170 commit = commit ,
168171 message = message .encode ("UTF-8" ),
172+ enable_pre_commit = enable_pre_commit ,
169173 )
170174 except CommitError as e :
171175 indented_error = '\n ' .join (f"\t { line } " for line in textwrap .wrap (str (e )))
0 commit comments