diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3315ceda..c0e7ee59d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,8 +11,8 @@ jobs: strategy: matrix: - ruby: ['2.7', '3.0', '3.1'] - redmine: ['5.0-stable', 'master'] + ruby: ['3.2', '3.3'] + redmine: ['6.0-stable', 'master'] db: ['postgres', 'mysql'] fail-fast: false @@ -71,10 +71,7 @@ jobs: - name: Checkout redmine_sidekiq uses: actions/checkout@v3 with: - # TODO Switch back to the original repo, once https://github.com/ogom/redmine_sidekiq/pull/16 is released - # repository: ogom/redmine_sidekiq - repository: dosyfier/redmine_sidekiq - ref: fix-rails-6 + repository: ogom/redmine_sidekiq path: redmine/plugins/redmine_sidekiq - name: Checkout gitolite @@ -121,7 +118,9 @@ jobs: run: | sudo useradd --create-home git sudo -n -u git -i mkdir bin - sudo -n -u git -i $GITHUB_WORKSPACE/gitolite/install -to /home/git/bin + sudo cp -r $GITHUB_WORKSPACE/gitolite /home/git/ + sudo chown -R git:git /home/git/gitolite + sudo -n -u git -i perl /home/git/gitolite/install -to /home/git/bin sudo cp plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa.pub /home/git/ sudo chown git.git /home/git/redmine_gitolite_admin_id_rsa.pub sudo -n -u git -i bin/gitolite setup -pk redmine_gitolite_admin_id_rsa.pub diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e765c5d4..e392a48aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 7.0.0 - TBD + +### Added + +- Support for Redmine 6.0 + +### Changed + +- Update all models to inherit from ApplicationRecord instead of ActiveRecord::Base +- Fix serialize syntax for Rails 7 compatibility using `type:` parameter +- Update minimum Ruby version requirement to 3.0+ + +### BREAKING CHANGE + +- Redmine 6.0+ is required +- Ruby 3.0+ is required +- Removed support for Redmine 5.x + ## 6.0.1 - 2022-11-04 ### Changed diff --git a/app/models/repository_git_extra.rb b/app/models/repository_git_extra.rb index fe6e3a37c..202c2c492 100644 --- a/app/models/repository_git_extra.rb +++ b/app/models/repository_git_extra.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -class RepositoryGitExtra < ActiveRecord::Base +class RepositoryGitExtra < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base) include Redmine::SafeAttributes + include Redmine::I18n SMART_HTTP_OPTIONS = [[l(:label_disabled), '0'], [l(:label_http_only), '3'], @@ -33,7 +34,7 @@ class RepositoryGitExtra < ActiveRecord::Base validate :validate_urls_order ## Serializations - serialize :urls_order, Array + serialize :urls_order, type: Array ## Callbacks before_save :check_urls_order_consistency diff --git a/app/models/repository_post_receive_url.rb b/app/models/repository_post_receive_url.rb index 8bfb858dc..5daad69b9 100644 --- a/app/models/repository_post_receive_url.rb +++ b/app/models/repository_post_receive_url.rb @@ -22,7 +22,7 @@ class RepositoryPostReceiveUrl < ActiveRecord::Base validates :mode, presence: true, inclusion: { in: %i[github get post] } ## Serializations - serialize :triggers, Array + serialize :triggers, type: Array ## Scopes scope :active, -> { where active: true } diff --git a/app/models/repository_protected_branche.rb b/app/models/repository_protected_branche.rb index f95911266..ea0e47594 100644 --- a/app/models/repository_protected_branche.rb +++ b/app/models/repository_protected_branche.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RepositoryProtectedBranche < ActiveRecord::Base +class RepositoryProtectedBranche < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base) include Redmine::SafeAttributes VALID_PERMS = ['RW+', 'RW', 'R', '-'].freeze DEFAULT_PERM = 'RW+' diff --git a/db/migrate/20150823030100_migrate_protected_branches_users.rb b/db/migrate/20150823030100_migrate_protected_branches_users.rb index 9c1b60c54..1315ce46d 100644 --- a/db/migrate/20150823030100_migrate_protected_branches_users.rb +++ b/db/migrate/20150823030100_migrate_protected_branches_users.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class RepositoryProtectedBrancheWrapped < RepositoryProtectedBranche - serialize :user_list, Array + serialize :user_list, type: Array end class MigrateProtectedBranchesUsers < ActiveRecord::Migration[4.2] diff --git a/init.rb b/init.rb index bc3ba946d..3c2633639 100644 --- a/init.rb +++ b/init.rb @@ -11,7 +11,7 @@ author_url 'settings/plugin/redmine_git_hosting/authors' settings partial: 'settings/redmine_git_hosting', default: RedmineGitHosting.settings - requires_redmine version_or_higher: '4.1.0' + requires_redmine version_or_higher: '6.0.0' permission :create_gitolite_ssh_key, gitolite_public_keys: %i[index create destroy], require: :loggedin diff --git a/lib/redmine_git_hosting.rb b/lib/redmine_git_hosting.rb index 63ba515e7..670b01666 100644 --- a/lib/redmine_git_hosting.rb +++ b/lib/redmine_git_hosting.rb @@ -6,7 +6,7 @@ module RedmineGitHosting extend self - VERSION = '6.0.1' + VERSION = '7.0.0' # Load RedminePluginLoader extend RedminePluginLoader diff --git a/lib/redmine_git_hosting/redcarpet_filter.rb b/lib/redmine_git_hosting/redcarpet_filter.rb index c49c5e48a..cd3ddf5bf 100644 --- a/lib/redmine_git_hosting/redcarpet_filter.rb +++ b/lib/redmine_git_hosting/redcarpet_filter.rb @@ -2,46 +2,35 @@ require 'html/pipeline/filter' require 'html/pipeline/text_filter' -require 'redcarpet' -require 'rouge' -require 'rouge/plugins/redcarpet' module RedmineGitHosting - class HTMLwithRouge < Redcarpet::Render::HTML - include Rouge::Plugins::Redcarpet - end - class RedcarpetFilter < HTML::Pipeline::TextFilter def initialize(text, context = nil, result = nil) super text, context, result @text = @text.delete "\r" end - # Convert Markdown to HTML using the best available implementation - # and convert into a DocumentFragment. + # Convert Markdown to HTML using Redmine's WikiFormatting system + # for consistency with Redmine's text formatting configuration. # def call - html = self.class.renderer.render @text + html = markdown_formatter.new(@text).to_html html.rstrip! html end - def self.renderer - @renderer ||= Redcarpet::Markdown.new HTMLwithRouge, markdown_options - end + private - def self.markdown_options - @markdown_options ||= { - fenced_code_blocks: true, - lax_spacing: true, - strikethrough: true, - autolink: true, - tables: true, - underline: true, - highlight: true - }.freeze + def markdown_formatter + # Find the markdown formatter from Redmine's WikiFormatting system + formatter_name = Redmine::WikiFormatting.format_names.find { |name| name =~ /markdown/i } + + if formatter_name + Redmine::WikiFormatting.formatter_for(formatter_name) + else + # Fallback to textile formatter if no markdown formatter is available + Redmine::WikiFormatting.formatter_for('textile') + end end - - private_class_method :markdown_options end end