我似乎无法在我的设置上使用任何 git 挂钩。
sjakubowski@sjakubowski:~/Work/git$ mkdir hookstest
sjakubowski@sjakubowski:~/Work/git$ cd hookstest/
hookstest$ git init
Initialized empty Git repository in /home/sjakubowski/Work/git/hookstest/.git/
hookstest$ git commit -m "initial commit"
[master (root-commit) 82b95e0] initial commit
0 files changed
create mode 100644 testfile
hookstest$ touch .git/hooks/commit-msg
hookstest$ nano .git/hooks/commit-msg
hookstest$ cat .git/hooks/commit-msg
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
#starts with # then number, space, and at least 5 words no more than 200
$regex = /(^#[0-9]+ \W*(\w+(\W+|$)){5,200})/
if !$regex.match(message)
puts "Your message is not formatted correctly (example: #XXX at least 5 words)"
exit 1
end
hookstest$ touch testfile2
hookstest$ git add testfile2
hookstest$ git commit -m "this message won't be blocked"
[master adea486] this message won't be blocked
0 files changed
create mode 100644 testfile2
我错过了什么?这是我的配置。
hookstest$ git --version
git version 1.7.9.5
hookstest$ ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
hookstest$ git config --list
user.name=Sylvester Jakubowski
user.email=XXXX@gmail.com
github.user=sjakubowski
github.token=XXXX
color.ui=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true