Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ jobs:
- name: Checkout redmine_sidekiq
uses: actions/checkout@v2
with:
repository: ogom/redmine_sidekiq
# TODO Switch back to the original repo, once the "fix-rails-6" PR gets accepted
# repository: ogom/redmine_sidekiq
repository: dosyfier/redmine_sidekiq
ref: fix-rails-6
path: redmine/plugins/redmine_sidekiq

- name: Checkout gitolite
Expand All @@ -93,6 +96,7 @@ jobs:
libmysqlclient-dev
libssh2-1
libssh2-1-dev
pkg-config
subversion

- name: Setup Ruby
Expand Down Expand Up @@ -125,6 +129,7 @@ jobs:
working-directory: redmine
run: |
bundle config set --local without 'development'
bundle config build.rugged --with-ssh
bundle install --jobs=4 --retry=3

- name: Run Redmine rake tasks
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

# Gitolite Admin repository management
gem 'gitolite-rugged', git: 'https://github.com/jbox-web/gitolite-rugged.git', tag: '1.4.0'
gem 'gitolite-rugged', git: 'https://github.com/dosyfier/gitolite-rugged.git', branch: 'fix-redmine-5'

# Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 2.0.0', git: 'https://github.com/jbox-web/grack.git', require: 'grack', branch: 'fix_gemfile'
Expand Down
5 changes: 5 additions & 0 deletions app/overrides/repositories/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
insert_before: 'erb[loud]:contains("label_statistics")',
original: '88f120e99075ba3246901c6e970ca671d7166855',
text: '<%= call_hook(:view_repositories_navigation, repository: @repository) %>'

module Repositories
module Navigation
end
end
5 changes: 5 additions & 0 deletions app/overrides/repositories/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@
insert_before: 'erb[silent]:contains("html_title")',
original: '2a0a09659d76066b896016c72527d479c69463ec',
partial: 'hooks/show_repositories_sidebar'

module Repositories
module Show
end
end
2 changes: 1 addition & 1 deletion contrib/hooks/post-receive/lib/git_hosting_http_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module GitHosting
module HttpHelper
def http_post(url, opts = {}, &block)
http, request = build_post_request url, opts
http, request = build_post_request url, **opts
send_http_request http, request, &block
end

Expand Down
1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"

Redmine::Plugin.register :redmine_git_hosting do
name 'Redmine Git Hosting Plugin'
Expand Down
1 change: 0 additions & 1 deletion lib/hrack/lib/hrack/bundle.rb → lib/hrack/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'rack/builder'
require 'rack/parser'
require 'hrack/server'

module Hrack
module Bundle
Expand Down
4 changes: 0 additions & 4 deletions lib/hrack/init.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/hrack/lib/hrack.rb

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions lib/hrack/lib/hrack/version.rb → lib/hrack/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Hrack
module Version
end
VERSION = '1.0.0'
end
3 changes: 3 additions & 0 deletions lib/load_gitolite_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@
].each do |file|
require_dependency file if File.exist? file
end

module LoadGitoliteHooks
end
2 changes: 1 addition & 1 deletion lib/redmine/scm/adapters/xitolite_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def lastrev(path, rev)
nil
end

def revisions(path, identifier_from, identifier_to, **options)
def revisions(path, identifier_from, identifier_to, options={})
revs = Revisions.new
cmd_args = %w[log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin]
cmd_args << '--no-renames' if self.class.client_version_above? [2, 9]
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_git_hosting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ def additionals_help_items
# Redmine SCM adapter
require_dependency 'redmine/scm/adapters/xitolite_adapter'

require 'hrack/init'
require 'hrack/bundle'
end
2 changes: 1 addition & 1 deletion lib/redmine_git_hosting/cache/abstract_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def time_limit
def valid_cache_entry?(cached_entry_date)
return true if max_cache_time.to_i.negative? # No expiration needed

current_time = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Timezone.now
current_time = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.zone.now
expired = current_time.to_i - cached_entry_date.to_i > max_cache_time
!expired
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_git_hosting/console_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ConsoleLogger

def title(message)
info "\n * #{message}:"
yield if block
yield if block_given?
info " Done!\n\n"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def gitolite_repo_path

attr_reader :force

def initialize(*args)
super
@force = options.delete(:force) { false }
@old_perms = options.delete(:old_perms) { {} }
def initialize(gitolite_config, repository, context, **options)
super(gitolite_config, repository, context, **options)
@force = @options.delete(:force) { false }
@old_perms = @options.delete(:old_perms) { {} }
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/redmine_git_hosting/gitolite_wrappers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ def gitolite_admin_repo_commit(message = '')
end

def create_gitolite_repository(repository)
GitoliteHandlers::Repositories::AddRepository.call gitolite_config, repository, context, options
GitoliteHandlers::Repositories::AddRepository.call gitolite_config, repository, context, **options
end

def update_gitolite_repository(repository)
GitoliteHandlers::Repositories::UpdateRepository.call gitolite_config, repository, context, options
GitoliteHandlers::Repositories::UpdateRepository.call gitolite_config, repository, context, **options
end

def delete_gitolite_repository(repository)
GitoliteHandlers::Repositories::DeleteRepository.call gitolite_config, repository, context, options
GitoliteHandlers::Repositories::DeleteRepository.call gitolite_config, repository, context, **options
end

def move_gitolite_repository(repository)
GitoliteHandlers::Repositories::MoveRepository.call gitolite_config, repository, context, options
GitoliteHandlers::Repositories::MoveRepository.call gitolite_config, repository, context, **options
end

def create_gitolite_key(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_repository
logger.info 'Execute Gitolite Plugins'

# Create README file or initialize GitAnnex
RedmineGitHosting::Plugins.execute :post_create, repository, options.merge(recovered: @recovered)
RedmineGitHosting::Plugins.execute :post_create, repository, **options.merge(recovered: @recovered)

# Fetch changeset
repository.fetch_changesets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def update_repository
logger.info 'Execute Gitolite Plugins'

# Delete Git Config Keys
RedmineGitHosting::Plugins.execute :post_update, repository, options
RedmineGitHosting::Plugins.execute :post_update, repository, **options

# Fetch changeset
repository.fetch_changesets
Expand Down
104 changes: 53 additions & 51 deletions lib/redmine_git_hosting/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,72 @@
require 'github/markup'

module RedmineGitHosting
class GitHostingHookListener < Redmine::Hook::ViewListener
render_on :view_repository_edit_top, partial: 'repositories/edit_top'
render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
render_on :view_repository_edit_bottom, partial: 'repositories/edit_bottom'
render_on :view_repositories_show_sidebar, partial: 'repositories/git_hosting_sidebar'
render_on :view_repositories_navigation, partial: 'repositories/git_hosting_navigation'
render_on :view_layouts_base_html_head, partial: 'common/git_hosting_html_head'

def view_my_account_contextual(context)
user = context[:user]
link_to(l(:label_my_public_keys), public_keys_path, class: 'icon icon-passwd') if user.allowed_to_create_ssh_keys?
end
module Hooks
class GitHostingHookListener < Redmine::Hook::ViewListener
render_on :view_repository_edit_top, partial: 'repositories/edit_top'
render_on :view_repositories_show_contextual, partial: 'repositories/show_top'
render_on :view_repository_edit_bottom, partial: 'repositories/edit_bottom'
render_on :view_repositories_show_sidebar, partial: 'repositories/git_hosting_sidebar'
render_on :view_repositories_navigation, partial: 'repositories/git_hosting_navigation'
render_on :view_layouts_base_html_head, partial: 'common/git_hosting_html_head'

def view_my_account_contextual(context)
user = context[:user]
link_to(l(:label_my_public_keys), public_keys_path, class: 'icon icon-passwd') if user.allowed_to_create_ssh_keys?
end

def self.default_url_options
{ script_name: Redmine::Utils.relative_url_root }
end
def self.default_url_options
{ script_name: Redmine::Utils.relative_url_root }
end

def view_repositories_show_bottom(context)
path = get_path context
rev = get_rev context
repository = context[:repository]
readme_file = find_readme_file repository, path, rev
def view_repositories_show_bottom(context)
path = get_path context
rev = get_rev context
repository = context[:repository]
readme_file = find_readme_file repository, path, rev

return '' if readme_file.nil?
return '' if readme_file.nil?

content = get_formatted_text repository, readme_file, rev
content = get_formatted_text repository, readme_file, rev

context[:controller].send :render_to_string, partial: 'repositories/readme', locals: { html: content }
end

private
context[:controller].send :render_to_string, partial: 'repositories/readme', locals: { html: content }
end

def get_path(context)
context[:request].params['path'] || ''
end
private

def get_rev(context)
rev = context[:request].params['rev']
rev.presence
end
def get_path(context)
context[:request].params['path'] || ''
end

def find_readme_file(repository, path, rev)
(repository.entries(path, rev) || []).find { |f| f.name =~ /README((\.).*)?/i }
end
def get_rev(context)
rev = context[:request].params['rev']
rev.presence
end

def get_formatted_text(repository, file, rev)
raw_readme_text = Redmine::CodesetUtil.to_utf8_by_setting repository.cat(file.path, rev)
def find_readme_file(repository, path, rev)
(repository.entries(path, rev) || []).find { |f| f.name =~ /README((\.).*)?/i }
end

if redmine_file? file
formatter_name = Redmine::WikiFormatting.format_names.find { |name| name =~ /markdown/i }
Redmine::WikiFormatting.formatter_for(formatter_name).new(raw_readme_text).to_html
elsif github_file? file
RedmineGitHosting::MarkdownRenderer.to_html raw_readme_text
else
GitHub::Markup.render(file.path, raw_readme_text).gsub("\n", '<br/>')
def get_formatted_text(repository, file, rev)
raw_readme_text = Redmine::CodesetUtil.to_utf8_by_setting repository.cat(file.path, rev)

if redmine_file? file
formatter_name = Redmine::WikiFormatting.format_names.find { |name| name =~ /markdown/i }
Redmine::WikiFormatting.formatter_for(formatter_name).new(raw_readme_text).to_html
elsif github_file? file
RedmineGitHosting::MarkdownRenderer.to_html raw_readme_text
else
GitHub::Markup.render(file.path, raw_readme_text).gsub("\n", '<br/>')
end
end
end

def redmine_file?(file)
%w[.txt].include? File.extname(file.path)
end
def redmine_file?(file)
%w[.txt].include? File.extname(file.path)
end

def github_file?(file)
%w[.markdown .mdown .mkdn .md].include? File.extname(file.path)
def github_file?(file)
%w[.markdown .mdown .mkdn .md].include? File.extname(file.path)
end
end
end
end
3 changes: 3 additions & 0 deletions lib/redmine_git_hosting/journal_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ def msg2str(msg)
end
end
end
else
module JournalLogger
end
end
end
4 changes: 2 additions & 2 deletions lib/redmine_git_hosting/plugins/extenders/branch_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module RedmineGitHosting::Plugins::Extenders
class BranchUpdater < BaseExtender
attr_reader :update_default_branch

def initialize(*args)
super
def initialize(repository, **options)
super(repository, **options)
@update_default_branch = options.delete(:update_default_branch) { false }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module RedmineGitHosting::Plugins::Extenders
class ConfigKeyDeletor < BaseExtender
attr_reader :delete_git_config_key

def initialize(*args)
super
def initialize(repository, **options)
super(repository, **options)
@delete_git_config_key = options.delete(:delete_git_config_key) { '' }
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module RedmineGitHosting::Plugins::Extenders
class GitAnnexCreator < BaseExtender
attr_reader :enable_git_annex

def initialize(*args)
super
def initialize(repository, **options)
super(repository, **options)
@enable_git_annex = options.delete(:enable_git_annex) { false }
end

Expand Down
4 changes: 2 additions & 2 deletions lib/redmine_git_hosting/plugins/extenders/readme_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module RedmineGitHosting::Plugins::Extenders
class ReadmeCreator < BaseExtender
attr_reader :create_readme_file

def initialize(*args)
super
def initialize(repository, **options)
super(repository, **options)
@create_readme_file = options.delete(:create_readme_file) { false }
end

Expand Down