end\r
\r
list = @changed_files[options[:type]] || @changed_files[:all]\r
- list = list.select {|path| path.index(options[:in]) == 0} if options[:in]\r
+ list = list.select {|path| options[:in].to_a.any? {|inpath|\r
+ path.index(inpath) == 0} if options[:in]\r
list = list.select {|path|\r
options[:extension].include?(File.extname(path).downcase)\r
} if options[:extension]\r
file = File.join(@repos, "hooks/hook_config.yml")\r
conf = File.file?(file) ? YAML.load_file(file) : {}\r
end\r
-\r
- def http_port\r
- unless @http_port\r
- filename ||= File.join(HOME, "config/service.yml")\r
- conf = File.file?(filename) ? YAML.load_file(filename) : {}\r
- @http_port = conf["apache"]["port"]\r
- end\r
- @http_port\r
- end\r
end\r
end\r
end\r
\r
def fetch_changesets(options)\r
- return unless changed_files.size > 0\r
-\r
run_background(%Q[ruby "#{HOME}/redmine/script/runner" "Repository.fetch_changesets"])\r
end\r
\r
def perform_build(options)\r
- return unless options["jobs"]\r
- options["jobs"].each {|job|\r
- name = job["name"]\r
- next unless name || changed_files(:in => job["path"]).size > 0\r
+ port = options["http_port"] || 80\r
+ token = options["token"]\r
+ return unless jobs = options["jobs"]\r
\r
- hudson_xml = File.join(HOME, "hudson/home/jobs/#{name}/config.xml")\r
- path = "/hudson/job/#{name}/build"\r
- next unless File.file?(hudson_xml)\r
+ jobs.each {|job|\r
+ next unless changed_files(:in => job["path"]).size > 0\r
+ name = job["name"]\r
\r
- require 'rexml/document'\r
- doc = REXML::Document.new(File.new(hudson_xml))\r
- elem = doc.elements["/project/authToken"]\r
- path += "?token=#{elem.text}" if elem\r
- run_background(%Q[ruby -e "require 'net/http'; Net::HTTP.get('localhost', '#{path}', #{http_port})"])\r
+ run_background(%Q[ruby -e "require 'net/http'; Net::HTTP.get('localhost', '/hudson/job/#{name}/build?token=#{token}', #{port})"])\r
}\r
end\r
end\r
end\r
\r
def check_commit_message(options)\r
- return unless changed_files(:in => options["path"]).size > 0\r
+ path = options["path"]\r
+ keywords = options["keywords"]\r
+ return unless changed_files(:in => path).size > 0\r
\r
- (options["keywords"] || []).each {|keyword|\r
+ keywords.each {|keyword|\r
begin\r
case keyword\r
when String\r
def check_encoding(options)\r
require 'iconv'\r
\r
+ path = options["path"]\r
@encoding = options["encoding"]\r
- changed_files(:type => :text, :in => options["path"], :extension => options["filetype"]).each {|file|\r
+ changed_files(:type => :text, :in => path, :extension => options["filetype"]).each {|file|\r
begin\r
Iconv.iconv(@encoding, @encoding, cat(file))\r
rescue Iconv::IllegalSequence\r
\r
# type: space or tab (default both)\r
def check_white_space(options)\r
+ path = options["path"]\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 => options["path"], :extension => options["filetype"]).each {|file|\r
+ changed_files(:type => :text, :in => path, :extension => options["filetype"]).each {|file|\r
cat(file).each{|line|\r
next unless s = line.match(/^\s+/)\r
s = s.to_s\r