This is my pre-commit
hook
#!/bin/sh
echo "pre-commit started"
filename="$1"
lineno=0
error() {
echo "$1"
exit 1
}
while read -r line
do
[[ "$line" =~ ^#.* ]] && continue
let lineno+=1
length=${#line}
if [[ $lineno -eq 1 ]]; then
[[ $length -gt 50 ]] && error "Limit the subject line to 50 characters"
[[ ! "$line" =~ ^[A-Z].*$ ]] && error "Capitalise the subject line"
[[ "$line" == *. ]] && error "Do not end the subject line with a period"
fi
[[ $lineno -eq 2 ]] && [[ -n $line ]] && error "Separate subject from body with a blank line"
[[ $lineno -gt 1 ]] && [[ $length -gt 72 ]] && error "Wrap the body at 72 characters"
done < "$filename"
exit 0
I am getting this error while running
› git commit -m "sfrewr"
pre-commit started
/Users/me/.git-templates/hooks/pre-commit: line 28: : No such file or directory
[master 6950a43] sfrewr
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 89
And line 28
reads
done < "$filename"