MCPcopy
hub / github.com/pre-commit/pre-commit / _run_single_hook

Function _run_single_hook

pre_commit/commands/run.py:142–235  ·  view source on GitHub ↗
(
        classifier: Classifier,
        hook: Hook,
        skips: set[str],
        cols: int,
        diff_before: bytes,
        verbose: bool,
        use_color: bool,
)

Source from the content-addressed store, hash-verified

140
141
142def _run_single_hook(
143 classifier: Classifier,
144 hook: Hook,
145 skips: set[str],
146 cols: int,
147 diff_before: bytes,
148 verbose: bool,
149 use_color: bool,
150) -> tuple[bool, bytes]:
151 filenames = tuple(classifier.filenames_for_hook(hook))
152
153 if hook.id in skips or hook.alias in skips:
154 output.write(
155 _full_msg(
156 start=hook.name,
157 end_msg=SKIPPED,
158 end_color=color.YELLOW,
159 use_color=use_color,
160 cols=cols,
161 ),
162 )
163 duration = None
164 retcode = 0
165 diff_after = diff_before
166 files_modified = False
167 out = b''
168 elif not filenames and not hook.always_run:
169 output.write(
170 _full_msg(
171 start=hook.name,
172 postfix=NO_FILES,
173 end_msg=SKIPPED,
174 end_color=color.TURQUOISE,
175 use_color=use_color,
176 cols=cols,
177 ),
178 )
179 duration = None
180 retcode = 0
181 diff_after = diff_before
182 files_modified = False
183 out = b''
184 else:
185 # print hook and dots first in case the hook takes a while to run
186 output.write(_start_msg(start=hook.name, end_len=6, cols=cols))
187
188 if not hook.pass_filenames:
189 filenames = ()
190 time_before = time.monotonic()
191 language = languages[hook.language]
192 with language.in_env(hook.prefix, hook.language_version):
193 retcode, out = language.run_hook(
194 hook.prefix,
195 hook.entry,
196 hook.args,
197 filenames,
198 is_local=hook.src == 'local',
199 require_serial=hook.require_serial,

Callers 1

_run_hooksFunction · 0.85

Calls 7

_full_msgFunction · 0.85
_start_msgFunction · 0.85
_get_diffFunction · 0.85
_subtle_lineFunction · 0.85
filenames_for_hookMethod · 0.80
in_envMethod · 0.80
run_hookMethod · 0.80

Tested by

no test coverage detected