Last active
August 12, 2016 09:29
Revisions
-
tueda revised this gist
Nov 27, 2013 . 1 changed file with 2 additions 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 @@ -1,9 +1,9 @@ #!/bin/sh # # A (client-side) git hook script which warns if there are too long lines in # the commit message, not fitting with 50/72 formatting. # # To use this script, copy it as .git/hooks/commit-msg and give it an executable # file permission. # FILE=$1 -
tueda revised this gist
Nov 24, 2013 . 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 @@ -1,7 +1,7 @@ #!/bin/sh # # A (client-side) git hook script which warns if there are too long lines in # the commit message. # # To use this script, put it as .git/hooks/commit-msg and give it an executable # file permission. -
tueda created this gist
Nov 24, 2013 .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,63 @@ #!/bin/sh # # A (client-side) git hook script which warns if there are too long lines in # the commit messages. # # To use this script, put it as .git/hooks/commit-msg and give it an executable # file permission. # FILE=$1 msg_lines() { cat "$FILE" \ | sed 's/^#.*//' \ | sed '/./=' \ | sed '/^$/{p;d}; N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /' \ | sed -n '/./,$p' } first_line() { msg_lines | head -1 } second_line() { msg_lines | head -2 | tail -1 } rest_lines() { msg_lines | sed '1,2d' } my_warned=false if first_line | sed -n '/\(.\)\{81\}/p' | grep '.' >/dev/null; then echo '' >&2 echo 'WARNING: The first line should be 72 characters or less.' >&2 first_line >&2 my_warned=true elif first_line | sed -n '/\(.\)\{59\}/p' | grep '.' >/dev/null; then echo '' >&2 echo 'WARNING: The first line is recommended to be 50 characters or less.' >&2 first_line >&2 my_warned=true fi if second_line | grep '.' >/dev/null; then echo '' >&2 echo 'WARNING: The second line should be blank.' >&2 second_line >&2 my_warned=true fi if rest_lines | sed -n '/\(.\)\{81\}/p' | grep '.' >/dev/null; then echo '' >&2 echo 'WARNING: Text should be wrapped at 72 characters.' >&2 rest_lines | sed -n '/\(.\)\{81\}/p' | grep '.' >&2 my_warned=true fi if $my_warned; then echo '' >&2 echo ' use "git commit --amend" etc. to reedit the commit message.' >&2 echo '' >&2 fi