redmine_with_git 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/initializers/001_patches.rb +11 -3
- data/installer/default_settings.sh +0 -3
- data/installer/programs/redmine_git_hosting/ssh_run.sh +15 -0
- data/installer/programs/redmine_git_hosting/ssh_server_port.sh +6 -0
- data/installer/setup.sh +1 -0
- data/installer/tasks/_before_run.sh +1 -0
- data/installer/tasks/gitolite_setup.sh +2 -2
- data/installer/tasks/redmine_git_hosting.sh +1 -1
- data/installer/tasks/redmine_git_hosting_settings.sh +1 -0
- data/installer/tasks/rugged_build_config.sh +12 -0
- data/installer/tasks/rugged_ssh_support.sh +17 -0
- data/installer/tasks/ssh_client_known_hosts.sh +45 -0
- data/installer/tasks/ssh_server_running.sh +4 -2
- data/installer/template/redmine_git_hosting_setting_value.sql +3 -3
- data/lib/redmine_with_git/patches/redmine_git_hosting/cache/database.rb +23 -0
- data/lib/redmine_with_git/patches/redmine_git_hosting/commands/{git/git_patch.rb → git.rb} +1 -5
- data/lib/redmine_with_git/patches/redmine_git_hosting/{gitolite_hook_patch.rb → gitolite_hook.rb} +1 -6
- data/lib/redmine_with_git/version.rb +1 -1
- data/lib/tasks/redmine_with_git.rake +1 -24
- metadata +18 -60
- data/app/controllers/backup_controller.rb +0 -62
- data/app/helpers/redmine_with_git_helper.rb +0 -26
- data/app/models/redmine_with_git/tableless/load.rb +0 -25
- data/app/views/backup/_api.html.erb +0 -14
- data/app/views/backup/_export.html.erb +0 -1
- data/app/views/backup/_import.html.erb +0 -9
- data/app/views/backup/index.html.erb +0 -13
- data/config/initializers/000_dependencies.rb +0 -25
- data/config/initializers/500_nonproject_modules.rb +0 -5
- data/config/locales/en.yml +0 -15
- data/config/locales/pt-BR.yml +0 -15
- data/config/routes.rb +0 -7
- data/lib/redmine_with_git/dump/all.rb +0 -26
- data/lib/redmine_with_git/dump/base.rb +0 -99
- data/lib/redmine_with_git/dump/database.rb +0 -15
- data/lib/redmine_with_git/dump/files.rb +0 -15
- data/lib/redmine_with_git/dump/git.rb +0 -15
- data/lib/redmine_with_git/dump_load/all.rb +0 -36
- data/lib/redmine_with_git/dump_load/base.rb +0 -30
- data/lib/redmine_with_git/dump_load/database.rb +0 -24
- data/lib/redmine_with_git/dump_load/files.rb +0 -13
- data/lib/redmine_with_git/dump_load/git.rb +0 -17
- data/lib/redmine_with_git/load/all.rb +0 -30
- data/lib/redmine_with_git/load/base.rb +0 -53
- data/lib/redmine_with_git/load/database.rb +0 -47
- data/lib/redmine_with_git/load/files.rb +0 -19
- data/lib/redmine_with_git/load/git.rb +0 -24
- data/lib/redmine_with_git/patches/redmine_git_hosting/cache/database_patch.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b34c96c3e569895dbb2fa9cb56fbba0696d74d194f47e0e3b83fda6e4a3bd5e
|
|
4
|
+
data.tar.gz: 94debefb24f7b406c342e42a2daefa8ef02ac8eef8043ad2ace2839689b0a92a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b114bcdbc6741bf7ebc88e0706c94d393b2cb6b68b7562e7fc392d9979b6f5ba7198ea06dbfbd3d5eb176bf0ffe5da1ba60789225315f8f2e9f2bead7ccf956b
|
|
7
|
+
data.tar.gz: d0a2f622fbbba50b9ff5b3fe1780d43054a2f5917b609b0f4819db8c908cd3b1c0ae493ac2e11cef453fd26b34137300703c897f3ec7c1ab7ebaa08f5337e8c6
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
EacRubyUtils.patch_module(
|
|
4
|
+
RedmineGitHosting::GitoliteHook,
|
|
5
|
+
RedmineWithGit::Patches::RedmineGitHosting::GitoliteHook
|
|
6
|
+
)
|
|
4
7
|
|
|
5
8
|
apply_patches_version_limit = Gem::Version.new('4.0.0')
|
|
6
9
|
redmine_git_hosting_version = Gem::Version.new(
|
|
@@ -9,5 +12,10 @@ redmine_git_hosting_version = Gem::Version.new(
|
|
|
9
12
|
|
|
10
13
|
return unless redmine_git_hosting_version < apply_patches_version_limit
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
patch = RedmineWithGit::Patches::RedmineGitHosting::Cache::Database
|
|
16
|
+
target = RedmineGitHosting::Cache::Database
|
|
17
|
+
target.send(:include, patch) unless target.include?(patch)
|
|
18
|
+
|
|
19
|
+
patch = RedmineWithGit::Patches::RedmineGitHosting::Commands::Git
|
|
20
|
+
target = RedmineGitHosting::Commands::Git
|
|
21
|
+
target.send(:include, patch) unless target.include?(patch)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
set -u
|
|
5
|
+
|
|
6
|
+
var_set_by STRICT_HOST_KEY_CHECKING bool_s "$1" 'yes' 'no'
|
|
7
|
+
shift
|
|
8
|
+
|
|
9
|
+
sudo -u "$(programeiro /rails/user)" \
|
|
10
|
+
ssh -oBatchMode=yes "-oStrictHostKeyChecking=${STRICT_HOST_KEY_CHECKING}" \
|
|
11
|
+
-i "$(programeiro /redmine_git_hosting/ssh_key)" \
|
|
12
|
+
-p "$(programeiro /redmine_git_hosting/ssh_server_port)" \
|
|
13
|
+
-l "$gitolite_user" \
|
|
14
|
+
"$SSH_SERVER_HOST" \
|
|
15
|
+
"$@"
|
data/installer/setup.sh
CHANGED
|
@@ -4,11 +4,11 @@ set -u
|
|
|
4
4
|
set -e
|
|
5
5
|
|
|
6
6
|
function task_dependencies {
|
|
7
|
-
echo gitolite_rc gitolite redmine_git_hosting_ssh_key ssh_server_running
|
|
7
|
+
echo gitolite_rc gitolite redmine_git_hosting_ssh_key ssh_client_known_hosts ssh_server_running
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
function task_condition {
|
|
11
|
-
|
|
11
|
+
programeiro /redmine_git_hosting/ssh_run no info
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function task_fix {
|
|
@@ -5,6 +5,7 @@ set -e
|
|
|
5
5
|
|
|
6
6
|
function redmine_git_hosting_setting_template {
|
|
7
7
|
export redmine_git_hosting_ssh_key=$(programeiro /redmine_git_hosting/ssh_key)
|
|
8
|
+
var_set_by SSH_SERVER_PORT programeiro /redmine_git_hosting/ssh_server_port
|
|
8
9
|
template_apply "${REDMINE_WITH_GIT_TEMPLATE_ROOT}/redmine_git_hosting_setting_value.sql" -
|
|
9
10
|
}
|
|
10
11
|
export -f redmine_git_hosting_setting_template
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -u
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
function task_dependencies {
|
|
7
|
+
echo redmine_bundle rugged_build_config
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function task_condition {
|
|
11
|
+
programeiro /rails/bundle exec ruby -e "require 'rugged'; exit(Rugged.features.include?(:ssh) ? 0 : 1)"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function task_fix {
|
|
15
|
+
programeiro /rails/bundle pristine rugged
|
|
16
|
+
programeiro /redmine/installer/triggers/set 'restart_application'
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -u
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
function ssh_client_known_hosts_file {
|
|
7
|
+
printf '%s/known_hosts' "$(dirname "$(programeiro /redmine_git_hosting/ssh_key)")"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function ssh_client_known_hosts_spec {
|
|
11
|
+
var_set_by SSH_SERVER_PORT programeiro /redmine_git_hosting/ssh_server_port
|
|
12
|
+
if [ "$SSH_SERVER_PORT" == '22' ]; then
|
|
13
|
+
printf '%s' "$SSH_SERVER_HOST"
|
|
14
|
+
else
|
|
15
|
+
printf '[%s]:%s' "$SSH_SERVER_HOST" "$SSH_SERVER_PORT"
|
|
16
|
+
fi
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function ssh_client_known_hosts_entries_count {
|
|
20
|
+
local known_hosts
|
|
21
|
+
known_hosts="$(ssh_client_known_hosts_file)"
|
|
22
|
+
[ -f "$known_hosts" ] || { echo 0; return; }
|
|
23
|
+
sudo -u "$(programeiro /rails/user)" \
|
|
24
|
+
ssh-keygen -F "$(ssh_client_known_hosts_spec)" -f "$known_hosts" | grep -vc '^#'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ssh_client_known_hosts_connection_ok {
|
|
28
|
+
programeiro /redmine_git_hosting/ssh_run yes info >/dev/null 2>&1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function task_dependencies {
|
|
32
|
+
echo redmine_git_hosting_ssh_key ssh_server_running
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function task_condition {
|
|
36
|
+
[ "$(ssh_client_known_hosts_entries_count)" == '1' ] && ssh_client_known_hosts_connection_ok
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function task_fix {
|
|
40
|
+
local known_hosts
|
|
41
|
+
known_hosts="$(ssh_client_known_hosts_file)"
|
|
42
|
+
sudo -u "$(programeiro /rails/user)" \
|
|
43
|
+
ssh-keygen -R "$(ssh_client_known_hosts_spec)" -f "$known_hosts" >/dev/null 2>&1 || true
|
|
44
|
+
programeiro /redmine_git_hosting/ssh_run no info
|
|
45
|
+
}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
set -u
|
|
4
4
|
set -e
|
|
5
5
|
|
|
6
|
+
PACKAGE_ARGS=('systemctl' "$SSH_SERVER_SERVICE")
|
|
7
|
+
|
|
6
8
|
function task_condition {
|
|
7
|
-
|
|
9
|
+
SUDO=t package_installed "${PACKAGE_ARGS[@]}"
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
function task_dependencies {
|
|
@@ -12,5 +14,5 @@ function task_dependencies {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
function task_fix {
|
|
15
|
-
|
|
17
|
+
SUDO=t package_assert "${PACKAGE_ARGS[@]}"
|
|
16
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--- !ruby/hash:
|
|
1
|
+
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
|
2
2
|
all_projects_use_git: 'false'
|
|
3
3
|
delete_git_repositories: 'true'
|
|
4
4
|
download_revision_enabled: 'true'
|
|
@@ -34,8 +34,8 @@ gitolite_resync_all: 'false'
|
|
|
34
34
|
gitolite_resync_all_projects: 'false'
|
|
35
35
|
gitolite_resync_all_ssh_keys: 'false'
|
|
36
36
|
gitolite_scripts_dir: ''
|
|
37
|
-
gitolite_server_host:
|
|
38
|
-
gitolite_server_port: '
|
|
37
|
+
gitolite_server_host: '%%SSH_SERVER_HOST%%'
|
|
38
|
+
gitolite_server_port: '%%SSH_SERVER_PORT%%'
|
|
39
39
|
gitolite_ssh_private_key: "%%redmine_git_hosting_ssh_key%%"
|
|
40
40
|
gitolite_ssh_public_key: "%%redmine_git_hosting_ssh_key%%.pub"
|
|
41
41
|
gitolite_temp_dir: "/tmp/redmine_git_hosting_%%gitolite_user%%/"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RedmineWithGit
|
|
4
|
+
module Patches
|
|
5
|
+
module RedmineGitHosting
|
|
6
|
+
module Cache
|
|
7
|
+
module Database
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.prepend(InstanceMethods)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module InstanceMethods
|
|
13
|
+
def apply_cache_limit
|
|
14
|
+
return unless max_cache_elements >= 0 && GitCache.count > max_cache_elements
|
|
15
|
+
|
|
16
|
+
GitCache.order(created_at: :desc).last.destroy
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -4,7 +4,7 @@ module RedmineWithGit
|
|
|
4
4
|
module Patches
|
|
5
5
|
module RedmineGitHosting
|
|
6
6
|
module Commands
|
|
7
|
-
module
|
|
7
|
+
module Git
|
|
8
8
|
def self.included(base)
|
|
9
9
|
base.prepend(InstanceMethods)
|
|
10
10
|
end
|
|
@@ -22,7 +22,3 @@ module RedmineWithGit
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
patch = RedmineWithGit::Patches::RedmineGitHosting::Commands::GitPatch
|
|
27
|
-
target = RedmineGitHosting::Commands::Git
|
|
28
|
-
target.send(:include, patch) unless target.include?(patch)
|
data/lib/redmine_with_git/patches/redmine_git_hosting/{gitolite_hook_patch.rb → gitolite_hook.rb}
RENAMED
|
@@ -7,7 +7,7 @@ require 'rbconfig'
|
|
|
7
7
|
module RedmineWithGit
|
|
8
8
|
module Patches
|
|
9
9
|
module RedmineGitHosting
|
|
10
|
-
module
|
|
10
|
+
module GitoliteHook
|
|
11
11
|
def self.included(base)
|
|
12
12
|
base.prepend(InstanceMethods)
|
|
13
13
|
end
|
|
@@ -85,8 +85,3 @@ module RedmineWithGit
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
|
-
|
|
89
|
-
EacRubyUtils.patch_module(
|
|
90
|
-
RedmineGitHosting::GitoliteHook,
|
|
91
|
-
RedmineWithGit::Patches::RedmineGitHosting::GitoliteHookPatch
|
|
92
|
-
)
|
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
namespace :redmine_with_git do
|
|
4
|
-
%w[database files git all].each do |a|
|
|
5
|
-
namespace :dump do
|
|
6
|
-
desc <<~DESCRIPTION
|
|
7
|
-
Dump backup file for "#{a}" resource(s).
|
|
8
|
-
|
|
9
|
-
Arguments:
|
|
10
|
-
* <path>: path to the dump.
|
|
11
|
-
* [overwrite]: 1: denied, 2: allowed, 3: rotate (Default: 1).
|
|
12
|
-
* [space_limit]: limits the used space by all rotated files.
|
|
13
|
-
DESCRIPTION
|
|
14
|
-
task a, %i[path overwrite space_limit] => :environment do |_t, args|
|
|
15
|
-
RedmineWithGit::Dump.const_get(a.camelize).new(args.path, overwrite: args.overwrite,
|
|
16
|
-
space_limit: args.space_limit)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
namespace :load do
|
|
20
|
-
desc "Load backup file for \"#{a}\" resource(s)"
|
|
21
|
-
task a, [:path] => :environment do |_t, args|
|
|
22
|
-
RedmineWithGit::Load.const_get(a.camelize).new(args.path)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
3
|
+
namespace :redmine_with_git do
|
|
27
4
|
desc 'Executa as operações de "Rescue" da configuração do plugin RedmineGitHosting'
|
|
28
5
|
task rescue: %i[redmine_git_hosting:install_hook_parameters
|
|
29
6
|
redmine_git_hosting:migration_tools:update_repositories_type
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redmine_with_git
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esquilo Azul Company
|
|
@@ -15,20 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '0.
|
|
19
|
-
- - ">="
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.102.4
|
|
18
|
+
version: '0.103'
|
|
22
19
|
type: :runtime
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
23
|
- - "~>"
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '0.
|
|
29
|
-
- - ">="
|
|
30
|
-
- !ruby/object:Gem::Version
|
|
31
|
-
version: 0.102.4
|
|
25
|
+
version: '0.103'
|
|
32
26
|
- !ruby/object:Gem::Dependency
|
|
33
27
|
name: eac_rails_utils
|
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -49,42 +43,28 @@ dependencies:
|
|
|
49
43
|
requirements:
|
|
50
44
|
- - "~>"
|
|
51
45
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '0.
|
|
46
|
+
version: '0.134'
|
|
53
47
|
type: :runtime
|
|
54
48
|
prerelease: false
|
|
55
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
50
|
requirements:
|
|
57
51
|
- - "~>"
|
|
58
52
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '0.
|
|
53
|
+
version: '0.134'
|
|
60
54
|
- !ruby/object:Gem::Dependency
|
|
61
|
-
name:
|
|
55
|
+
name: rdoc
|
|
62
56
|
requirement: !ruby/object:Gem::Requirement
|
|
63
57
|
requirements:
|
|
64
|
-
- - "
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: '3'
|
|
67
|
-
type: :runtime
|
|
68
|
-
prerelease: false
|
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
-
requirements:
|
|
71
|
-
- - "<"
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
version: '3'
|
|
74
|
-
- !ruby/object:Gem::Dependency
|
|
75
|
-
name: redcarpet
|
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
|
77
|
-
requirements:
|
|
78
|
-
- - ">="
|
|
58
|
+
- - "~>"
|
|
79
59
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '
|
|
60
|
+
version: '7.2'
|
|
81
61
|
type: :runtime
|
|
82
62
|
prerelease: false
|
|
83
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
64
|
requirements:
|
|
85
|
-
- - "
|
|
65
|
+
- - "~>"
|
|
86
66
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
67
|
+
version: '7.2'
|
|
88
68
|
- !ruby/object:Gem::Dependency
|
|
89
69
|
name: sidekiq
|
|
90
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -117,24 +97,14 @@ executables: []
|
|
|
117
97
|
extensions: []
|
|
118
98
|
extra_rdoc_files: []
|
|
119
99
|
files:
|
|
120
|
-
- app/controllers/backup_controller.rb
|
|
121
|
-
- app/helpers/redmine_with_git_helper.rb
|
|
122
|
-
- app/models/redmine_with_git/tableless/load.rb
|
|
123
|
-
- app/views/backup/_api.html.erb
|
|
124
|
-
- app/views/backup/_export.html.erb
|
|
125
|
-
- app/views/backup/_import.html.erb
|
|
126
|
-
- app/views/backup/index.html.erb
|
|
127
|
-
- config/initializers/000_dependencies.rb
|
|
128
100
|
- config/initializers/001_patches.rb
|
|
129
|
-
- config/initializers/500_nonproject_modules.rb
|
|
130
|
-
- config/locales/en.yml
|
|
131
|
-
- config/locales/pt-BR.yml
|
|
132
|
-
- config/routes.rb
|
|
133
101
|
- init.rb
|
|
134
102
|
- installer/default_settings.sh
|
|
135
103
|
- installer/programs/linux/sudo_file_exists.sh
|
|
136
104
|
- installer/programs/linux/sudo_write.sh
|
|
137
105
|
- installer/programs/redmine_git_hosting/ssh_key.sh
|
|
106
|
+
- installer/programs/redmine_git_hosting/ssh_run.sh
|
|
107
|
+
- installer/programs/redmine_git_hosting/ssh_server_port.sh
|
|
138
108
|
- installer/programs/text/diff_stdin_file.sh
|
|
139
109
|
- installer/programs/triggers/redmine_git_hosting_rescue.sh
|
|
140
110
|
- installer/setup.sh
|
|
@@ -150,6 +120,9 @@ files:
|
|
|
150
120
|
- installer/tasks/redmine_git_hosting_ssh_key.sh
|
|
151
121
|
- installer/tasks/redmine_gitolite_sudoer.sh
|
|
152
122
|
- installer/tasks/redmine_with_git_bundle_requirements.sh
|
|
123
|
+
- installer/tasks/rugged_build_config.sh
|
|
124
|
+
- installer/tasks/rugged_ssh_support.sh
|
|
125
|
+
- installer/tasks/ssh_client_known_hosts.sh
|
|
153
126
|
- installer/tasks/ssh_server.sh
|
|
154
127
|
- installer/tasks/ssh_server_running.sh
|
|
155
128
|
- installer/template/gitolite.rc
|
|
@@ -157,24 +130,9 @@ files:
|
|
|
157
130
|
- installer/template/redmine_git_hosting_setting_value.sql
|
|
158
131
|
- installer/template/redmine_user_sudoer
|
|
159
132
|
- lib/redmine_with_git.rb
|
|
160
|
-
- lib/redmine_with_git/
|
|
161
|
-
- lib/redmine_with_git/
|
|
162
|
-
- lib/redmine_with_git/
|
|
163
|
-
- lib/redmine_with_git/dump/files.rb
|
|
164
|
-
- lib/redmine_with_git/dump/git.rb
|
|
165
|
-
- lib/redmine_with_git/dump_load/all.rb
|
|
166
|
-
- lib/redmine_with_git/dump_load/base.rb
|
|
167
|
-
- lib/redmine_with_git/dump_load/database.rb
|
|
168
|
-
- lib/redmine_with_git/dump_load/files.rb
|
|
169
|
-
- lib/redmine_with_git/dump_load/git.rb
|
|
170
|
-
- lib/redmine_with_git/load/all.rb
|
|
171
|
-
- lib/redmine_with_git/load/base.rb
|
|
172
|
-
- lib/redmine_with_git/load/database.rb
|
|
173
|
-
- lib/redmine_with_git/load/files.rb
|
|
174
|
-
- lib/redmine_with_git/load/git.rb
|
|
175
|
-
- lib/redmine_with_git/patches/redmine_git_hosting/cache/database_patch.rb
|
|
176
|
-
- lib/redmine_with_git/patches/redmine_git_hosting/commands/git/git_patch.rb
|
|
177
|
-
- lib/redmine_with_git/patches/redmine_git_hosting/gitolite_hook_patch.rb
|
|
133
|
+
- lib/redmine_with_git/patches/redmine_git_hosting/cache/database.rb
|
|
134
|
+
- lib/redmine_with_git/patches/redmine_git_hosting/commands/git.rb
|
|
135
|
+
- lib/redmine_with_git/patches/redmine_git_hosting/gitolite_hook.rb
|
|
178
136
|
- lib/redmine_with_git/version.rb
|
|
179
137
|
- lib/tasks/redmine_with_git.rake
|
|
180
138
|
licenses: []
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class BackupController < ApplicationController
|
|
4
|
-
EXPORT_PERMISSION = 'redmine_with_git.backup.export'
|
|
5
|
-
IMPORT_PERMISSION = 'redmine_with_git.backup.import'
|
|
6
|
-
|
|
7
|
-
PERMISSIONS = { or: [EXPORT_PERMISSION, IMPORT_PERMISSION] }.freeze
|
|
8
|
-
|
|
9
|
-
layout 'nonproject_modules'
|
|
10
|
-
require_permission PERMISSIONS, only: [:index]
|
|
11
|
-
require_permission EXPORT_PERMISSION, only: [:export]
|
|
12
|
-
require_permission IMPORT_PERMISSION, only: [:import]
|
|
13
|
-
|
|
14
|
-
accept_api_auth :export, :import
|
|
15
|
-
|
|
16
|
-
helper ::RedmineWithGitHelper
|
|
17
|
-
|
|
18
|
-
def index
|
|
19
|
-
@load = ::RedmineWithGit::Tableless::Load.new
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def export
|
|
23
|
-
Tempfile.open('redmine_export') do |file|
|
|
24
|
-
::RedmineWithGit::Dump::All.new(
|
|
25
|
-
file.path,
|
|
26
|
-
overwrite: ::RedmineWithGit::Dump::Base::OVERWRITE_ALLOWED
|
|
27
|
-
)
|
|
28
|
-
send_file(file.path, filename: export_file_name, type: 'application/x-tar',
|
|
29
|
-
size: file.size)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def import
|
|
34
|
-
@load = ::RedmineWithGit::Tableless::Load.new(import_params)
|
|
35
|
-
@load.save
|
|
36
|
-
respond_to do |format|
|
|
37
|
-
format.html { import_respond_to_html }
|
|
38
|
-
format.api { render_validation_errors(@load) }
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def import_respond_to_html
|
|
45
|
-
if @load.errors.empty?
|
|
46
|
-
redirect_to backup_path, notice: 'Backup imported' # rubocop:disable Rails/I18nLocaleTexts
|
|
47
|
-
else
|
|
48
|
-
render :index
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def export_file_name
|
|
53
|
-
"redmine-backup_#{Time.zone.now.strftime('%Y-%m-%d_%H-%M-%S')}.tar"
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def import_params
|
|
57
|
-
ps = params[::RedmineWithGit::Tableless::Load.model_name.param_key]
|
|
58
|
-
return {} if ps.blank?
|
|
59
|
-
|
|
60
|
-
ps.permit(:path)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGitHelper
|
|
4
|
-
def export_api_curl_command
|
|
5
|
-
curl_command("curl -JLO '#{export_backup_url(key: User.current.api_key)}'")
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def import_api_curl_command
|
|
9
|
-
curl_command(<<~IMPORT_CURL)
|
|
10
|
-
curl -X POST \\
|
|
11
|
-
-F '#{import_param_key}=@<PATH_TO_BACKUP_FILE>' \\
|
|
12
|
-
-F 'key=#{User.current.api_key}' \\
|
|
13
|
-
#{import_backup_url(format: 'json')}
|
|
14
|
-
IMPORT_CURL
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def curl_command(command)
|
|
20
|
-
content_tag(:pre, command)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def import_param_key
|
|
24
|
-
"#{::RedmineWithGit::Tableless::Load.model_name.param_key}[path]"
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Tableless
|
|
5
|
-
class Load < ::EacRailsUtils::Models::Tableless
|
|
6
|
-
attribute :path, String
|
|
7
|
-
|
|
8
|
-
validates :path, presence: true
|
|
9
|
-
|
|
10
|
-
def save
|
|
11
|
-
return false unless valid?
|
|
12
|
-
|
|
13
|
-
::RedmineWithGit::Load::All.new(path.path)
|
|
14
|
-
true
|
|
15
|
-
rescue StandardError => e
|
|
16
|
-
errors.add(:path, e.message)
|
|
17
|
-
false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def path_path
|
|
21
|
-
path.is_a?(Pathname) ? path.path : path.to_s
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<div>
|
|
2
|
-
<%= link_to_function(l(:button_show), "$('#redmine_with_git_api').toggle();")%>
|
|
3
|
-
<div id='redmine_with_git_api' class="autoscroll" >
|
|
4
|
-
<% if ::GroupPermission.permission?(::BackupController::EXPORT_PERMISSION) %>
|
|
5
|
-
<h4>Export CURL command</h4>
|
|
6
|
-
<%= export_api_curl_command %>
|
|
7
|
-
<% end %>
|
|
8
|
-
<% if ::GroupPermission.permission?(::BackupController::IMPORT_PERMISSION) %>
|
|
9
|
-
<h4>Import CURL command</h4>
|
|
10
|
-
<%= import_api_curl_command %>
|
|
11
|
-
<% end %>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
<%= javascript_tag("$('#redmine_with_git_api').hide();") %>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= link_to 'Export', export_backup_path %>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<h2>Redmine With Git</h2>
|
|
2
|
-
<% if ::GroupPermission.permission?(::BackupController::EXPORT_PERMISSION) %>
|
|
3
|
-
<h3>Export</h3>
|
|
4
|
-
<%= render partial: 'export' %>
|
|
5
|
-
<% end %>
|
|
6
|
-
<% if ::GroupPermission.permission?(::BackupController::IMPORT_PERMISSION) %>
|
|
7
|
-
<h3>Import</h3>
|
|
8
|
-
<%= render partial: 'import' %>
|
|
9
|
-
<% end %>
|
|
10
|
-
<% if Setting.rest_api_enabled? %>
|
|
11
|
-
<h3>API</h3>
|
|
12
|
-
<%= render partial: 'api' %>
|
|
13
|
-
<% end %>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Redmine::Plugin.post_register :redmine_with_git do
|
|
4
|
-
# Source: https://github.com/esquilo-azul/redmine_nonproject_modules
|
|
5
|
-
requires_redmine_plugin(:redmine_nonproject_modules, version_or_higher: '0.3.1')
|
|
6
|
-
|
|
7
|
-
if Redmine::VERSION.to_s < '4'
|
|
8
|
-
# Source: https://github.com/jbox-web/redmine_bootstrap_kit.git
|
|
9
|
-
# Note: redmine_bootstrap_kit is a redmine_git_hosting's dependency.
|
|
10
|
-
requires_redmine_plugin(:redmine_bootstrap_kit, version_or_higher: '0.2.5')
|
|
11
|
-
# Source: https://github.com/jbox-web/redmine_git_hosting.git
|
|
12
|
-
requires_redmine_plugin(:redmine_git_hosting, version_or_higher: '1.2.3.1')
|
|
13
|
-
else
|
|
14
|
-
# Source: https://github.com/jbox-web/additionals
|
|
15
|
-
# Note: additionals is a redmine_git_hosting's dependency.
|
|
16
|
-
requires_redmine_plugin(:additionals, version_or_higher: '2.0.24')
|
|
17
|
-
# Source: https://github.com/jbox-web/redmine_git_hosting.git
|
|
18
|
-
requires_redmine_plugin(:redmine_git_hosting, version_or_higher: '4.0.1.1')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Source: https://github.com/esquilo-azul/redmine_installer
|
|
22
|
-
if Redmine::Plugin.registered_plugins.keys.include?(:redmine_installer)
|
|
23
|
-
requires_redmine_plugin(:redmine_installer, version_or_higher: '0.21.0')
|
|
24
|
-
end
|
|
25
|
-
end
|
data/config/locales/en.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
en:
|
|
2
|
-
label_backup: Backup
|
|
3
|
-
eac_ruby_utils:
|
|
4
|
-
listable:
|
|
5
|
-
redmine_with_git/dump/base:
|
|
6
|
-
overwrite:
|
|
7
|
-
allowed:
|
|
8
|
-
label: Allowed
|
|
9
|
-
denied:
|
|
10
|
-
label: Denied
|
|
11
|
-
field_path: Path
|
|
12
|
-
permission_redmine_with_git:
|
|
13
|
-
backup:
|
|
14
|
-
export_description: Allows to export the backup package.
|
|
15
|
-
import_description: Allows to import a backup package.
|
data/config/locales/pt-BR.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
pt-BR:
|
|
2
|
-
label_backup: Backup
|
|
3
|
-
eac_ruby_utils:
|
|
4
|
-
listable:
|
|
5
|
-
redmine_with_git/dump/base:
|
|
6
|
-
overwrite:
|
|
7
|
-
allowed:
|
|
8
|
-
label: Permitido
|
|
9
|
-
denied:
|
|
10
|
-
label: Negado
|
|
11
|
-
field_path: Caminho
|
|
12
|
-
permission_redmine_with_git:
|
|
13
|
-
backup:
|
|
14
|
-
export_description: Permite exportar o pacote de backup.
|
|
15
|
-
import_description: Permite importar um pacote de backup.
|
data/config/routes.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Dump
|
|
5
|
-
class All < ::RedmineWithGit::Dump::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::All
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def run_command
|
|
11
|
-
on_temp_dir do
|
|
12
|
-
RESOURCES.each { |resource| build_sub(resource) }
|
|
13
|
-
super
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def build_sub(resource)
|
|
18
|
-
resource_class(resource).new(resource_file_path(resource), options)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def build_command
|
|
22
|
-
create_tar_command(tmpdir, false)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'avm/data/rotate'
|
|
4
|
-
require 'eac_ruby_utils/patches/object/asserts'
|
|
5
|
-
require 'eac_ruby_utils/listable'
|
|
6
|
-
|
|
7
|
-
module RedmineWithGit
|
|
8
|
-
module Dump
|
|
9
|
-
class Base < ::RedmineWithGit::DumpLoad::Base
|
|
10
|
-
include ::EacRubyUtils::Listable
|
|
11
|
-
|
|
12
|
-
lists.add_integer :overwrite, 1 => :denied, 2 => :allowed, 3 => :rotate
|
|
13
|
-
|
|
14
|
-
attr_reader :options
|
|
15
|
-
|
|
16
|
-
def initialize(path, options = {})
|
|
17
|
-
options.assert_argument ::Hash, 'options'
|
|
18
|
-
@options = options
|
|
19
|
-
validate_overwrite
|
|
20
|
-
super(path)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def overwrite
|
|
24
|
-
v = @options[:overwrite]
|
|
25
|
-
v.present? ? v.to_i : OVERWRITE_DENIED
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def space_limit
|
|
29
|
-
@options[:space_limit]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def run
|
|
35
|
-
start_banner
|
|
36
|
-
return unless run_if_overwrite_denied
|
|
37
|
-
return unless run_if_rotate
|
|
38
|
-
|
|
39
|
-
run_command
|
|
40
|
-
validate_exported
|
|
41
|
-
end_banner
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def start_banner
|
|
45
|
-
Rails.logger.info "Dumping resource \"#{resource_name}\" to \"#{path}\"..."
|
|
46
|
-
Rails.logger.info "Overwrite: #{overwrite}"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def end_banner
|
|
50
|
-
Rails.logger.info("#{path}: #{number_to_human_size(::File.size(path))}, #{path_type}")
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def run_if_overwrite_denied # rubocop:disable Naming/PredicateMethod
|
|
54
|
-
if ::File.exist?(path) && overwrite == OVERWRITE_DENIED
|
|
55
|
-
Rails.logger.warn "File \"#{path}\" already exists"
|
|
56
|
-
false
|
|
57
|
-
else
|
|
58
|
-
true
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def run_if_rotate # rubocop:disable Naming/PredicateMethod
|
|
63
|
-
if ::File.exist?(path) && overwrite == OVERWRITE_ROTATE
|
|
64
|
-
rotate = ::Avm::Data::Rotate.new(path, space_limit: space_limit)
|
|
65
|
-
::Rails.logger.info "Rotating \"#{rotate.source_path}\"..."
|
|
66
|
-
rotate.run
|
|
67
|
-
::Rails.logger.info "Rotated to \"#{rotate.target_path}\""
|
|
68
|
-
end
|
|
69
|
-
true
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def run_command
|
|
73
|
-
build_command.execute!(output_file: path)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def create_tar_command(dir, compression = true) # rubocop:disable Style/OptionalBooleanParameter
|
|
77
|
-
tar = "cd #{Shellwords.escape(dir)}; tar -c *"
|
|
78
|
-
tar += " | #{compress_args.join(' ')}" if compression
|
|
79
|
-
env.command(['bash', '-c', tar])
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def compress_args
|
|
83
|
-
%w[gzip -9 -c -]
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def validate_exported
|
|
87
|
-
raise "File \"#{path}\" was not generated" unless ::File.exist?(path)
|
|
88
|
-
raise "File \"#{path}\" has zero size" unless ::File.size(path).positive?
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def validate_overwrite
|
|
92
|
-
klass = ::RedmineWithGit::Dump::Base
|
|
93
|
-
return if klass.lists.overwrite.values.include?(overwrite)
|
|
94
|
-
|
|
95
|
-
raise "Invalid overwrite value: \"#{overwrite}\" (Valid: #{klass.lists.overwrite.values})"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Dump
|
|
5
|
-
class Database < ::RedmineWithGit::Dump::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::Database
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def build_command
|
|
11
|
-
build_postgres_command('pg_dump', ['-x', '-c', '-O', '@ESC_|'] + compress_args)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Dump
|
|
5
|
-
class Files < ::RedmineWithGit::Dump::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::Files
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def build_command
|
|
11
|
-
create_tar_command(files_path)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Dump
|
|
5
|
-
class Git < ::RedmineWithGit::Dump::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::Git
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def build_command
|
|
11
|
-
create_tar_command(repositories_path).prepend(sudo_command)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module DumpLoad
|
|
5
|
-
module All
|
|
6
|
-
DATABASE = 'database.gz'
|
|
7
|
-
FILES = 'files.tar.gz'
|
|
8
|
-
GIT = 'git.tar.gz'
|
|
9
|
-
|
|
10
|
-
RESOURCES = %w[database files git].freeze
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
attr_reader :tmpdir
|
|
15
|
-
|
|
16
|
-
def on_temp_dir
|
|
17
|
-
::Dir.mktmpdir do |dir|
|
|
18
|
-
@tmpdir = dir
|
|
19
|
-
yield
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def resource_class(resource_name)
|
|
24
|
-
"#{self.class.name.deconstantize}::#{resource_name.camelize}".constantize
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def resource_file_name(resource_name)
|
|
28
|
-
self.class.const_get(resource_name.underscore.upcase)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def resource_file_path(resource_name)
|
|
32
|
-
File.join(tmpdir, resource_file_name(resource_name))
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module DumpLoad
|
|
5
|
-
class Base
|
|
6
|
-
include ::ActionView::Helpers::NumberHelper
|
|
7
|
-
|
|
8
|
-
def initialize(path)
|
|
9
|
-
@path = path
|
|
10
|
-
run
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
attr_reader :path
|
|
16
|
-
|
|
17
|
-
def resource_name
|
|
18
|
-
self.class.name.demodulize.underscore
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def env
|
|
22
|
-
::EacRubyUtils::Envs.local
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def path_type
|
|
26
|
-
env.command('file', '-b', path).execute!
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module DumpLoad
|
|
5
|
-
module Database
|
|
6
|
-
def build_postgres_command(command, args = [])
|
|
7
|
-
env.command(
|
|
8
|
-
[password_arg, command] + {
|
|
9
|
-
host: database_schema['host'], port: database_schema['port'],
|
|
10
|
-
username: database_schema['username'], dbname: database_schema['database']
|
|
11
|
-
}.flat_map { |k, v| ["--#{k}", v] } + args
|
|
12
|
-
)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def database_schema
|
|
16
|
-
Rails.configuration.database_configuration[Rails.env]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def password_arg
|
|
20
|
-
"@ESC_PGPASSWORD=#{Shellwords.escape(database_schema['password'])}"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module DumpLoad
|
|
5
|
-
module Git
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def repositories_path
|
|
9
|
-
::RedmineGitHosting::Config.gitolite_global_storage_dir
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def sudo_command
|
|
13
|
-
::RedmineGitHosting::Commands.send(:sudo)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Load
|
|
5
|
-
class All < ::RedmineWithGit::Load::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::All
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def run_clear
|
|
11
|
-
# Do nothing
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run_load
|
|
15
|
-
on_temp_dir do
|
|
16
|
-
extract_path_to_tmpdir
|
|
17
|
-
RESOURCES.each { |r| load_resource(r) }
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def extract_path_to_tmpdir
|
|
22
|
-
tar_extract_command(tmpdir, false).execute!(input_file: path)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def load_resource(resource_name)
|
|
26
|
-
resource_class(resource_name).new(resource_file_path(resource_name))
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Load
|
|
5
|
-
class Base < ::RedmineWithGit::DumpLoad::Base
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def run
|
|
9
|
-
start_banner
|
|
10
|
-
unless ::File.exist?(path)
|
|
11
|
-
Rails.logger.warn "File \"#{path}\" does not exist"
|
|
12
|
-
return
|
|
13
|
-
end
|
|
14
|
-
run_clear
|
|
15
|
-
run_load
|
|
16
|
-
end_banner
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def start_banner
|
|
20
|
-
Rails.logger.info "Loading \"#{path}\" to #{resource_name}..."
|
|
21
|
-
Rails.logger.info("#{path}: #{number_to_human_size(::File.size(path))}, #{path_type}")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def run_clear
|
|
25
|
-
Rails.logger.info "Clearing resource \"#{resource_name}\"..."
|
|
26
|
-
before_clear
|
|
27
|
-
clear_command.execute!
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def run_load
|
|
31
|
-
Rails.logger.info "Loading \"#{path}\" to resource \"#{resource_name}\"..."
|
|
32
|
-
load_command.execute!(input_file: path)
|
|
33
|
-
after_load
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def end_banner
|
|
37
|
-
Rails.logger.info "\"#{path}\" loaded in resource \"#{resource_name}\""
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def uncompress_args
|
|
41
|
-
['gzip', '-d', '-c', '-']
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def tar_extract_command(target_dir, compression = true) # rubocop:disable Style/OptionalBooleanParameter
|
|
45
|
-
env.command('tar', (compression ? '-xz' : '-x'), '-C', target_dir)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def before_clear; end
|
|
49
|
-
|
|
50
|
-
def after_load; end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_dependency 'redmine_plugins_helper'
|
|
4
|
-
|
|
5
|
-
module RedmineWithGit
|
|
6
|
-
module Load
|
|
7
|
-
class Database < ::RedmineWithGit::Load::Base
|
|
8
|
-
include ::RedmineWithGit::DumpLoad::Database
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def before_clear
|
|
13
|
-
raise(<<~MESSAGE) unless ::RedminePluginsHelper::Available.settings?
|
|
14
|
-
Settings table does not exist.
|
|
15
|
-
MESSAGE
|
|
16
|
-
|
|
17
|
-
@redmine_git_hosting_setting = ::Setting.plugin_redmine_git_hosting
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def clear_command
|
|
21
|
-
psql_sql_command(psql_sql_command(drop_all_tables_sql).execute!)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def load_command
|
|
25
|
-
psql_command.prepend(uncompress_args + ['@ESC_|'])
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def after_load
|
|
29
|
-
::Setting.plugin_redmine_git_hosting = @redmine_git_hosting_setting if
|
|
30
|
-
@redmine_git_hosting_setting
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def psql_command
|
|
34
|
-
build_postgres_command('psql')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def psql_sql_command(sql)
|
|
38
|
-
psql_command.append(['-qtc', sql])
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def drop_all_tables_sql
|
|
42
|
-
"select 'drop table \"' || tablename || '\" cascade;' from pg_tables " \
|
|
43
|
-
"where schemaname = 'public';"
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Load
|
|
5
|
-
class Files < ::RedmineWithGit::Load::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::Files
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def clear_command
|
|
11
|
-
env.command('rm', '-rf', "#{files_path}/*")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def load_command
|
|
15
|
-
tar_extract_command(files_path)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineWithGit
|
|
4
|
-
module Load
|
|
5
|
-
class Git < ::RedmineWithGit::Load::Base
|
|
6
|
-
include ::RedmineWithGit::DumpLoad::Git
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def clear_command
|
|
11
|
-
env.command('rm', '-rf', "#{repositories_path}/*").prepend(sudo_command)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run_load
|
|
15
|
-
env.command('mkdir', '-p', repositories_path).prepend(sudo_command).execute!
|
|
16
|
-
super
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def load_command
|
|
20
|
-
tar_extract_command(repositories_path).prepend(sudo_command)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RedmineGitHosting
|
|
4
|
-
module Cache
|
|
5
|
-
module DatabasePatch
|
|
6
|
-
def self.included(base)
|
|
7
|
-
base.prepend(InstanceMethods)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module InstanceMethods
|
|
11
|
-
def apply_cache_limit
|
|
12
|
-
return unless max_cache_elements >= 0 && GitCache.count > max_cache_elements
|
|
13
|
-
|
|
14
|
-
GitCache.order(created_at: :desc).last.destroy
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
patch = RedmineGitHosting::Cache::DatabasePatch
|
|
22
|
-
target = RedmineGitHosting::Cache::Database
|
|
23
|
-
target.send(:include, patch) unless target.include?(patch)
|