메일링 리스트에 Subversion 커밋 로그 메시지 포스팅 하기

저작권 안내
  • 책 또는 웹사이트의 내용을 복제하여 다른 곳에 게시하는 것을 금지합니다.
  • 책 또는 웹사이트의 내용을 발췌, 요약하여 강의 자료, 발표 자료, 블로그 포스팅 등으로 만드는 것을 금지합니다.

메일링 리스트에 Subversion 커밋 로그 메시지 포스팅 하기

이재홍 http://www.pyrasis.com ~2004.10.10. 버전 1.0

CVS와 같이 Subversion도 커밋 메시지를 메일, 메일링 리스트에 포스팅 할 수 있습니다.

commit-mail.pl

commit-mail 펄 스크립트 파일입니다. Subversion에서 커밋을 했을때 실행되게 하면 적당히 메일을 만들어서 보내줍니다. 이 펄 스크립트는 Subversion 소스와 함께 배포되고 있습니다. Subversion 소스 디렉토리/tools/hook-scripts에 commit-email.pl.in이라는 이름으로 들어 있습니다. 이 파일을 commit-email.pl로 바꾸고 사용하면 됩니다.

아래 파일은 리비전간의 Diff를 보낼지 보내지 않을지 설정할 수 있도록 수정한 파일입니다.
commit-email.pl.gz

위 파일을 다운로드 받습니다. gzip으로 압축이 되어 있는데. 압축을 해제 한뒤 저장소 디렉토리 아래의 hooks 디렉토리에 복사합니다. 그리고 실행 권한을 줍니다.

# chmod 755 commit-email.pl

commit-email.pl을 열어 자신의 시스템에 맞게 설정을 고칩니다.

######################################################################
# Configuration section.

# Ensure that sending charset is UTF-8.
$ENV{'LANG'} = "ko_KR.UTF-8";
$ENV{'LC_CTYPE'} = "ko_KR.UTF-8";

# Sendmail path.
my $sendmail = "/usr/sbin/sendmail";
# Svnlook path.
my $svnlook = "@SVN_BINDIR@/svnlook";

# By default, when a file is deleted from the repository, svnlook diff
# prints the entire contents of the file.  If you want to save space
# in the log and email messages by not printing the file, then set
# $no_diff_deleted to 1.
my $no_diff_deleted = 1;

# By default, do not include diff in the mail.
my $include_diff = 1;
  • 한글을 사용하려면 $ENV{'LANG'}$ENV{'LC_CTYPE'}ko_KR.UTF-8로 설정합니다.
  • $sendmail에 Sendmail이 있는 경로를 설정합니다. Qmail을 사용하고 있는 경우 /var/qmail/bin/sendmail로 설정 할 수도 있습니다. 자신의 시스템에 설치된 메일 데몬의 경로를 지정합니다.
  • $svnlook에는 svnlook의 경로를 지정합니다. 예) /usr/local/bin/svnlook
  • $include_diff에는 Diff를 메일에 포함시킬것인지를 설정합니다. 1로 하면 메일에 Diff가 포함되며 0으로 하면 Diff가 포함되지 않습니다.

$ENV{'LANG'}, $ENV{'LC_CTYPE'}, $include_diff는 Subversion 소스에 포함된 스크립트에는 없습니다. 위에서 받을 수 있는 commit-email.pl.gz에서 설정할 수 있습니다.

주의 : 펄 스크립트를 실행하기 위해 펄이 필요하고 메일을 보낼 수 있도록 Sendmail이 필요합니다. 펄 설치와 메일 설정은 꼭 하셔야 합니다.

저장소 설정하기

Subversion 저장소안에는 hooks 라는 디렉토리가 있습니다. 이 디렉토리 안에서 커밋을 했을때 실행할 것들을 설정 합니다. hooks 디렉토리 안의 post-commit.tmpl 파일을 post-commit이라고 복사합니다. .tmpl 파일은 아무 일도 하지 않는 파일입니다. 그리고 실행 권한을 줍니다.

# cp post-commit.tmpl post-commit
# chmod 755 post-commit

같은 디렉토리에 있는 pre-revprop-change.tmpl파일도 pre-revprop-change로 복사한 뒤 실행권한을 줍니다.

# cp pre-revprop-change.tmpl pre-revprop-change
# chmod 755 pre-revprop-change

그리고 post-commit 파일을 수정합니다.

#!/bin/sh

# POST-COMMIT HOOK
#
# The post-commit hook is invoked after a commit. Subversion runs
# this hook by invoking a program (script, executable, binary,
# etc.) named 'post-commit' (for which
# this file is a template) with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] REV          (the number of the revision just committed)
#
# Because the commit has already completed and cannot be undone,
# the exit code of the hook program is ignored.  The hook program
# can use the 'svnlook' utility to help it examine the
# newly-committed tree.
#
# On a Unix system, the normal procedure is to have 'post-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
#
# Note that 'post-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
#
# On a Windows system, you should name the hook program
# 'post-commit.bat' or 'post-commit.exe',
# but the basic idea is the same.
# 
# Here is an example hook script, for a Unix /bin/sh interpreter:

REPOS="$1"
REV="$2"

PERL="/usr/local/bin/perl"
COMMIT_EMAIL="/repos/sample/hooks/commit-email.pl"
SUBJECT="Sample Project svn commit:"
AUTHOR=`/usr/local/bin/svnlook author -r $REV $REPOS`
FROMMAIL="$AUTHOR@your-domain.com" # 보낸 사람
LISTS="mailling-list-address@examplemail.net"

$PERL $COMMIT_EMAIL "$REPOS" "$REV" -s "$SUBJECT" "$LISTS" --from "$FROMMAIL"

#commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
#log-commit.py --repository "$REPOS" --revision "$REV"
  • PERL에는 시스템에서 펄이 설치된 경로를 지정합니다.
  • COMMIT_EMAIL에는 위에서 받은 commit-email.pl의 경로를 지정합니다. 우리는 저장소 디렉토리 아래의 hooks 디렉토리에 commit-email.pl 파일을 넣었으므로 (저장소 디렉토리)/hooks/commit-email.pl로 합니다.
  • SUBJECT에는 메일 제목에 들어갈 문장을 지정합니다.
  • AUTHOR의 /usr/local/bin/svnlook은 자신의 시스템에 설치된 svnlook의 경로로 지정합니다.
  • FROMMAIL에는 커밋하는 사람의 이메일 주소를 지정합니다. 해당 단체의 도메인을 지정하면 됩니다. 보낸 사람을 표시하지 않으려면 --from "$FROMMAIL" 부분을 삭제하면 됩니다. 보낸 사람을 표시하지 않으면 Subversion 저장소 서버의 도메인과 계정 이름으로 보낸 사람이 표시됩니다.
  • LISTS 커밋 메시지가 포스팅 될 메일링 리스트나 메일 주소를 지정하면 됩니다.

메일 테스트 방법

커밋을 한것과 같은 효과를 내어 메일 테스트를 해볼 수 있습니다.

쉘에서 다음과 같이 명령을 내리면 커밋 로그를 메일로 직접 보낼 수 있습니다.

# ./post-commit "/repos/sample" "20"

"/repos/sample"은 저장소의 경로입니다. "20"은 커밋 로그 메시지를 보내고자 하는 특정 리비전입니다.

Subversion에서는 버전을 전체 리비전으로 관리하므로 메일은 리비전 단위로 보내야 합니다.


저작권 안내

이 웹사이트에 게시된 모든 글의 무단 복제 및 도용을 금지합니다.
  • 블로그, 게시판 등에 퍼가는 것을 금지합니다.
  • 비공개 포스트에 퍼가는 것을 금지합니다.
  • 글 내용, 그림을 발췌 및 요약하는 것을 금지합니다.
  • 링크 및 SNS 공유는 허용합니다.

Published

2004-10-11