ブログ@kaorun55

HoloLensやKinectなどのDepthセンサーを中心に書いています。

テスト成功ごとにgitにコミットしてみる

確か@のツイートにだった気がするんだけど、「テストごとにgitにコミットすればコードの成長過程が残るよねー」って。
なるほど。
毎回ちゃんとコミットすればいいんだけど、よく忘れるのでmakeしてテスト実行する際にgitへのコミットも入れてみた。コミットメッセージはコミット時刻です。
環境はMac+C++

Makefileをこんな感じに書いてみた

NOW=$(shell date +"%Y/%m/%d %p %I:%M:%S")

test: test.cpp
	g++ test.cpp -lgtest -lgtest_main
	./a.out
	git commit -am"$(NOW)"

出力はこんな感じ

MakefileGit kaorun$ make
g++ test.cpp -lgtest -lgtest_main
./a.out
Running main() from gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from simpleTest
[ RUN      ] simpleTest.except_eq
[       OK ] simpleTest.except_eq (0 ms)
[----------] 1 test from simpleTest (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[  PASSED  ] 1 test.
git commit -am"2010/08/04 PM 11:49:37"
[master 9db311e] 2010/08/04 PM 11:49:37
 1 files changed, 1 insertions(+), 1 deletions(-)

まぁ

コミットメッセージが時刻はどうなのとか、能動的にコミットがベストなんだけどとかあるけど、忘れちゃう人にはいいんじゃないかな。