Skip to content

Commit cd8179a

Browse files
committed
Apply relative files to try-repo also
1 parent 823c5bc commit cd8179a

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

pre_commit/main.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,21 @@ def main(argv=None):
212212
)
213213
help.add_argument('help_cmd', nargs='?', help='Command to show help for.')
214214

215-
# Argparse doesn't really provide a way to use a `default` subparser
215+
# argparse doesn't really provide a way to use a `default` subparser
216216
if len(argv) == 0:
217217
argv = ['run']
218218
args = parser.parse_args(argv)
219-
if args.command == 'run':
219+
220+
if args.command == 'help' and args.help_cmd:
221+
parser.parse_args([args.help_cmd, '--help'])
222+
elif args.command == 'help':
223+
parser.parse_args(['--help'])
224+
elif args.command in {'run', 'try-repo'}:
220225
args.files = [
221226
os.path.relpath(os.path.abspath(filename), git.get_root())
222227
for filename in args.files
223228
]
224229

225-
if args.command == 'help':
226-
if args.help_cmd:
227-
parser.parse_args([args.help_cmd, '--help'])
228-
else:
229-
parser.parse_args(['--help'])
230-
231230
with error_handler():
232231
add_logging_handler(args.color)
233232
runner = Runner.create(args.config)

0 commit comments

Comments
 (0)