Skip to content

Commit

Permalink
Merge pull request #750 from pre-commit/try_repo_files_norm
Browse files Browse the repository at this point in the history
Apply relative files to try-repo also
  • Loading branch information
asottile committed May 12, 2018
2 parents 823c5bc + cd8179a commit 1b67b03
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pre_commit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,21 @@ def main(argv=None):
)
help.add_argument('help_cmd', nargs='?', help='Command to show help for.')

# Argparse doesn't really provide a way to use a `default` subparser
# argparse doesn't really provide a way to use a `default` subparser
if len(argv) == 0:
argv = ['run']
args = parser.parse_args(argv)
if args.command == 'run':

if args.command == 'help' and args.help_cmd:
parser.parse_args([args.help_cmd, '--help'])
elif args.command == 'help':
parser.parse_args(['--help'])
elif args.command in {'run', 'try-repo'}:
args.files = [
os.path.relpath(os.path.abspath(filename), git.get_root())
for filename in args.files
]

if args.command == 'help':
if args.help_cmd:
parser.parse_args([args.help_cmd, '--help'])
else:
parser.parse_args(['--help'])

with error_handler():
add_logging_handler(args.color)
runner = Runner.create(args.config)
Expand Down

0 comments on commit 1b67b03

Please sign in to comment.