push したタイミングで Trac のチケットへコミットコメントを反映するフックスクリプト
6371 ワード
前提
Trac のプラグイン CommitTicketReferenceMacro、CommitTicketUpdater を有効にしておく。
Git のフックスクリプト
post-receive
#!/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/local/share/git-core/contrib/hooks/post-receive-email
GIT_APP="/usr/local/bin/git"
TRAC_ADMIN="/usr/local/bin/trac-admin"
TRAC_ENV="【Tracのenvへのパス】"
REPO_NAME="【Tracに登録したGITリポジトリ名】"
LOG="/dev/null"
while read oldrev newrev refname; do
echo "oldrev=${oldrev}, newrev=${newrev}, refname=${refname}" >> "${LOG}"
from_rev=`git log -n 1 --reverse --pretty=format:%h ${oldrev}`
to_rev=`git log -n 1 --reverse --pretty=format:%h ${newrev}`
echo "from_rev=${from_rev}, to_rev=${to_rev}" >> "${LOG}"
added_flag="0"
for rev in `${GIT_APP} log --reverse --pretty=format:%h`; do
if [ "${added_flag}" = "1" -o "${from_rev}" = "" ]; then
echo "rev=${rev}" >> "${LOG}"
${TRAC_ADMIN} "${TRAC_ENV}" changeset added "${REPO_NAME}" "${rev}"
elif [ "${from_rev}" = "${rev}" ]; then
added_flag="1"
fi
done
done
${TRAC_ADMIN} "${TRAC_ENV}" repository resync "${REPO_NAME}"
心配事
post-receive
#!/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/local/share/git-core/contrib/hooks/post-receive-email
GIT_APP="/usr/local/bin/git"
TRAC_ADMIN="/usr/local/bin/trac-admin"
TRAC_ENV="【Tracのenvへのパス】"
REPO_NAME="【Tracに登録したGITリポジトリ名】"
LOG="/dev/null"
while read oldrev newrev refname; do
echo "oldrev=${oldrev}, newrev=${newrev}, refname=${refname}" >> "${LOG}"
from_rev=`git log -n 1 --reverse --pretty=format:%h ${oldrev}`
to_rev=`git log -n 1 --reverse --pretty=format:%h ${newrev}`
echo "from_rev=${from_rev}, to_rev=${to_rev}" >> "${LOG}"
added_flag="0"
for rev in `${GIT_APP} log --reverse --pretty=format:%h`; do
if [ "${added_flag}" = "1" -o "${from_rev}" = "" ]; then
echo "rev=${rev}" >> "${LOG}"
${TRAC_ADMIN} "${TRAC_ENV}" changeset added "${REPO_NAME}" "${rev}"
elif [ "${from_rev}" = "${rev}" ]; then
added_flag="1"
fi
done
done
${TRAC_ADMIN} "${TRAC_ENV}" repository resync "${REPO_NAME}"
ブランチをマージした後 push すると、チケットがコメントだらけになってしまうかも?
Author And Source
この問題について(push したタイミングで Trac のチケットへコミットコメントを反映するフックスクリプト), 我々は、より多くの情報をここで見つけました https://qiita.com/asahiufo/items/22bb168d8271a76819c2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .