diff --git a/init.rb b/init.rb index 44a427ec9..a73bef031 100644 --- a/init.rb +++ b/init.rb @@ -66,6 +66,12 @@ # This *must stay after* Redmine::Plugin.register statement # because it needs to access to plugin settings... # so we need the plugin to be fully registered... -Rails.configuration.to_prepare do - require_dependency 'load_gitolite_hooks' -end +require_dependency 'load_gitolite_hooks' + +# Autoload Git Hosting Libs and Patches +RedmineGitHosting.load_plugin! + +# Redmine SCM adapter +require_dependency 'redmine/scm/adapters/xitolite_adapter' + +require 'hrack/bundle' diff --git a/lib/redmine_git_hosting.rb b/lib/redmine_git_hosting.rb index 29c566b4e..be9384420 100644 --- a/lib/redmine_git_hosting.rb +++ b/lib/redmine_git_hosting.rb @@ -56,14 +56,3 @@ def additionals_help_items admin: true }] end end - -# Set up autoload of patches -Rails.configuration.to_prepare do - # Redmine Git Hosting Libs and Patches - RedmineGitHosting.load_plugin! - - # Redmine SCM adapter - require_dependency 'redmine/scm/adapters/xitolite_adapter' - - require 'hrack/bundle' -end diff --git a/lib/redmine_git_hosting/commands.rb b/lib/redmine_git_hosting/commands.rb index 1e62620ac..78a0d3bca 100644 --- a/lib/redmine_git_hosting/commands.rb +++ b/lib/redmine_git_hosting/commands.rb @@ -2,10 +2,5 @@ module RedmineGitHosting module Commands - extend Commands::Base - extend Commands::Git - extend Commands::Gitolite - extend Commands::Ssh - extend Commands::Sudo end end diff --git a/lib/redmine_git_hosting/commands/base.rb b/lib/redmine_git_hosting/commands/base.rb index 2757a7cff..fcaff2c5f 100644 --- a/lib/redmine_git_hosting/commands/base.rb +++ b/lib/redmine_git_hosting/commands/base.rb @@ -25,5 +25,7 @@ def logger RedmineGitHosting.logger end end + + extend Commands::Base end end diff --git a/lib/redmine_git_hosting/commands/git.rb b/lib/redmine_git_hosting/commands/git.rb index bfcb167c4..9ec55c34c 100644 --- a/lib/redmine_git_hosting/commands/git.rb +++ b/lib/redmine_git_hosting/commands/git.rb @@ -120,5 +120,7 @@ def git_config_as_hash(namespace, params) value_hash end end + + extend Commands::Git end end diff --git a/lib/redmine_git_hosting/commands/gitolite.rb b/lib/redmine_git_hosting/commands/gitolite.rb index 30b69b6b2..ed1fab1bf 100644 --- a/lib/redmine_git_hosting/commands/gitolite.rb +++ b/lib/redmine_git_hosting/commands/gitolite.rb @@ -79,5 +79,7 @@ def gitolite_home_dir RedmineGitHosting::Config.gitolite_home_dir end end + + extend Commands::Gitolite end end diff --git a/lib/redmine_git_hosting/commands/ssh.rb b/lib/redmine_git_hosting/commands/ssh.rb index a4f3d3663..5864ec719 100644 --- a/lib/redmine_git_hosting/commands/ssh.rb +++ b/lib/redmine_git_hosting/commands/ssh.rb @@ -53,5 +53,7 @@ def ssh_shell_params ] end end + + extend Commands::Ssh end end diff --git a/lib/redmine_git_hosting/commands/sudo.rb b/lib/redmine_git_hosting/commands/sudo.rb index b6d090e87..c424f261b 100644 --- a/lib/redmine_git_hosting/commands/sudo.rb +++ b/lib/redmine_git_hosting/commands/sudo.rb @@ -205,5 +205,7 @@ def content_from_gitolite_side(destination_path) sudo_cat destination_path end end + + extend Commands::Sudo end end diff --git a/lib/redmine_git_hosting/config.rb b/lib/redmine_git_hosting/config.rb index 7375779ec..d55315559 100644 --- a/lib/redmine_git_hosting/config.rb +++ b/lib/redmine_git_hosting/config.rb @@ -7,17 +7,5 @@ module Config GITOLITE_DEFAULT_CONFIG_FILE = 'gitolite.conf' GITOLITE_IDENTIFIER_DEFAULT_PREFIX = 'redmine_' - - extend Config::Base - extend Config::GitoliteAccess - extend Config::GitoliteBase - extend Config::GitoliteCache - extend Config::GitoliteConfigTests - extend Config::GitoliteHooks - extend Config::GitoliteInfos - extend Config::GitoliteNotifications - extend Config::GitoliteStorage - extend Config::Mirroring - extend Config::RedmineConfig end end diff --git a/lib/redmine_git_hosting/config/base.rb b/lib/redmine_git_hosting/config/base.rb index 98ec7c653..0efbbe661 100644 --- a/lib/redmine_git_hosting/config/base.rb +++ b/lib/redmine_git_hosting/config/base.rb @@ -99,5 +99,7 @@ def file_logger RedmineGitHosting.logger end end + + extend Config::Base end end diff --git a/lib/redmine_git_hosting/config/gitolite_access.rb b/lib/redmine_git_hosting/config/gitolite_access.rb index 705d2aba0..1ac50c136 100644 --- a/lib/redmine_git_hosting/config/gitolite_access.rb +++ b/lib/redmine_git_hosting/config/gitolite_access.rb @@ -57,5 +57,7 @@ def my_root_url(ssl: true) File.join(server_domain[%r{^[^/]*}], redmine_root_url, '/')[0..-2] end end + + extend Config::GitoliteAccess end end diff --git a/lib/redmine_git_hosting/config/gitolite_base.rb b/lib/redmine_git_hosting/config/gitolite_base.rb index 355395eec..cf25ef6bd 100644 --- a/lib/redmine_git_hosting/config/gitolite_base.rb +++ b/lib/redmine_git_hosting/config/gitolite_base.rb @@ -111,5 +111,7 @@ def gitolite_log_level get_setting :gitolite_log_level end end + + extend Config::GitoliteBase end end diff --git a/lib/redmine_git_hosting/config/gitolite_cache.rb b/lib/redmine_git_hosting/config/gitolite_cache.rb index 5215243ad..2971388e9 100644 --- a/lib/redmine_git_hosting/config/gitolite_cache.rb +++ b/lib/redmine_git_hosting/config/gitolite_cache.rb @@ -21,5 +21,7 @@ def gitolite_cache_adapter get_setting :gitolite_cache_adapter end end + + extend Config::GitoliteCache end end diff --git a/lib/redmine_git_hosting/config/gitolite_config_tests.rb b/lib/redmine_git_hosting/config/gitolite_config_tests.rb index ec17ea422..62fb5ac5a 100644 --- a/lib/redmine_git_hosting/config/gitolite_config_tests.rb +++ b/lib/redmine_git_hosting/config/gitolite_config_tests.rb @@ -84,5 +84,7 @@ def execute_sudo_test(user, &block) /#{user}/.match?(test) end end + + extend Config::GitoliteConfigTests end end diff --git a/lib/redmine_git_hosting/config/gitolite_hooks.rb b/lib/redmine_git_hosting/config/gitolite_hooks.rb index f6b30262d..d75695384 100644 --- a/lib/redmine_git_hosting/config/gitolite_hooks.rb +++ b/lib/redmine_git_hosting/config/gitolite_hooks.rb @@ -57,5 +57,7 @@ def update_hook_params! RedmineGitHosting::GitoliteParams::GlobalParams.new.install! end end + + extend Config::GitoliteHooks end end diff --git a/lib/redmine_git_hosting/config/gitolite_infos.rb b/lib/redmine_git_hosting/config/gitolite_infos.rb index 29c3fd4c9..c4d6394d5 100644 --- a/lib/redmine_git_hosting/config/gitolite_infos.rb +++ b/lib/redmine_git_hosting/config/gitolite_infos.rb @@ -72,5 +72,7 @@ def gitolite_repository_count end end end + + extend Config::GitoliteInfos end end diff --git a/lib/redmine_git_hosting/config/gitolite_notifications.rb b/lib/redmine_git_hosting/config/gitolite_notifications.rb index 42d0b360f..9c6aebcef 100644 --- a/lib/redmine_git_hosting/config/gitolite_notifications.rb +++ b/lib/redmine_git_hosting/config/gitolite_notifications.rb @@ -21,5 +21,7 @@ def gitolite_notify_global_exclude get_setting :gitolite_notify_global_exclude end end + + extend Config::GitoliteNotifications end end diff --git a/lib/redmine_git_hosting/config/gitolite_storage.rb b/lib/redmine_git_hosting/config/gitolite_storage.rb index 77d51f1d3..d775811c9 100644 --- a/lib/redmine_git_hosting/config/gitolite_storage.rb +++ b/lib/redmine_git_hosting/config/gitolite_storage.rb @@ -23,5 +23,7 @@ def recycle_bin_dir nil end end + + extend Config::GitoliteStorage end end diff --git a/lib/redmine_git_hosting/config/mirroring.rb b/lib/redmine_git_hosting/config/mirroring.rb index e10980eab..c03c82313 100644 --- a/lib/redmine_git_hosting/config/mirroring.rb +++ b/lib/redmine_git_hosting/config/mirroring.rb @@ -19,5 +19,7 @@ def gitolite_mirroring_script File.join gitolite_home_dir, '.ssh', 'run_gitolite_admin_ssh' end end + + extend Config::Mirroring end end diff --git a/lib/redmine_git_hosting/config/redmine_config.rb b/lib/redmine_git_hosting/config/redmine_config.rb index 770c56d9a..f3e32d4fe 100644 --- a/lib/redmine_git_hosting/config/redmine_config.rb +++ b/lib/redmine_git_hosting/config/redmine_config.rb @@ -49,5 +49,7 @@ def gitolite_recycle_bin_expiration_time (get_setting(:gitolite_recycle_bin_expiration_time).to_f * 60).to_i end end + + extend Config::RedmineConfig end end diff --git a/spec/models/gitolite_public_key_spec.rb b/spec/models/gitolite_public_key_spec.rb index aeb0172ad..3c7d102df 100644 --- a/spec/models/gitolite_public_key_spec.rb +++ b/spec/models/gitolite_public_key_spec.rb @@ -32,7 +32,7 @@ # There is an isolation issue in tests. # Try to workaround it... def test_user - 'redmine_git_user1_12' + 'redmine_git_user1_13' end describe 'Valid SSH key build' do diff --git a/spec/support/global_helpers.rb b/spec/support/global_helpers.rb index 2f5627ac3..f262c3bc6 100644 --- a/spec/support/global_helpers.rb +++ b/spec/support/global_helpers.rb @@ -84,7 +84,12 @@ def create_svn_repository(**opts) end def load_yaml_fixture(fixture) - YAML.load load_fixture(fixture) # rubocop: disable Security/YAMLLoad + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + YAML.load load_fixture(fixture), # rubocop: disable Security/YAMLLoad + permitted_classes: [Symbol, Time] + else + YAML.load load_fixture(fixture) # rubocop: disable Security/YAMLLoad + end end def load_fixture(fixture)