Defect #44440 ยป unify-scm-path-regexp.patch
| app/models/repository.rb | ||
|---|---|---|
|
end
|
||
|
def self.scm_available
|
||
|
scm_client_available && Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"].present?
|
||
|
scm_client_available && scm_path_regexp.present?
|
||
|
end
|
||
|
def self.scm_path_regexp
|
||
|
# Uses name.demodulize, not scm_name, which each adapter overrides as its display label.
|
||
|
Redmine::Configuration["scm_#{name.demodulize.downcase}_path_regexp"]
|
||
|
end
|
||
|
def set_as_default?
|
||
| ... | ... | |
|
# Validates repository url based against an optional regular expression
|
||
|
# that can be set in the Redmine configuration file.
|
||
|
def validate_repository_path(attribute=:url)
|
||
|
regexp = Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"]
|
||
|
regexp = self.class.scm_path_regexp
|
||
|
if changes[attribute] && regexp.present?
|
||
|
regexp = regexp.to_s.strip.gsub('%project%') {Regexp.escape(project.try(:identifier).to_s)}
|
||
|
unless Regexp.new("\\A#{regexp}\\z").match?(send(attribute).to_s)
|
||
| app/views/settings/_repositories.html.erb | ||
|---|---|---|
|
<% text, value = (choice.is_a?(Array) ? choice : [choice, choice]) %>
|
||
|
<% setting = :enabled_scm %>
|
||
|
<% enabled = Setting.send(setting).include?(value) %>
|
||
|
<% path_regexp = Redmine::Configuration["scm_#{choice.to_s.downcase}_path_regexp"].presence %>
|
||
|
<% path_regexp = scm_class.scm_path_regexp.presence %>
|
||
|
<tr>
|
||
|
<td class="scm_name">
|
||
|
<label>
|
||
| lib/redmine/info.rb | ||
|---|---|---|
|
s << "SCM:\n"
|
||
|
Redmine::Scm::Base.all.each do |scm|
|
||
|
scm_class = "Repository::#{scm}".constantize
|
||
|
config = "scm_#{scm.to_s.downcase}_path_regexp"
|
||
|
if scm_class.scm_client_available
|
||
|
paths = if Redmine::Configuration[config].present?
|
||
|
"Allowed Paths: #{Redmine::Configuration[config]}"
|
||
|
paths = if scm_class.scm_path_regexp.present?
|
||
|
"Allowed Paths: #{scm_class.scm_path_regexp}"
|
||
|
else
|
||
|
"DISABLED: scm_#{scm.to_s.downcase}_path_regexp missing in configuration.yml"
|
||
|
end
|
||
| test/unit/repository_test.rb | ||
|---|---|---|
|
assert_nil Repository.factory('Serializer')
|
||
|
assert_nil Repository.factory('Query')
|
||
|
end
|
||
|
def test_scm_path_regexp_should_use_registered_scm_name
|
||
|
Redmine::Configuration.with 'scm_subversion_path_regexp' => '/svn/.*' do
|
||
|
assert_equal '/svn/.*', Repository::Subversion.scm_path_regexp
|
||
|
end
|
||
|
end
|
||
|
def test_scm_path_regexp_should_use_registered_scm_name_even_if_scm_name_is_overridden
|
||
|
Repository::Subversion.stubs(:scm_name).returns('Custom SCM Label')
|
||
|
Redmine::Configuration.with 'scm_subversion_path_regexp' => '/svn/.*' do
|
||
|
assert_equal '/svn/.*', Repository::Subversion.scm_path_regexp
|
||
|
end
|
||
|
end
|
||
|
end
|
||