Skip to content

Commit 117df52

Browse files
authored
Merge pull request #7 from tommarshall/6-fix-imperative-mood-false-positives
Fix imperative mood false positives
2 parents 0952e5b + cbf012d commit 117df52

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Offers an interactive prompt if any of the rules are detected to be broken.
2727
At the root of the repository, run:
2828

2929
```sh
30-
curl https://cdn.rawgit.com/tommarshall/git-good-commit/v0.4.0/hook.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
30+
curl https://cdn.rawgit.com/tommarshall/git-good-commit/v0.5.0/hook.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
3131
```
3232

3333
### Globally
@@ -37,14 +37,14 @@ To use the hook globally, you can use `git-init`'s template directory:
3737
```sh
3838
mkdir -p ~/.git-template/hooks
3939
git config --global init.templatedir '~/.git-template'
40-
curl https://cdn.rawgit.com/tommarshall/git-good-commit/v0.4.0/hook.sh > ~/.git-template/hooks/commit-msg && chmod +x ~/.git-template/hooks/commit-msg
40+
curl https://cdn.rawgit.com/tommarshall/git-good-commit/v0.5.0/hook.sh > ~/.git-template/hooks/commit-msg && chmod +x ~/.git-template/hooks/commit-msg
4141
```
4242

4343
The hook will now be present after any `git init` or `git clone`. You can [safely re-run `git init`](http://stackoverflow.com/a/5149861/885540) on any existing repositories to add the hook there.
4444

4545
---
4646

47-
_If you're security conscious, you may be reasonably suspicious of [curling executable files](https://www.seancassidy.me/dont-pipe-to-your-shell.html). In this case you're on HTTPS throughout, and not piping directly to execution, so you can check contents and the hash against MD5 `1bbe22e756fe98dbcc8aae390e20367d` for v0.4.0._
47+
_If you're security conscious, you may be reasonably suspicious of [curling executable files](https://www.seancassidy.me/dont-pipe-to-your-shell.html). In this case you're on HTTPS throughout, and not piping directly to execution, so you can check contents and the hash against MD5 `32345e70572846c29f3a767c3dce492f` for v0.5.0._
4848

4949
## Usage
5050

hook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# git-good-commit(1) - Git hook to help you write good commit messages.
55
# Released under the MIT License.
66
#
7-
# Version 0.4.0
7+
# Version 0.5.0
88
#
99
# https://github.com/tommarshall/git-good-commit
1010
#
@@ -180,7 +180,7 @@ validate_commit_message() {
180180
shopt -s nocasematch
181181

182182
for BLACKLISTED_WORD in "${IMPERATIVE_MOOD_BLACKLIST[@]}"; do
183-
[[ ${COMMIT_SUBJECT} =~ $BLACKLISTED_WORD ]]
183+
[[ ${COMMIT_SUBJECT} =~ ^[[:blank:]]*$BLACKLISTED_WORD ]]
184184
test $? -eq 0 && add_warning 1 "Use the imperative mood in the subject line, e.g 'fix' not 'fixes'" && break
185185
done
186186

test/validation.bats

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,38 @@ EOF
172172
# 5. Use the imperative mood in the subject line
173173
# ------------------------------------------------------------------------------
174174

175-
@test "validation: subject line with 'fixes' shows warning" {
175+
@test "validation: subject line starting with 'fixes' shows warning" {
176176
echo "n" > $FAKE_TTY
177-
run git commit -m "More fixes for broken stuff"
177+
run git commit -m "Fixes for broken stuff"
178178

179179
assert_failure
180180
assert_line --partial "Use the imperative mood in the subject line"
181181
}
182182

183-
@test "validation: subject line with 'fixed' shows warning" {
183+
@test "validation: subject line starting with 'fixed' shows warning" {
184184
echo "n" > $FAKE_TTY
185185
run git commit -m "Fixed bug with Y"
186186

187187
assert_failure
188188
assert_line --partial "Use the imperative mood in the subject line"
189189
}
190190

191-
@test "validation: subject line with 'fixing' shows warning" {
191+
@test "validation: subject line starting with 'fixing' shows warning" {
192192
echo "n" > $FAKE_TTY
193193
run git commit -m "Fixing behavior of X"
194194

195195
assert_failure
196196
assert_line --partial "Use the imperative mood in the subject line"
197197
}
198198

199+
@test "validation: subject line in imperative mood with 'fixes' does not show warning" {
200+
echo "n" > $FAKE_TTY
201+
run git commit -m "Remove the temporary fixes to Y"
202+
203+
assert_success
204+
refute_line --partial "Use the imperative mood in the subject line"
205+
}
206+
199207
@test "validation: body with 'fixes', 'fixed', 'fixing' does not show warning" {
200208
run git commit -m "$(cat <<EOF
201209
Add foo bar string to my_file

0 commit comments

Comments
 (0)