-
-
Save bingdian/ca67d7e18d09b76b29ec to your computer and use it in GitHub Desktop.
Revisions
-
xbx revised this gist
Dec 30, 2011 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,8 +67,11 @@ fi JSHINT_BIN=/usr/bin/jshint for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do if test -f ${REPO}/${FILE}; then ${JSHINT_BIN} ${REPO}/${FILE} else continue fi # could similarly wrap Rhino or Node... @@ -83,7 +86,12 @@ done CSSLINT_BIN=/usr/bin/csslint for FILE in `git diff-index --name-only ${against} -- | egrep *.css`; do if test -f ${REPO}/${FILE}; then ${CSSLINT_BIN} ${REPO}/${FILE} else continue fi # could similarly wrap Rhino or Node... -
xbx revised this gist
Dec 30, 2011 . 1 changed file with 20 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ #!/bin/sh # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1 then @@ -46,17 +46,23 @@ fi ## Common EXIT_CODE=0 REPO=$(pwd) # # Checking trailing whitespaces and indent # git diff --cached --check --color=always EXIT_STATUS=$? if [[ $EXIT_STATUS -ne 0 ]]; then EXIT_CODE=$((${EXIT_CODE} + $EXIT_STATUS)) fi # # Begin JsHint hook # A pre-commit hook for git to lint JavaScript files with jshint # @see https://github.com/jshint/jshint/ # JSHINT_BIN=/usr/bin/jshint for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do @@ -68,15 +74,13 @@ for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do EXIT_CODE=$((${EXIT_CODE} + $?)) done # End JsHint hook # # Begin CssLint hook # CSSLINT_BIN=/usr/bin/csslint for FILE in `git diff-index --name-only ${against} -- | egrep *.css`; do ${CSSLINT_BIN} ${REPO}/${FILE} @@ -85,11 +89,15 @@ for FILE in `git diff-index --name-only ${against} -- | egrep *.css`; do EXIT_CODE=$((${EXIT_CODE} + $?)) done # End CssLint hook # # Common # if [[ ${EXIT_CODE} -ne 0 ]]; then echo "" echo "Problems were found" echo "Commit aborted." exit ${EXIT_CODE} fi -
xbx revised this gist
Dec 29, 2011 . 1 changed file with 11 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ #!/bin/sh # # An hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, save it as .git/hooks/pre-commit if git rev-parse --verify HEAD >/dev/null 2>&1 then @@ -45,12 +45,19 @@ fi ## Common EXIT_CODE=0 REPO=$(pwd) git diff --cached --check --color=always EXIT_STATUS=$? ## Checking trailing whitespaces and indent if [[ $EXIT_STATUS -ne 0 ]]; then EXIT_CODE=$((${EXIT_CODE} + $EXIT_STATUS)) fi ## Begin JsHint hook # A pre-commit hook for git to lint JavaScript files with jshint # @see https://github.com/jshint/jshint/ JSHINT_BIN=/usr/bin/jshint for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do @@ -66,7 +73,6 @@ done ## Begin CssLint hook CSSLINT_BIN=/usr/bin/csslint @@ -86,6 +92,4 @@ if [[ ${EXIT_CODE} -ne 0 ]]; then echo "Problems were found" echo "Commit aborted." exit ${EXIT_CODE} fi -
xbx revised this gist
Dec 29, 2011 . 1 changed file with 26 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,29 +43,49 @@ then exit 1 fi ## Common EXIT_CODE=0 ## Begin JsHint hook # A pre-commit hook for git to lint JavaScript files with jshint # @see https://github.com/jshint/jshint/ REPO=$(pwd) JSHINT_BIN=/usr/bin/jshint for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do # with jsc: ${JSHINT_BIN} ${REPO}/${FILE} # could similarly wrap Rhino or Node... EXIT_CODE=$((${EXIT_CODE} + $?)) done ## End JsHint hook ## Begin CssLint hook REPO=$(pwd) CSSLINT_BIN=/usr/bin/csslint ## End CssLint hook for FILE in `git diff-index --name-only ${against} -- | egrep *.css`; do ${CSSLINT_BIN} ${REPO}/${FILE} # could similarly wrap Rhino or Node... EXIT_CODE=$((${EXIT_CODE} + $?)) done ## Common if [[ ${EXIT_CODE} -ne 0 ]]; then echo "" echo "Problems were found" echo "Commit aborted." exit ${EXIT_CODE} fi exec git diff-index --check --cached $against -- -
xbx revised this gist
Dec 29, 2011 . 2 changed files with 71 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ #!/bin/sh # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # If you want to allow non-ascii filenames set this variable to true. allownonascii=$(git config hooks.allownonascii) # Cross platform projects tend to avoid non-ascii filenames; prevent # them from being added to the repository. We exploit the fact that the # printable range starts at the space character and ends with tilde. if [ "$allownonascii" != "true" ] && # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. test "$(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')" then echo "Error: Attempt to add a non-ascii file name." echo echo "This can cause problems if you want to work" echo "with people on other platforms." echo echo "To be portable it is advisable to rename the file ..." echo echo "If you know what you are doing you can disable this" echo "check using:" echo echo " git config hooks.allownonascii true" echo exit 1 fi ## Begin JsHint hook # A pre-commit hook for git to lint JavaScript files with jshint # @see https://github.com/jshint/jshint/ REPO=$(pwd) JSHINT_BIN=/usr/bin/jshint EXIT_CODE=0 for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do # with jsc: ${JSHINT_BIN} ${REPO}/${FILE} # could similarly wrap Rhino or Node... exit $((${EXIT_CODE} + $?)) done if [[ ${EXIT_CODE} -ne 0 ]]; then echo "" echo "JSHint detected syntax problems." echo "Commit aborted." fi ## End JsHint hook exec git diff-index --check --cached $against -- -
founddrama revised this gist
Jun 15, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,7 @@ for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do # with jsc: env/ddc-jsc.sh ${REPO}/${FILE} # could similarly wrap Rhino or Node... EXIT_CODE=$((${EXIT_CODE} + $?)) done -
founddrama revised this gist
Jun 8, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ done if [[ ${EXIT_CODE} -ne 0 ]]; then echo "" echo "JSHint detected syntax problems." echo "Commit aborted." fi -
founddrama revised this gist
Jun 8, 2011 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ #!/bin/sh # A pre-commit hook for git to lint JavaScript files with jshint # @see https://github.com/jshint/jshint/ if git rev-parse --verify HEAD >/dev/null 2>&1 then -
founddrama created this gist
Jun 8, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/bin/sh # A pre-commit hook to lint JS files w/ jshint if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi REPO=$(pwd) JSHINT_HOME=${HOME}/src/jshint EXIT_CODE=0 for FILE in `git diff-index --name-only ${against} -- | egrep *.js`; do cd ${JSHINT_HOME} # with jsc: env/ddc-jsc.sh ${REPO}/${FILE} # with rhino: # env/ddc-rhino.sh ${REPO}/${FILE} EXIT_CODE=$((${EXIT_CODE} + $?)) done if [[ ${EXIT_CODE} -ne 0 ]]; then echo "" echo "JSHint detected syntax problems with ${EXIT_CODE} file(s)." echo "Commit aborted." fi exit $((${EXIT_CODE}))