Created
November 30, 2011 00:41
-
-
Save mathfur/1407397 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit以下に配置すると、カレントディレクトリ以下にTODOが有る場合にコミットを禁止する。
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
#!/usr/bin/ruby | |
# | |
# .git/hooks/pre-commit以下に配置すると、カレントディレクトリ以下にTODOが | |
# 有る場合にコミットを禁止する。 | |
# FORCE_COMMITフラグが立っていればTODO有りでもコミットできる | |
exit 0 if ENV["FORCE_COMMIT"] == "true" | |
todo_files = Dir["#{Dir.pwd}/**/*"].select do |path| | |
File.read(path).all?{|line| (line =~ /TODO/) and (line !~ /#.*TODO/)} | |
end | |
if 0 < todo_files.size | |
puts "TODOファイルが残っています" | |
exit -1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment