Skip to content

Commit f000e67

Browse files
authored
Merge pull request #2 from tommarshall/ignore-trailing-whitespace
Ignore trailing whitespace
2 parents 070b263 + d31b39a commit f000e67

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
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.1.0/hook.sh > .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
30+
curl https://cdn.rawgit.com/tommarshall/git-good-commit/v0.2.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.1.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.2.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 `479e619b78afb68de77e7796a452246e` for v0.1.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 `5addd4052346aac69dec3faad4b46261` for v0.2.0._
4848

4949
## Usage
5050

hook.sh

Lines changed: 9 additions & 1 deletion
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.1.0
7+
# Version 0.2.0
88
#
99
# https://github.com/tommarshall/git-good-commit
1010
#
@@ -89,8 +89,16 @@ read_commit_msg() {
8989

9090
# read commit message into lines array
9191
while IFS= read -r; do
92+
93+
# trim trailing spaces from commit lines
94+
shopt -s extglob
95+
REPLY="${REPLY%%*( )}"
96+
shopt -u extglob
97+
98+
# ignore comments
9299
[[ $REPLY =~ ^# ]]
93100
test $? -eq 0 || COMMIT_MSG_LINES+=("$REPLY")
101+
94102
done < <(cat $COMMIT_MSG_FILE)
95103
}
96104

0 commit comments

Comments
 (0)