mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 11:37:14 +00:00
Replace regular expression matches with String#start_with? / end_with? (#40010).
Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22605 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b57a3a187c
commit
5b77092be4
@ -481,7 +481,7 @@ class IssueQuery < Query
|
||||
" WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id" +
|
||||
" AND (#{sql_for_field field, operator.delete_prefix('!'), value, Journal.table_name, 'notes'})" +
|
||||
" AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})"
|
||||
"#{/^!/.match?(operator) ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
|
||||
"#{operator.start_with?('!') ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
|
||||
end
|
||||
|
||||
def sql_for_updated_by_field(field, operator, value)
|
||||
|
||||
@ -194,7 +194,7 @@ module Redmine
|
||||
|
||||
def target(path, sq=true)
|
||||
path ||= ''
|
||||
base = /^\//.match?(path) ? root_url : url
|
||||
base = path.start_with?('/') ? root_url : url
|
||||
str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
|
||||
if sq
|
||||
str = shell_quote(str)
|
||||
|
||||
@ -136,7 +136,7 @@ module Redmine
|
||||
revision = nil
|
||||
parsing = nil
|
||||
io.each_line do |line|
|
||||
if /^----/.match?(line)
|
||||
if line.start_with?('----')
|
||||
revisions << revision if revision
|
||||
revision = Revision.new(:paths => [], :message => '')
|
||||
parsing = nil
|
||||
@ -151,7 +151,7 @@ module Redmine
|
||||
revision.scmid = $1.strip
|
||||
elsif line =~ /^timestamp: (.+)$/
|
||||
revision.time = Time.parse($1).localtime
|
||||
elsif /^ -----/.match?(line)
|
||||
elsif line.start_with?(' -----')
|
||||
# partial revisions
|
||||
parsing = nil unless parsing == 'message'
|
||||
elsif line =~ /^(message|added|modified|removed|renamed):/
|
||||
|
||||
@ -173,7 +173,7 @@ module Redmine
|
||||
file_state = nil
|
||||
branch_map = nil
|
||||
io.each_line() do |line|
|
||||
if state != "revision" && /^#{ENDLOG}/o.match?(line)
|
||||
if state != "revision" && line.start_with?(ENDLOG)
|
||||
commit_log = ""
|
||||
revision = nil
|
||||
state = "entry_start"
|
||||
@ -186,9 +186,9 @@ module Redmine
|
||||
logger.debug("Path #{entry_path} <=> Name #{entry_name}")
|
||||
elsif /^head: (.+)$/ =~ line
|
||||
entry_headRev = $1
|
||||
elsif /^symbolic names:/.match?(line)
|
||||
elsif line.start_with?('symbolic names:')
|
||||
state = "symbolic"
|
||||
elsif /^#{STARTLOG}/o.match?(line)
|
||||
elsif line.start_with?(STARTLOG)
|
||||
commit_log = ""
|
||||
state = "revision"
|
||||
end
|
||||
@ -201,15 +201,15 @@ module Redmine
|
||||
next
|
||||
end
|
||||
elsif state == "tags"
|
||||
if /^#{STARTLOG}/o.match?(line)
|
||||
if line.start_with?(STARTLOG)
|
||||
commit_log = ""
|
||||
state = "revision"
|
||||
elsif /^#{ENDLOG}/o.match?(line)
|
||||
elsif line.start_with?(ENDLOG)
|
||||
state = "head"
|
||||
end
|
||||
next
|
||||
elsif state == "revision"
|
||||
if /^#{ENDLOG}/o =~ line || /^#{STARTLOG}/o =~ line
|
||||
if line.start_with?(ENDLOG, STARTLOG)
|
||||
if revision
|
||||
revHelper = CvsRevisionHelper.new(revision)
|
||||
revBranch = "HEAD"
|
||||
@ -239,7 +239,7 @@ module Redmine
|
||||
end
|
||||
commit_log = ""
|
||||
revision = nil
|
||||
if /^#{ENDLOG}/o.match?(line)
|
||||
if line.start_with?(ENDLOG)
|
||||
state = "entry_start"
|
||||
end
|
||||
next
|
||||
@ -267,7 +267,7 @@ module Redmine
|
||||
# version.line_minus = 0
|
||||
# end
|
||||
else
|
||||
commit_log += line unless /^\*\*\* empty log message \*\*\*/.match?(line)
|
||||
commit_log += line unless line.start_with?('*** empty log message ***')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -299,7 +299,7 @@ module Redmine
|
||||
end
|
||||
|
||||
def target(path = '')
|
||||
base = /^\//.match?(path) ? root_url : url
|
||||
base = path.start_with?('/') ? root_url : url
|
||||
uri = "#{base}/#{path}"
|
||||
uri = Addressable::URI.encode(uri)
|
||||
shell_quote(uri.gsub(/[?<>\*]/, ''))
|
||||
|
||||
@ -537,7 +537,7 @@ class RedCloth3 < String
|
||||
# the regexp prevents wiki links with a | from being cut as cells
|
||||
row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/o) do |modifiers, cell|
|
||||
ctyp = 'd'
|
||||
ctyp = 'h' if modifiers && modifiers =~ /^_/
|
||||
ctyp = 'h' if modifiers&.start_with?('_')
|
||||
|
||||
catts = nil
|
||||
catts = pba( modifiers, 'td' ) if modifiers
|
||||
@ -637,7 +637,7 @@ class RedCloth3 < String
|
||||
end
|
||||
|
||||
def lT( text )
|
||||
/\#$/.match?(text) ? 'o' : 'u'
|
||||
text.end_with?('#') ? 'o' : 'u'
|
||||
end
|
||||
|
||||
def hard_break( text )
|
||||
@ -673,7 +673,7 @@ class RedCloth3 < String
|
||||
|
||||
block_applied = 0
|
||||
@rules.each do |rule_name|
|
||||
block_applied += 1 if rule_name.to_s.match /^block_/ and method(rule_name).call(blk)
|
||||
block_applied += 1 if rule_name.to_s.start_with?('block_') and method(rule_name).call(blk)
|
||||
end
|
||||
if block_applied.zero?
|
||||
if deep_code
|
||||
@ -909,7 +909,7 @@ class RedCloth3 < String
|
||||
|
||||
def refs( text )
|
||||
@rules.each do |rule_name|
|
||||
method( rule_name ).call( text ) if rule_name.to_s.match? /^refs_/
|
||||
method( rule_name ).call( text ) if rule_name.to_s.start_with?('refs_')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ namespace :locales do
|
||||
|
||||
missing_keys.each do |key|
|
||||
{key => en_strings[key]}.to_yaml.each_line do |line|
|
||||
next if line =~ /^---/ || line.empty?
|
||||
next if line.start_with?('---') || line.empty?
|
||||
puts " #{line}"
|
||||
lang << " #{line}"
|
||||
end
|
||||
@ -133,7 +133,7 @@ END_DESC
|
||||
File.open(path, 'a') do |file|
|
||||
adds.each do |kv|
|
||||
Hash[*kv].to_yaml.each_line do |line|
|
||||
file.puts " #{line}" unless (line =~ /^---/ || line.empty?)
|
||||
file.puts " #{line}" unless (line.start_with?('---') || line.empty?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user