Project

General

Profile

Actions

Defect #44440

closed

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

Added by Takenori TAKAKI about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Category:
SCM
Target version:
-
Resolution:
Fixed
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.


Files

unify-scm-path-regexp.patch (3.51 KB) unify-scm-path-regexp.patch Takenori TAKAKI, 2026-09-15 08:20
Actions #1

Updated by Takenori TAKAKI about 1 month ago

The attached patch fixes this by deriving the scm_TYPE_path_regexp configuration key from the repository class name (name.demodulize), which corresponds to the adapter's registered identifier, rather than from the overridable scm_name display label.

Repository.scm_available and Repository#validate_repository_path previously built this key directly from scm_name. They now call a new Repository.scm_path_regexp class method. The other two call sites, lib/redmine/info.rb and app/views/settings/_repositories.html.erb, also use this method, centralizing the lookup. Configuration keys for the bundled adapters remain unchanged.

Actions #2

Updated by Go MAEDA about 1 month ago

  • Target version set to 7.1.0

Setting the target version to 7.1.0.

Actions #4

Updated by Go MAEDA about 1 month ago

  • Category set to SCM
Actions #5

Updated by Marius BĂLTEANU about 1 month ago

  • Assignee set to Holger Just

Looks good to me. Holger Just, can you take a look, please?

Actions #6

Updated by Holger Just about 1 month ago

  • Assignee changed from Holger Just to Marius BĂLTEANU

Looks good to me, too. Thanks!

Actions #7

Updated by Marius BĂLTEANU about 1 month ago

  • Status changed from New to Closed
  • Target version deleted (7.1.0)
  • Resolution set to Fixed
Actions #8

Updated by Marius BĂLTEANU about 1 month ago

Committed the fix, thanks!

Actions

Also available in: Atom PDF