2008. 7. 9. 19:41
Subversion의 commit과 Trac 연동하기...(Subversion, Trac, post-commit, trac-post-commit-hook)
2008. 7. 9. 19:41 in 개발 관련 툴/Trac
![](https://tistory1.daumcdn.net/tistory/0/tis_UtomBox_Green/images/bg_clear.gif)
Subversion에서 commit하면 자동으로 Trac의 티켓 닫기
일단 다음과 같이 가정합니다.
- Subversion 저장소 : /var/TEST
- Trac 저장소 : /var/TEST.TRAC
Subversion의 post-commit 훅 스크립트
- /var/TEST/hooks/post-commit 스크립트 파일
- 원래의 파일 이름은 post-commit.tmpl 입니다. 이 파일의 이름을 post-commit 으로 변경하고, 실행 속성을 주어야 합니다.
SVNLOOK=/usr/local/bin/svnlook
REPOS="$1"
REV="$2"
LOG=`$SVNLOOK log -r "$REV" "$REPOS"`
AUTHOR=`$SVNLOOK author -r "$REV" "$REPOS"`
DIRS="`$SVNLOOK dirs-changed -r "$REV" "$REPOS"`"
$REPOS/hooks/trac-post-commit-hook.py -p /var/TEST.TRAC -r "$REV" -u "$AUTHOR" -m "$LOG"
REPOS="$1"
REV="$2"
LOG=`$SVNLOOK log -r "$REV" "$REPOS"`
AUTHOR=`$SVNLOOK author -r "$REV" "$REPOS"`
DIRS="`$SVNLOOK dirs-changed -r "$REV" "$REPOS"`"
$REPOS/hooks/trac-post-commit-hook.py -p /var/TEST.TRAC -r "$REV" -u "$AUTHOR" -m "$LOG"
Trac의 trac-post-commit-hook.py 파일
- 사용하고 있는 trac의 소스에 보면 contrib/trac-post-commit-hook 파일이 있습니다.
- 이 파일을 /var/TEST/hooks 디렉토리에 복사합니다. 이 위치는 post-commit 파일에 명시된 위치와 동일합니다.
주의 사항
- 위에서 언급한 두개의 파일은 모두 실행 속성을 가지고 있어야 한다.
Subversion commit시에 Trac의 티켓에 영향을 미치도록 commit message 작성하기
다음과 같은 동작을 수행할 수 있습니다.
- 티켓 자동으로 닫기
- 티켓에 자동으로 comment 추가하기
# It searches commit messages for text in the form of:
# command #1
# command #1, #2
# command #1 & #2
# command #1 and #2
#
# Instead of the short-hand syntax "#1", "ticket:1" can be used as well, e.g.:
# command ticket:1
# command ticket:1, ticket:2
# command ticket:1 & ticket:2
# command ticket:1 and ticket:2
#
# In addition, the ':' character can be omitted and issue or bug can be used
# instead of ticket.
#
# You can have more then one command in a message. The following commands
# are supported. There is more then one spelling for each command, to make
# this as user-friendly as possible.
#
# close, closed, closes, fix, fixed, fixes
# The specified issue numbers are closed with the contents of this
# commit message being added to it.
# references, refs, addresses, re, see
# The specified issue numbers are left in their current status, but
# the contents of this commit message are added to their notes.
#
# A fairly complicated example of what you can do is with a commit message
# of:
#
# Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.
#
# This will close #10 and #12, and add a note to #12.
# command #1
# command #1, #2
# command #1 & #2
# command #1 and #2
#
# Instead of the short-hand syntax "#1", "ticket:1" can be used as well, e.g.:
# command ticket:1
# command ticket:1, ticket:2
# command ticket:1 & ticket:2
# command ticket:1 and ticket:2
#
# In addition, the ':' character can be omitted and issue or bug can be used
# instead of ticket.
#
# You can have more then one command in a message. The following commands
# are supported. There is more then one spelling for each command, to make
# this as user-friendly as possible.
#
# close, closed, closes, fix, fixed, fixes
# The specified issue numbers are closed with the contents of this
# commit message being added to it.
# references, refs, addresses, re, see
# The specified issue numbers are left in their current status, but
# the contents of this commit message are added to their notes.
#
# A fairly complicated example of what you can do is with a commit message
# of:
#
# Changed blah and foo to do this or that. Fixes #10 and #12, and refs #12.
#
# This will close #10 and #12, and add a note to #12.
즉, Subversion commit 메시지에 특정 스트링을 넣으면, Trac의 티켓이 자동으로 변경됩니다.
Subversion commit과 함께 5, 10번 티켓을 닫을려면 다음과 같이 사용할 수 있다.
"close" 대신에 "closed", "closes", "fix", "fixed", "fixes" 등을 사용할 수도 있다.
close #5, #10
close #5 & #10
close #5 and #10
close ticket:5, ticket:10
close #5 & #10
close #5 and #10
close ticket:5, ticket:10
Subversion commit과 함께 commit 메시지를 5번, 10번 티켓의 comment로 추가하려면...
"refs" 대신에 "references", "addresses", "re", "see"등을 사용할 수도 있다.
refs #5, #10
refs #5, #10
refs #5 & #10
refs #5 and #10
refs ticket:5, ticket:10
refs #5, #10
refs #5 & #10
refs #5 and #10
refs ticket:5, ticket:10
자. 이제 Subversion에서 commit을 하면, 자동으로 Trac의 관련 티켓이 닫히거나, comment가 추가되게 됩니다.
참고로 말씀 드립니다.
오늘 서점에 갔다가 "윈도우 프로젝트 필수 유틸리티"란 책을 보았습니다.
이 책에 윈도우 환경에서 Subversion과 Trac을 연동하는 방법이 아주 잘 설명되었습니다.
참고하시기 바립니다.