summaryrefslogtreecommitdiffstats
path: root/lib/redmine/scm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/redmine/scm')
-rw-r--r--lib/redmine/scm/adapters/abstract_adapter.rb7
-rw-r--r--lib/redmine/scm/adapters/bazaar_adapter.rb4
-rw-r--r--lib/redmine/scm/adapters/cvs_adapter.rb14
-rw-r--r--lib/redmine/scm/adapters/filesystem_adapter.rb2
-rw-r--r--lib/redmine/scm/adapters/git_adapter.rb6
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb2
-rw-r--r--lib/redmine/scm/adapters/subversion_adapter.rb18
7 files changed, 27 insertions, 26 deletions
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index 7665b0d84..55753d27e 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
@@ -214,7 +214,7 @@ module Redmine
path = Redmine::Configuration['scm_stderr_log_file'].presence
path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
if File.exists?(path)
- if File.file?(path) && File.writable?(path)
+ if File.file?(path) && File.writable?(path)
writable = true
else
logger.warn("SCM log file (#{path}) is not writable")
@@ -276,8 +276,9 @@ module Redmine
end
def scm_iconv(to, from, str)
- return nil if str.nil?
+ return if str.nil?
return str if to == from && str.encoding.to_s == from
+ str = str.dup
str.force_encoding(from)
begin
str.encode(to)
diff --git a/lib/redmine/scm/adapters/bazaar_adapter.rb b/lib/redmine/scm/adapters/bazaar_adapter.rb
index 2c5996b34..af48a9d0f 100644
--- a/lib/redmine/scm/adapters/bazaar_adapter.rb
+++ b/lib/redmine/scm/adapters/bazaar_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
@@ -154,7 +154,7 @@ module Redmine
parsing = $1
elsif line =~ /^ (.*)$/
if parsing == 'message'
- revision.message << "#{$1}\n"
+ revision.message += "#{$1}\n"
else
if $1 =~ /^(.*)\s+(\S+)$/
path_locale = $1.strip
diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb
index 730ee5caa..c45987f33 100644
--- a/lib/redmine/scm/adapters/cvs_adapter.rb
+++ b/lib/redmine/scm/adapters/cvs_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
@@ -93,7 +93,7 @@ module Redmine
def entries(path=nil, identifier=nil, options={})
logger.debug "<cvs> entries '#{path}' with identifier '#{identifier}'"
path_locale = scm_iconv(@path_encoding, 'UTF-8', path)
- path_locale.force_encoding("ASCII-8BIT")
+ path_locale = path_locale.dup.force_encoding("ASCII-8BIT")
entries = Entries.new
cmd_args = %w|-q rls -e|
cmd_args << "-D" << time_to_cvstime_rlog(identifier) if identifier
@@ -161,7 +161,7 @@ module Redmine
cmd_args << path_with_project_utf8
scm_cmd(*cmd_args) do |io|
state = "entry_start"
- commit_log = String.new
+ commit_log = ""
revision = nil
date = nil
author = nil
@@ -171,7 +171,7 @@ module Redmine
branch_map = nil
io.each_line() do |line|
if state != "revision" && /^#{ENDLOG}/ =~ line
- commit_log = String.new
+ commit_log = ""
revision = nil
state = "entry_start"
end
@@ -186,7 +186,7 @@ module Redmine
elsif /^symbolic names:/ =~ line
state = "symbolic" #unless entry.nil?
elsif /^#{STARTLOG}/ =~ line
- commit_log = String.new
+ commit_log = ""
state = "revision"
end
next
@@ -230,7 +230,7 @@ module Redmine
}]
})
end
- commit_log = String.new
+ commit_log = ""
revision = nil
if /^#{ENDLOG}/ =~ line
state = "entry_start"
@@ -261,7 +261,7 @@ module Redmine
# version.line_minus = 0
# end
else
- commit_log << line unless line =~ /^\*\*\* empty log message \*\*\*/
+ commit_log += line unless line =~ /^\*\*\* empty log message \*\*\*/
end
end
end
diff --git a/lib/redmine/scm/adapters/filesystem_adapter.rb b/lib/redmine/scm/adapters/filesystem_adapter.rb
index 0ff289df4..4335244be 100644
--- a/lib/redmine/scm/adapters/filesystem_adapter.rb
+++ b/lib/redmine/scm/adapters/filesystem_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 3a9103360..1889dcda6 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
@@ -203,7 +203,7 @@ module Redmine
cmd_args << "--" << scm_iconv(@path_encoding, 'UTF-8', path) if path && !path.empty?
revisions = []
if identifier_from || identifier_to
- revisions << ""
+ revisions << +""
revisions[0] << "#{identifier_from}.." if identifier_from
revisions[0] << "#{identifier_to}" if identifier_to
else
@@ -261,7 +261,7 @@ module Redmine
end
elsif (parsing_descr == 0) && line.chomp.to_s == ""
parsing_descr = 1
- changeset[:description] = ""
+ changeset[:description] = +""
elsif (parsing_descr == 1 || parsing_descr == 2) \
&& line =~ /^:\d+\s+\d+\s+[0-9a-f.]+\s+[0-9a-f.]+\s+(\w)\t(.+)$/
parsing_descr = 2
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb
index 32637b2f1..fceebf035 100644
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb
index 79276feb6..ad99217c3 100644
--- a/lib/redmine/scm/adapters/subversion_adapter.rb
+++ b/lib/redmine/scm/adapters/subversion_adapter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
@@ -61,7 +61,7 @@ module Redmine
# Get info about the svn repository
def info
- cmd = "#{self.class.sq_bin} info --xml #{target}"
+ cmd = +"#{self.class.sq_bin} info --xml #{target}"
cmd << credentials_string
info = nil
shellout(cmd) do |io|
@@ -91,7 +91,7 @@ module Redmine
path ||= ''
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
entries = Entries.new
- cmd = "#{self.class.sq_bin} list --xml #{target(path)}@#{identifier}"
+ cmd = +"#{self.class.sq_bin} list --xml #{target(path)}@#{identifier}"
cmd << credentials_string
shellout(cmd) do |io|
output = io.read.force_encoding('UTF-8')
@@ -130,7 +130,7 @@ module Redmine
return nil unless self.class.client_version_above?([1, 5, 0])
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
- cmd = "#{self.class.sq_bin} proplist --verbose --xml #{target(path)}@#{identifier}"
+ cmd = +"#{self.class.sq_bin} proplist --verbose --xml #{target(path)}@#{identifier}"
cmd << credentials_string
properties = {}
shellout(cmd) do |io|
@@ -152,7 +152,7 @@ module Redmine
identifier_from = (identifier_from && identifier_from.to_i > 0) ? identifier_from.to_i : "HEAD"
identifier_to = (identifier_to && identifier_to.to_i > 0) ? identifier_to.to_i : 1
revisions = Revisions.new
- cmd = "#{self.class.sq_bin} log --xml -r #{identifier_from}:#{identifier_to}"
+ cmd = +"#{self.class.sq_bin} log --xml -r #{identifier_from}:#{identifier_to}"
cmd << credentials_string
cmd << " --verbose " if options[:with_paths]
cmd << " --limit #{options[:limit].to_i}" if options[:limit]
@@ -192,7 +192,7 @@ module Redmine
identifier_to = (identifier_to and identifier_to.to_i > 0) ? identifier_to.to_i : (identifier_from.to_i - 1)
- cmd = "#{self.class.sq_bin} diff -r "
+ cmd = +"#{self.class.sq_bin} diff -r "
cmd << "#{identifier_to}:"
cmd << "#{identifier_from}"
cmd << " #{target(path)}@#{identifier_from}"
@@ -209,7 +209,7 @@ module Redmine
def cat(path, identifier=nil)
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
- cmd = "#{self.class.sq_bin} cat #{target(path)}@#{identifier}"
+ cmd = +"#{self.class.sq_bin} cat #{target(path)}@#{identifier}"
cmd << credentials_string
cat = nil
shellout(cmd) do |io|
@@ -222,7 +222,7 @@ module Redmine
def annotate(path, identifier=nil)
identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
- cmd = "#{self.class.sq_bin} blame #{target(path)}@#{identifier}"
+ cmd = +"#{self.class.sq_bin} blame #{target(path)}@#{identifier}"
cmd << credentials_string
blame = Annotate.new
shellout(cmd) do |io|
@@ -244,7 +244,7 @@ module Redmine
private
def credentials_string
- str = ''
+ str = +''
str << " --username #{shell_quote(@login)}" unless @login.blank?
str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank?
str << " --no-auth-cache --non-interactive"