self.transaction = transaction\r
\r
@errors = {}\r
- (load_config["pre_commit"] || {}).each {|path, options|\r
- options.each {|method, option|\r
- self.send(method, path, option)\r
- }\r
+ (load_config["pre_commit"] || {}).each {|method, options|\r
+ self.send(method, options)\r
}\r
\r
unless @errors.size == 0\r
end\r
end\r
\r
- def check_commit_message(path, keywords)\r
- return unless changed_files(:in => path).size > 0\r
+ def check_commit_message(options)\r
+ return unless changed_files(:in => options["path"]).size > 0\r
\r
- keywords.each {|keyword|\r
+ (options["keywords"] || []).each {|keyword|\r
begin\r
case keyword\r
when String\r
}\r
end\r
\r
- def check_encoding(path, options)\r
+ def check_encoding(options)\r
require 'iconv'\r
\r
@encoding = options["encoding"]\r
- changed_files(:type => :text, :in => path, :extension => options["filetype"]).each {|file|\r
+ changed_files(:type => :text, :in => options["path"], :extension => options["filetype"]).each {|file|\r
begin\r
Iconv.iconv(@encoding, @encoding, cat(file))\r
rescue Iconv::IllegalSequence\r
end\r
\r
# type: space or tab (default both)\r
- def check_white_space(path, options)\r
+ def check_white_space(options)\r
h = {"space" => " ", "tab" => "\t"}\r
char = h[options["type"]]\r
@white_space_error_message = char ?\r
"The following files are not indented with #{options['type']} only:" :\r
"The following files are indented with a mixture of tabs and spaces:"\r
\r
- changed_files(:type => :text, :in => path, :extension => options["filetype"]).each {|file|\r
+ changed_files(:type => :text, :in => options["path"], :extension => options["filetype"]).each {|file|\r
cat(file).each{|line|\r
next unless s = line.match(/^\s+/)\r
s = s.to_s\r