From c7ba14e8ef9c62fc056922d70020e4814b66e668 Mon Sep 17 00:00:00 2001 From: Iulian Onofrei Date: Tue, 9 Jan 2018 16:47:22 +0200 Subject: [PATCH 1/2] Simplify config loading code --- pre_commit/clientlib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pre_commit/clientlib.py b/pre_commit/clientlib.py index c94691a5..9af2fcc7 100644 --- a/pre_commit/clientlib.py +++ b/pre_commit/clientlib.py @@ -153,9 +153,9 @@ def ordered_load_normalize_legacy_config(contents): data = ordered_load(contents) if isinstance(data, list): # TODO: Once happy, issue a deprecation warning and instructions - return collections.OrderedDict([('repos', data)]) - else: - return data + data = collections.OrderedDict([('repos', data)]) + + return data load_config = functools.partial( From 20addf4d875d80275c578c5b7e5d419025e78b71 Mon Sep 17 00:00:00 2001 From: Iulian Onofrei Date: Tue, 9 Jan 2018 17:32:10 +0200 Subject: [PATCH 2/2] Add path expand for repo URL --- pre_commit/clientlib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pre_commit/clientlib.py b/pre_commit/clientlib.py index 9af2fcc7..2cf219e8 100644 --- a/pre_commit/clientlib.py +++ b/pre_commit/clientlib.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import argparse import collections import functools +import os from aspy.yaml import ordered_load from identify.identify import ALL_TAGS @@ -155,6 +156,9 @@ def ordered_load_normalize_legacy_config(contents): # TODO: Once happy, issue a deprecation warning and instructions data = collections.OrderedDict([('repos', data)]) + for repo_config in data['repos']: + repo_config['repo'] = os.path.expanduser(repo_config['repo']) + return data