mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Various cleanup.
This commit is contained in:
parent
bf912cfebb
commit
01b557c497
12 changed files with 85 additions and 37 deletions
|
|
@ -29,7 +29,9 @@ logger = logging.getLogger('pre_commit')
|
|||
|
||||
def install(runner):
|
||||
"""Install the pre-commit hooks."""
|
||||
pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
|
||||
pre_commit_file = pkg_resources.resource_filename(
|
||||
'pre_commit', 'resources/pre-commit.sh',
|
||||
)
|
||||
with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:
|
||||
pre_commit_file_obj.write(open(pre_commit_file).read())
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ def is_in_merge_conflict():
|
|||
def parse_merge_msg_for_conflicts(merge_msg):
|
||||
# Conflicted files start with tabs
|
||||
return [
|
||||
line.strip() for line in merge_msg.splitlines() if line.startswith('\t')
|
||||
line.strip()
|
||||
for line in merge_msg.splitlines()
|
||||
if line.startswith('\t')
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,19 @@ from pre_commit.languages import system
|
|||
# # Use None for no environment
|
||||
# ENVIRONMENT_DIR = 'foo_env'
|
||||
#
|
||||
# def install_environment(repo_cmd_runner):
|
||||
# def install_environment(repo_cmd_runner, version='default'):
|
||||
# """Installs a repository in the given repository. Note that the current
|
||||
# working directory will already be inside the repository.
|
||||
#
|
||||
# Args:
|
||||
# repo_cmd_runner - `PrefixedCommandRunner` bound to the repository.
|
||||
# version - A version specified in the hook configuration or
|
||||
# 'default'.
|
||||
# """
|
||||
#
|
||||
# def run_hook(repo_cmd_runner, hook, file_args):
|
||||
# """Runs a hook and returns the returncode and output of running that hook.
|
||||
# """Runs a hook and returns the returncode and output of running that
|
||||
# hook.
|
||||
#
|
||||
# Args:
|
||||
# repo_cmd_runner - `PrefixedCommandRunner` bound to the repository.
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ def get_hook_message(
|
|||
>>> print_hook_message('start', end_len=6)
|
||||
start...............................................................
|
||||
|
||||
# Print `start` followed by dots with the end message colored if coloring is
|
||||
# specified and a newline afterwards
|
||||
# Print `start` followed by dots with the end message colored if coloring
|
||||
# is specified and a newline afterwards
|
||||
>>> print_hook_message(
|
||||
'start',
|
||||
end_msg='end',
|
||||
|
|
|
|||
|
|
@ -42,7 +42,12 @@ class PrefixedCommandRunner(object):
|
|||
|
||||
will run ['/tmp/foo/foo.sh', 'bar', 'baz']
|
||||
"""
|
||||
def __init__(self, prefix_dir, popen=subprocess.Popen, makedirs=os.makedirs):
|
||||
def __init__(
|
||||
self,
|
||||
prefix_dir,
|
||||
popen=subprocess.Popen,
|
||||
makedirs=os.makedirs
|
||||
):
|
||||
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
|
||||
self.__popen = popen
|
||||
self.__makedirs = makedirs
|
||||
|
|
|
|||
|
|
@ -35,9 +35,13 @@ def run(argv):
|
|||
'--no-stash', default=False, action='store_true',
|
||||
help='Use this option to prevent auto stashing of unstaged files.',
|
||||
)
|
||||
run_parser.add_argument('--verbose', '-v', action='store_true', default=False)
|
||||
run_parser.add_argument(
|
||||
'--verbose', '-v', action='store_true', default=False,
|
||||
)
|
||||
|
||||
help = subparsers.add_parser('help', help='Show help for a specific command.')
|
||||
help = subparsers.add_parser(
|
||||
'help', help='Show help for a specific command.'
|
||||
)
|
||||
help.add_argument('help_cmd', nargs='?', help='Command to show help for.')
|
||||
|
||||
# Argparse doesn't really provide a way to use a `default` subparser
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue