【发布时间】:2018-10-06 14:38:40
【问题描述】:
这是我的pre-commit 钩子
#!/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
我在运行时遇到此错误
› 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
28 的行是
done < "$filename"
【问题讨论】: