Browse Source

Added make lint-changed which lints changed files only.

Ruben Vereecken 10 years ago
parent
commit
4b44492314
3 changed files with 13 additions and 2 deletions
  1. 6 2
      Makefile
  2. 6 0
      scripts/lint-changed.sh
  3. 1 0
      scripts/pre-commit

+ 6 - 2
Makefile

@@ -7,8 +7,12 @@ setup:
 	@chmod +x .git/hooks/pre-commit
 	@echo "Git pre-commit hook installed."
 	
-	@gem install mdl --install-dir .gem
+	@gem install mdl --install-dir .gem --no-rdoc --no-ri
 	@echo "Installed required Ruby gems under .gem"
 	
 lint: 
-	@GEM_PATH=.gem PATH=$(PATH):.gem/bin find pages -exec mdl {} --style ./scripts/markdown-style.rb 1>&2 \;
+	@GEM_PATH=.gem find pages -exec .gem/bin/mdl {} --style ./scripts/markdown-style.rb 1>&2 \;
+	
+lint-changed:
+	@./scripts/lint-changed.sh
+	

+ 6 - 0
scripts/lint-changed.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+MD_FILES=`git diff --cached --name-only | tr " " "\n" | egrep ^.*\.md$`
+
+# Execute Markdown lint if any markdown files have been changed and added to git
+[[ -z "$MD_FILES" ]] || GEM_PATH=.gem .gem/bin/mdl "$MD_FILES"

+ 1 - 0
scripts/pre-commit

@@ -2,3 +2,4 @@
 
 make index
 git add ./pages/index.json
+make lint-changed