Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git钩子拼写检查器忽略缩进行_Git_Hook_Ignore_Aspell - Fatal编程技术网

Git钩子拼写检查器忽略缩进行

Git钩子拼写检查器忽略缩进行,git,hook,ignore,aspell,Git,Hook,Ignore,Aspell,我正在编写一个git钩子,用于拼写检查我的提交消息。这就是我到目前为止所做的: #!/bin/sh ASPELL=$(which aspell) WORDS=$($ASPELL list < "$1") if [ -n "$WORDS" ]; then echo -e "Possible spelling errors found in commit message. Consider using git commit --amend to change the messag

我正在编写一个git钩子,用于拼写检查我的提交消息。这就是我到目前为止所做的:

#!/bin/sh

ASPELL=$(which aspell)

WORDS=$($ASPELL list < "$1")

if [ -n "$WORDS" ]; then
    echo -e "Possible spelling errors found in commit message. Consider using git commit --amend to change the message.\n\tPossible mispelled words: " $WORDS
fi
#/垃圾箱/垃圾箱
ASPELL=$(哪个ASPELL)
单词=$($ASPELL列表<“$1”)
如果[-n“$WORDS”];然后
E-E“在提交消息中发现可能的拼写错误。考虑使用Git提交-修改来更改消息。\n可能错译的单词:”$Word
fi
我不知道如何告诉aspell我想忽略缩进的行(两个或更多空格)。这将避免有关文件名、注释等的恼人消息


谢谢大家!

您是否有机会参加EECS 398

只是给你一个提示而不违反荣誉准则


将提交消息放入文本文件中。使用文本编辑器从文本文件中删除缩进行。然后将文本文件放到aspell上。

如果其他人遇到此问题,并且不在原始海报所说的任何大学课堂上,下面是我解决问题的方法:

#/bin/bash
ASPELL=$(哪个ASPELL)
如果[$?-ne 0];然后
echo“Aspell未安装-无法检查拼写”>&2
出口
其他的
WORDS=$($ASPELL--mode=email--add email quote='#'列表<“$1”)
fi
如果[-n“$WORDS”];然后
printf“\e[1;在提交消息中发现33m个可能的拼写错误。\n可能的拼写错误:\n\e[0m\e[0;31m%s\n\e[0m\e[1;33m使用git提交--修改以更改消息。\e[0m\n\n”“$words”>&2
fi
关键部分是
--mode=email--addemail quote='#'
参数,当我们实际调用
aspell

--mode
设置模式,在本例中,我们将其设置为
电子邮件
模式。其描述如下:

电子邮件
过滤模式跳过带引号的文本。
添加| rem电子邮件引号
选项控制被视为引号字符的字符,默认值为“
”和“

因此,如果我们将“
#
”添加到“quote”字符列表中,
aspell
将跳过它。当然,我们可以使用
--addemail quote
选项来实现这一点

请注意,根据文档,我们还跳过了“
”和“
|
”。如果您不希望
aspell
跳过这些,请使用
--rem email quote
选项

有关更多信息,请参阅