Skip to content

Commit

Permalink
The staging wrapper works beautifully.
Browse files Browse the repository at this point in the history
  • Loading branch information
elfsternberg committed Sep 26, 2016
1 parent c4200eb commit bacbdd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
9 changes: 7 additions & 2 deletions HISTORY.rst
Expand Up @@ -2,7 +2,12 @@
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.
16 changes: 11 additions & 5 deletions git_lint/git_lint.py
Expand Up @@ -459,12 +459,12 @@ def pick_stash_runner(cmdline):
constantly monitoring file times.
"""

def staging_wrapper(run_linters):
def staging_wrapper(run_linters, filenames):
def time_gather(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'])

results = run_linters()
Expand All @@ -475,7 +475,7 @@ def time_gather(f):
os.utime(filename, timepair)
return results

def workspace_wrapper(run_linters):
def workspace_wrapper(run_linters, filenames):
return run_linters()

return ('staging' in cmdline and staging_wrapper) or workspace_wrapper
Expand Down Expand Up @@ -579,12 +579,18 @@ def build_config_subset(keys):
cant_lint_filenames = [filename for filename in lintable_filenames
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(
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)
if not len(results):
return 0
return max([i[2] for i in results if len(i)])


Expand Down

0 comments on commit bacbdd7

Please sign in to comment.