我在窗口中使用git,並且我想在每次push後做一些操作,所以我使用post-receive hook,但是當我試圖讓refname
知道推送的分支時,我給任何東西。在post-receive鉤子中獲取refname
爲什麼? (我不能也給其他參數:oldrev
和newrev
)
這是我的後收到的文件,電子郵件被正確發送,但沒有在這一主題的refname(它如果我把$3
相同在體內)
#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
# send mail
last_comment=$(git log -n 1 HEAD --format=format:%s%n%b)
last_change=$(git log -1 --name-status)
msmtp $(git config hooks.mailinglist) <<EOI
Subject: [GIT] ($3) Sources update
$last_change
EOI
這將幫助,如果你在你的問題包括你正在使用的'後receive'掛機腳本,讓人們有機會猜測什麼是錯的。常見錯誤是'oldrev newrev refname'在標準輸入上提供,而不是作爲命令行參數提供。 –