Skip to content

Commit

Permalink
Merge branch 'redmine5'
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Sep 29, 2022
2 parents aa74f68 + 3796efb commit 7f26e47
Show file tree
Hide file tree
Showing 56 changed files with 200 additions and 167 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/brakeman.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Run Brakeman

on: [push]
on:
- push
- pull_request

jobs:
build:
Expand All @@ -23,7 +25,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 3.1
bundler-cache: true

- name: Setup gems
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Run RuboCop

on: [push]
on:
- push
- pull_request

jobs:
build:
Expand All @@ -23,7 +25,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 3.1
bundler-cache: true

- name: Setup gems
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/stylelint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Run StyleLint

on: [push]
on:
- push
- pull_request

jobs:
build:
Expand All @@ -11,6 +13,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '16'
- run: yarn install
- run: node_modules/.bin/stylelint "assets/stylesheets/*.css"
23 changes: 11 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Test

on:
push:
pull_request:
- push
- pull_request

jobs:
test:
Expand All @@ -10,16 +11,9 @@ jobs:

strategy:
matrix:
ruby: ['2.7', '2.6', '3.0']
redmine: ['4.1-stable', '4.2-stable', 'master']
ruby: ['2.7', '3.0', '3.1']
redmine: ['5.0-stable', 'master']
db: ['postgres', 'mysql']
exclude:
- ruby: 2.7
redmine: 4.1-stable
- ruby: '3.0'
redmine: 4.1-stable
- ruby: '3.0'
redmine: 4.2-stable
fail-fast: false

services:
Expand Down Expand Up @@ -77,7 +71,10 @@ jobs:
- name: Checkout redmine_sidekiq
uses: actions/checkout@v2
with:
repository: ogom/redmine_sidekiq
# 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
path: redmine/plugins/redmine_sidekiq

- name: Checkout gitolite
Expand All @@ -100,6 +97,7 @@ jobs:
libmysqlclient-dev
libssh2-1
libssh2-1-dev
pkg-config
subversion
- name: Setup Ruby
Expand Down Expand Up @@ -132,6 +130,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
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,11 @@ Layout/SpaceBeforeBrackets:
Rails/EnvironmentVariableAccess:
Enabled: true
AllowReads: true

# Hrack::Server requires the `initialize` method
Style/RedundantInitialize:
Enabled: false

# Because our unit tests assert that
Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# 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/jbox-web/gitolite-rugged.git', tag: '1.5.0'

# 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 All @@ -16,9 +18,7 @@ gem 'hiredis'
gem 'redis'

# Markdown rendering
gem 'deckar01-task_list'
gem 'escape_utils'
gem 'html-pipeline', '~> 2.13.2'
gem 'rinku'

# Syntaxic coloration
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/xitolite_repository_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def find_xitolite_repository_by_path
repo_path = "#{params[:repo_path]}.git"
repository = Repository::Xitolite.find_by_path repo_path, loose: true
if repository.nil?
RedmineGitHosting.logger.error "GoRedirector : repository not found at path : '#{repo_path}'," \
' exiting!'
RedmineGitHosting.logger.error "GoRedirector : repository not found at path : '#{repo_path}', " \
'exiting!'
render_404
elsif !repository.go_access_available?
RedmineGitHosting.logger.error "GoRedirector : GoAccess is disabled for this repository '#{repository.gitolite_repository_name}'," \
' exiting!'
RedmineGitHosting.logger.error "GoRedirector : GoAccess is disabled for this repository '#{repository.gitolite_repository_name}', " \
'exiting!'
render_403
else
RedmineGitHosting.logger.info "GoRedirector : access granted for repository '#{repository.gitolite_repository_name}'"
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ fieldset.box.tabular
br
fieldset.box.tabular
legend = l :label_path_directories
pre == (ENV['PATH']).gsub(/:/, '<br/>')
pre == ENV.fetch('PATH', nil).gsub(/:/, '<br/>')
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
15 changes: 10 additions & 5 deletions init.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'redmine'
require 'redmine_git_hosting'
$LOAD_PATH.unshift "#{File.dirname __FILE__}/lib"

Redmine::Plugin.register :redmine_git_hosting do
name 'Redmine Git Hosting Plugin'
Expand Down Expand Up @@ -67,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'
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 = {}) # rubocop:disable Style/OptionHash
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
15 changes: 0 additions & 15 deletions lib/redmine_git_hosting.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

# Redmine Hooks
require 'redmine_git_hosting/hooks'

# Redmine SCM
Redmine::Scm::Base.add 'Xitolite'

Expand All @@ -12,7 +9,6 @@ module RedmineGitHosting
VERSION = '5.0.1-master'

# Load RedminePluginLoader
require 'redmine_git_hosting/redmine_plugin_loader'
extend RedminePluginLoader

set_plugin_name 'redmine_git_hosting'
Expand Down Expand Up @@ -60,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/init'
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
5 changes: 0 additions & 5 deletions lib/redmine_git_hosting/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/commands/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ def logger
RedmineGitHosting.logger
end
end

extend Commands::Base
end
end
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/commands/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ def git_config_as_hash(namespace, params)
value_hash
end
end

extend Commands::Git
end
end
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/commands/gitolite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,7 @@ def gitolite_home_dir
RedmineGitHosting::Config.gitolite_home_dir
end
end

extend Commands::Gitolite
end
end
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/commands/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ def ssh_shell_params
]
end
end

extend Commands::Ssh
end
end
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/commands/sudo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,7 @@ def content_from_gitolite_side(destination_path)
sudo_cat destination_path
end
end

extend Commands::Sudo
end
end
12 changes: 0 additions & 12 deletions lib/redmine_git_hosting/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/config/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ def file_logger
RedmineGitHosting.logger
end
end

extend Config::Base
end
end
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/config/gitolite_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions lib/redmine_git_hosting/config/gitolite_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ def gitolite_log_level
get_setting :gitolite_log_level
end
end

extend Config::GitoliteBase
end
end
Loading

0 comments on commit 7f26e47

Please sign in to comment.