2017. 1. 5. 01:27ㆍ프로그래밍/형상관리
회사에서 리눅스 머신에 git과 svn 커밋 mail을 손대게 되어 좀 찾아봤다.
나의 개인 리눅스 머신에서 테스트 했으며 CentosOS Linux 7 환경.
우선 해야 될 것은 2가지다.
1. project.git 폴더의 config에 [hooks] 섹션 값들 설정해주기.
2. post-receive 설정.
config에 [hooks] 섹션 값 설정
원격지에 bare로 생성되어 있는 [project name].git 폴더에 들어간다.
보통 /usr/local/git/repos/project.git 쯤 될 것이다.
해당 폴더에 config 파일이 있고 vim config 수행
1 2 3 4 | [hooks] mailinglist = elkiss@gmail.com showrev = "git show -C %s; echo" emailprefix = "[Test repos]" | cs |
post-receive 설정
원격지의 git hook 기능인 post-receive-email이 어느 경로인지 확인.
/usr/share/doc/git-core/contrib/hooks/post-receive-email
이 일반적인 경로인데 나의 경우 git-core가 아닌 git 버전으로.. git-1.8.3.1
/usr/local/git/repos/poject.git/hooks 폴더에 post-receive.sample 이 있는지 확인.
있다면 이름을 바꿔준다. mv post-receive.sample post-receive
파일이 있다면 주석 제일 아랫줄은 주석을 푼다. 얘를 실행하게 되는 것.
git-core 경로가 맞는지 한번 더 확인한다.
없다면 새로 만들어준다. touch post-receive
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/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 an sample, or uncomment the next line and # rename the file to "post-receive". #. /usr/share/doc/git-core/contrib/hooks/post-receive-email | cs |
딱히 주석이 필요 없이 맨 아랫 줄만 있으면 된다.
vim으로 마지막 줄은 주석을 풀고 git core 경로가 맞는지 확인한다.
그리고 해당 스크립트들이 실행 권한을 얻을 수 있도록 chomd로 권한을 부여해준다.
경로는 /project.git/hooks/ 라고 가정.
sudo chmod 0755 /usr/share/doc/git-core/contrib/hooks/post-receive-email
sudo chmod 0755 post-receive
커밋을 하면 메일이 온다.
정크 메일에 있어서 왜 안오는지 한참 헤맸다..
제목: elkiss@elkiss-centos.localdomain
내용:
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "UNNAMED PROJECT".
The branch, master has been updated
via fed8fbcacc7130c945523868099135
from e2b13b5c17fc97fb447e5997126128
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log ------------------------------
commit fed8fbcacc7130c945523868099135
Author: Elkiss-PC <email@gmail.com>
Date: Thu Jan 5 01:00:07 2017 +0900
Test mailing.
diff --git a/test.txt b/test.txt
deleted file mode 100644
index e69de29..0000000
------------------------------
Summary of changes:
test.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 test.txt
hooks/post-receive
'프로그래밍 > 형상관리' 카테고리의 다른 글
[GIT] ignore 따로 두기 (0) | 2017.11.15 |
---|---|
[GIT] git remote url 변경하기 (0) | 2017.07.10 |
[GIT] git pull no tracking info 에러 (0) | 2017.02.08 |
[git] 특정 리비전으로 리버트하기 (0) | 2016.11.08 |
[svn] Cleanup failed to process the following paths: (4) | 2016.08.18 |
[CI] 팀시티 git checkout 메모리 에러 (3) | 2016.08.12 |
[GIT] 서버에 원격 리포지토리 만들기 (0) | 2016.04.25 |