The staging wrapper works beautifully.

This commit is contained in:
Elf M. Sternberg 2016-09-26 15:26:04 -07:00
parent c4200eb3a4
commit bacbdd7179
2 changed files with 18 additions and 7 deletions

View File

@ -2,7 +2,12 @@
History History
======= =======
0.0.2 (2016-09-13) 0.0.2 (2015-05-22)
------------------ ------------------
* First release on PyPI. Pre-commit version
0.0.04 (2016-09-26)
-------------------
Moved to "git lint" and optioned the hell out of it.

View File

@ -459,12 +459,12 @@ def pick_stash_runner(cmdline):
constantly monitoring file times. constantly monitoring file times.
""" """
def staging_wrapper(run_linters): def staging_wrapper(run_linters, filenames):
def time_gather(f): def time_gather(f):
stats = os.stat(f) stats = os.stat(f)
return (f, (stats.atime, stats.mtime)) return (f, (stats.st_atime, stats.st_mtime))
times = [time_gather(file) for file in files] times = [time_gather(file) for file in filenames]
run_git_command(['stash', '--keep-index']) run_git_command(['stash', '--keep-index'])
results = run_linters() results = run_linters()
@ -475,7 +475,7 @@ def pick_stash_runner(cmdline):
os.utime(filename, timepair) os.utime(filename, timepair)
return results return results
def workspace_wrapper(run_linters): def workspace_wrapper(run_linters, filenames):
return run_linters() return run_linters()
return ('staging' in cmdline and staging_wrapper) or workspace_wrapper return ('staging' in cmdline and staging_wrapper) or workspace_wrapper
@ -579,12 +579,18 @@ def run_gitlint(cmdline, config, extras):
cant_lint_filenames = [filename for filename in lintable_filenames cant_lint_filenames = [filename for filename in lintable_filenames
if cant_lint_filter(filename)] if cant_lint_filter(filename)]
if 'dryrun' in cmdline:
return dryrun(
build_config_subset(working_linter_names), sorted(lintable_filenames))
lint_runner = build_lint_runner( lint_runner = build_lint_runner(
build_config_subset(working_linter_names), sorted(lintable_filenames)) build_config_subset(working_linter_names), sorted(lintable_filenames))
results = stash_runner(lint_runner) results = stash_runner(lint_runner, lintable_filenames)
print_report(results, cmdline) print_report(results, cmdline)
if not len(results):
return 0
return max([i[2] for i in results if len(i)]) return max([i[2] for i in results if len(i)])