Created
December 5, 2012 05:04
-
-
Save pogin503/4212441 to your computer and use it in GitHub Desktop.
test-post-receive.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# rm ~/foo -rf | |
function sep (){ | |
echo "===================" | |
echo "" | |
echo "===================" | |
} | |
# テスト用リポジトリを作る (~/foo/test ) | |
mkdir foo | |
cd ~/foo && pwd | |
mkdir test | |
cd test/ && pwd | |
git init | |
touch test.txt | |
echo "foo" >> test.txt | |
git add . && git commit -m "test commit" | |
sep | |
# テスト用リモートを作る (~/foo/repo.git) | |
cd ~/foo && pwd | |
mkdir repo.git | |
cd repo.git && pwd | |
git init --bare #リモートリポジトリを作るためにbareリポジトリを作る | |
sep | |
cd ~/foo/test && pwd | |
git push ~/foo/repo.git master | |
sep | |
# フックを設定する (~/receive) | |
cd ~/foo && pwd | |
git clone ~/foo/repo.git receive # cloneのときreceiveというディレクトリ名でクローンする | |
cd repo.git/hooks/ && pwd | |
{ | |
echo "#!/bin/sh" | |
echo "" | |
echo "# . /home/username/foo/repo.git/hooks/post-receive" | |
echo 'echo "test post-receive"' | |
echo "pwd" | |
echo "cd ~/foo/receive # post-receiveが実行されるときはrepo.git/にいる" | |
echo "pwd" | |
echo "git --git-dir=.git pull ../repo.git master" | |
} > post-receive | |
# post-receiveはchmodで実行権限を与えておかないと実行されない | |
chmod +x post-receive | |
sep | |
# post-receiveが動くかの確認 | |
cd ~/foo/test && pwd | |
echo "test" >> test.txt && git add . && git commit -m "test commit" && git push ../repo.git/ master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment