Project

General

Profile

Actions

Defect #44440

open

Inconsistent scm_TYPE_path_regexp key: scm_name in Repository, registered adapter name elsewhere

Added by Takenori TAKAKI 2 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Resolution:
Affected version:

Description

Since r24864, an adapter without scm_TYPE_path_regexp in config/configuration.yml is shown as DISABLED and treated as unavailable. The key is built in two different ways:

  • lib/redmine/info.rb and app/views/settings/_repositories.html.erb use the registered adapter name: "scm_#{scm.to_s.downcase}_path_regexp"
  • Repository.scm_available and Repository#validate_repository_path use scm_name: "scm_#{scm_name.to_s.downcase}_path_regexp"

Bundled adapters are unaffected, because their scm_name downcases to their registered name (Repository::Cvs.scm_name is "CVS", registered as "Cvs"). The keys diverge when an adapter overrides scm_name with a different display label, as third-party adapters commonly do.

Steps to reproduce

For an adapter registered as CustomScm whose scm_name is "Custom SCM":

  1. Open "Administration > Information" with no key set. It reports DISABLED: scm_customscm_path_regexp missing in configuration.yml.
  2. Add scm_customscm_path_regexp to config/configuration.yml as instructed, and restart.
  3. Open "Administration > Settings > Repositories".

Actual behavior

Setting the key the message asked for changes nothing but the display. The "Path to repository" column now shows the configured regexp, and the information page reports it as an allowed path, but on the same row the adapter's checkbox is still disabled and it cannot be enabled.

Repository.scm_available looks up scm_custom scm_path_regexp (note the space) rather than the key named in the message. That lookup returns nil, so the adapter stays unavailable, Setting.enabled_scm drops it, and it is never offered when creating a repository. The spaced key cannot reasonably be written in configuration.yml either.

Repository#validate_repository_path reads the same spaced key, so for a repository of this type the regexp is never applied to the URL: the value is nil, regexp.present? is false, and the check is skipped.

Expected behavior

The key named in the DISABLED message is the one used for availability and validation, so that setting it makes the adapter selectable and applies the regexp to repository URLs.

Possible fix

Derive the key from the registered adapter name in Repository.scm_available and Repository#validate_repository_path as well, leaving scm_name as a display label. Key names for bundled adapters would be unchanged, so this is backward compatible and no existing configuration.yml needs to be edited.

No data to display

Actions

Also available in: Atom PDF