-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcommit-msg
More file actions
executable file
·61 lines (55 loc) · 1.85 KB
/
commit-msg
File metadata and controls
executable file
·61 lines (55 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env sh
export COMMIT_MESSAGE_PATH=$1
if [ -z "$COMMIT_MESSAGE_PATH" ]; then
>&2 echo "fit-commit: WARNING: Skipping checks because the Git hook was not passed the"
>&2 echo "fit-commit: commit message file path. This is usually \`.git/COMMIT_EDITMSG\`."
>&2 echo "fit-commit: This hook was called via: $0 $*"
>&2 echo "fit-commit: Please submit a bug report with the project:"
>&2 echo "fit-commit: https://github.com/m1foley/fit-commit/issues"
exit 0
fi
if [ ! -r "$COMMIT_MESSAGE_PATH" ]; then
>&2 echo "fit-commit: WARNING: Skipping checks because the commit message file cannot be read:"
>&2 echo "fit-commit: $COMMIT_MESSAGE_PATH"
>&2 echo "fit-commit: This hook was called via: $0 $*"
>&2 echo "fit-commit: Please submit a bug report with the project:"
>&2 echo "fit-commit: https://github.com/m1foley/fit-commit/issues"
exit 0
fi
export GIT_BRANCH_NAME=`git symbolic-ref --short HEAD 2> /dev/null`
# If this script is being run from a non interactive shell
# (i.e. from within RubyMine) then we might need to
# detect and initialise rbenv.
if [ -d $HOME/.rbenv ]; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
# Use bundler if fit-commit was installed using it
# or find appropriate Ruby command
if bundle show fit-commit > /dev/null 2>&1; then
cmd="bundle exec ruby"
elif which rbenv > /dev/null 2>&1; then
cmd="rbenv exec ruby"
elif which ruby-rvm-env > /dev/null 2>&1; then
cmd="ruby-rvm-env"
elif which rvm > /dev/null 2>&1; then
cmd="rvm default do ruby"
else
cmd="ruby"
fi
# allow user input if running in a terminal
if [ -t 1 ]; then
exec < /dev/tty
fi
$cmd -rrubygems -e '
begin
require "fit_commit"
true
rescue LoadError => e
$stderr.puts <<-MESSAGE
fit-commit: WARNING: Skipping checks because: #{e}
fit-commit: Did you set your Ruby version?
MESSAGE
false
end and FitCommit.run
'