MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / _adjust_args_and_chdir

Function _adjust_args_and_chdir

pre_commit/main.py:175–199  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

173
174
175def _adjust_args_and_chdir(args: argparse.Namespace) -> None:
176 # `--config` was specified relative to the non-root working directory
177 if os.path.exists(args.config):
178 args.config = os.path.abspath(args.config)
179 if args.command in {'run', 'try-repo'}:
180 args.files = [os.path.abspath(filename) for filename in args.files]
181 if args.commit_msg_filename is not None:
182 args.commit_msg_filename = os.path.abspath(
183 args.commit_msg_filename,
184 )
185 if args.command == 'try-repo' and os.path.exists(args.repo):
186 args.repo = os.path.abspath(args.repo)
187
188 toplevel = git.get_root()
189 os.chdir(toplevel)
190
191 args.config = os.path.relpath(args.config)
192 if args.command in {'run', 'try-repo'}:
193 args.files = [os.path.relpath(filename) for filename in args.files]
194 if args.commit_msg_filename is not None:
195 args.commit_msg_filename = os.path.relpath(
196 args.commit_msg_filename,
197 )
198 if args.command == 'try-repo' and os.path.exists(args.repo):
199 args.repo = os.path.relpath(args.repo)
200
201
202def main(argv: Sequence[str] | None = None) -> int:

Callers 1

mainFunction · 0.85

Calls 1

existsMethod · 0.80

Tested by

no test coverage detected