OSDN Git Service

Modification about hook_config.yml
[redminele/redminele.git] / script / hooks / subversion_hook / pre_commit.rb
index 02b0735..1745725 100644 (file)
@@ -9,10 +9,8 @@ module SubversionHook
                        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
@@ -38,10 +36,10 @@ module SubversionHook
                        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
@@ -70,11 +68,11 @@ module SubversionHook
                        }\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
@@ -84,14 +82,14 @@ module SubversionHook
                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