Skip to content

Instantly share code, notes, and snippets.

@mathfur
Created November 30, 2011 00:41
Show Gist options
  • Save mathfur/1407397 to your computer and use it in GitHub Desktop.
Save mathfur/1407397 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit以下に配置すると、カレントディレクトリ以下にTODOが有る場合にコミットを禁止する。
#!/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