File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 8
8
# cp tool/hooks/lint-check.sh .git/hooks/pre-push
9
9
# The choice is yours.
10
10
11
- exec tool/jt.rb lint fast
11
+ filename=$( basename " ${BASH_SOURCE[0]} " )
12
+
13
+ case " $filename " in
14
+ pre-commit) exec tool/jt.rb lint fast HEAD ;;
15
+ post-commit) exec tool/jt.rb lint fast HEAD^ ;;
16
+ pre-push) exec tool/jt.rb lint fast origin/master ;;
17
+ esac
Original file line number Diff line number Diff line change @@ -2386,14 +2386,11 @@ def format_specializations_arguments
2386
2386
2387
2387
def lint ( *args )
2388
2388
fast = args . first == 'fast'
2389
- if fast
2390
- changed_files = `git diff --cached --name-only` # Only staged files in the git index
2391
- if changed_files . empty? # post-commit hook
2392
- changed_files = `git diff --cached --name-only HEAD^`
2393
- end
2394
- raise 'Could not list changed files' if changed_files . empty?
2389
+ args . shift if fast
2390
+
2391
+ if fast and compare_to = args . shift
2392
+ changed_files = `git diff --cached --name-only #{ compare_to } `
2395
2393
exts_changed = changed_files . lines . map { |f | File . extname ( f . strip ) } . uniq
2396
- raise 'Could not list changed file extensions' if exts_changed . empty?
2397
2394
changed = -> ext { exts_changed . include? ( ext ) }
2398
2395
else
2399
2396
changed = -> _ext { true }
You can’t perform that action at this time.
0 commit comments