Fix potential for double path on grep. Fixed broken generators check. Better regex to check for commented out lines when grep returns path name first
This commit is contained in:
parent
fcf23ffecf
commit
22ce8cab63
|
@ -221,8 +221,8 @@ module Rails
|
||||||
generators = Dir.glob(base_path + "vendor/plugins/**/generators/**/")
|
generators = Dir.glob(base_path + "vendor/plugins/**/generators/**/")
|
||||||
|
|
||||||
unless generators.empty?
|
unless generators.empty?
|
||||||
files = generators.map do |g|
|
files = generators.reject do |g|
|
||||||
grep_for("def manifest", g).empty? ? g : nil
|
grep_for("def manifest", g).empty?
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
if !files.empty?
|
if !files.empty?
|
||||||
|
@ -348,6 +348,9 @@ module Rails
|
||||||
# If they're on Windows, they probably don't have grep.
|
# If they're on Windows, they probably don't have grep.
|
||||||
@probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil?
|
@probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil?
|
||||||
|
|
||||||
|
# protect against double root paths in Rails 3
|
||||||
|
where.gsub!(Regexp.new(base_path),'')
|
||||||
|
|
||||||
lines = if @probably_has_grep
|
lines = if @probably_has_grep
|
||||||
find_with_grep(text, base_path + where, double_quote, perl_regex)
|
find_with_grep(text, base_path + where, double_quote, perl_regex)
|
||||||
else
|
else
|
||||||
|
@ -355,9 +358,7 @@ module Rails
|
||||||
end
|
end
|
||||||
|
|
||||||
# ignore comments
|
# ignore comments
|
||||||
lines.gsub! /^\s*#.+$/m, ""
|
lines.gsub /^(\/[^:]+:)?\s*#.+$/m, ""
|
||||||
|
|
||||||
lines
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a base path for finding files; mostly for testing
|
# Sets a base path for finding files; mostly for testing
|
||||||
|
@ -378,18 +379,15 @@ module Rails
|
||||||
Open3.popen3(command) do |stdin, stdout, stderr|
|
Open3.popen3(command) do |stdin, stdout, stderr|
|
||||||
value = stdout.read
|
value = stdout.read
|
||||||
end
|
end
|
||||||
|
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Use the rak gem to grep the files (not yet implemented)
|
# Use the rak gem to grep the files (not yet implemented)
|
||||||
def find_with_rak(text, where, double_quote)
|
def find_with_rak(text, where, double_quote)
|
||||||
value = ""
|
value = ""
|
||||||
|
|
||||||
Open3.popen3("rak --nogroup -l '#{Regexp.escape(text)}' #{where}") do |stdin, stdout, stderr|
|
Open3.popen3("rak --nogroup -l '#{Regexp.escape(text)}' #{where}") do |stdin, stdout, stderr|
|
||||||
value = stdout.read
|
value = stdout.read
|
||||||
end
|
end
|
||||||
|
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -405,13 +403,11 @@ module Rails
|
||||||
def extract_filenames_from_grep(output)
|
def extract_filenames_from_grep(output)
|
||||||
return nil if output.empty?
|
return nil if output.empty?
|
||||||
|
|
||||||
fnames = output.split("\n").map do |fn|
|
output.split("\n").map do |fn|
|
||||||
if m = fn.match(/^(.+?):/)
|
if m = fn.match(/^(.+?):/)
|
||||||
m[1]
|
m[1]
|
||||||
end
|
end
|
||||||
end.compact
|
end.compact.uniq
|
||||||
|
|
||||||
fnames.uniq
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_filenames_from_rak(output)
|
def extract_filenames_from_rak(output)
|
||||||
|
|
Loading…
Reference in New Issue