redmine_with_git 0.11.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 +2 -2
- data/lib/redmine_with_git/patches/redmine_git_hosting/commands/{git_patch.rb → git.rb} +1 -1
- data/lib/redmine_with_git/patches/redmine_git_hosting/{gitolite_hook_patch.rb → gitolite_hook.rb} +1 -1
- data/lib/redmine_with_git/version.rb +1 -1
- data/lib/tasks/redmine_with_git.rake +1 -24
- metadata +3 -29
- 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/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
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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
EacRubyUtils.patch_module(
|
|
4
4
|
RedmineGitHosting::GitoliteHook,
|
|
5
|
-
RedmineWithGit::Patches::RedmineGitHosting::
|
|
5
|
+
RedmineWithGit::Patches::RedmineGitHosting::GitoliteHook
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
apply_patches_version_limit = Gem::Version.new('4.0.0')
|
|
@@ -16,6 +16,6 @@ patch = RedmineWithGit::Patches::RedmineGitHosting::Cache::Database
|
|
|
16
16
|
target = RedmineGitHosting::Cache::Database
|
|
17
17
|
target.send(:include, patch) unless target.include?(patch)
|
|
18
18
|
|
|
19
|
-
patch = RedmineWithGit::Patches::RedmineGitHosting::Commands::
|
|
19
|
+
patch = RedmineWithGit::Patches::RedmineGitHosting::Commands::Git
|
|
20
20
|
target = RedmineGitHosting::Commands::Git
|
|
21
21
|
target.send(:include, patch) unless target.include?(patch)
|
|
@@ -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
|
|
@@ -97,18 +97,7 @@ executables: []
|
|
|
97
97
|
extensions: []
|
|
98
98
|
extra_rdoc_files: []
|
|
99
99
|
files:
|
|
100
|
-
- app/controllers/backup_controller.rb
|
|
101
|
-
- app/helpers/redmine_with_git_helper.rb
|
|
102
|
-
- app/models/redmine_with_git/tableless/load.rb
|
|
103
|
-
- app/views/backup/_api.html.erb
|
|
104
|
-
- app/views/backup/_export.html.erb
|
|
105
|
-
- app/views/backup/_import.html.erb
|
|
106
|
-
- app/views/backup/index.html.erb
|
|
107
100
|
- config/initializers/001_patches.rb
|
|
108
|
-
- config/initializers/500_nonproject_modules.rb
|
|
109
|
-
- config/locales/en.yml
|
|
110
|
-
- config/locales/pt-BR.yml
|
|
111
|
-
- config/routes.rb
|
|
112
101
|
- init.rb
|
|
113
102
|
- installer/default_settings.sh
|
|
114
103
|
- installer/programs/linux/sudo_file_exists.sh
|
|
@@ -141,24 +130,9 @@ files:
|
|
|
141
130
|
- installer/template/redmine_git_hosting_setting_value.sql
|
|
142
131
|
- installer/template/redmine_user_sudoer
|
|
143
132
|
- lib/redmine_with_git.rb
|
|
144
|
-
- lib/redmine_with_git/dump/all.rb
|
|
145
|
-
- lib/redmine_with_git/dump/base.rb
|
|
146
|
-
- lib/redmine_with_git/dump/database.rb
|
|
147
|
-
- lib/redmine_with_git/dump/files.rb
|
|
148
|
-
- lib/redmine_with_git/dump/git.rb
|
|
149
|
-
- lib/redmine_with_git/dump_load/all.rb
|
|
150
|
-
- lib/redmine_with_git/dump_load/base.rb
|
|
151
|
-
- lib/redmine_with_git/dump_load/database.rb
|
|
152
|
-
- lib/redmine_with_git/dump_load/files.rb
|
|
153
|
-
- lib/redmine_with_git/dump_load/git.rb
|
|
154
|
-
- lib/redmine_with_git/load/all.rb
|
|
155
|
-
- lib/redmine_with_git/load/base.rb
|
|
156
|
-
- lib/redmine_with_git/load/database.rb
|
|
157
|
-
- lib/redmine_with_git/load/files.rb
|
|
158
|
-
- lib/redmine_with_git/load/git.rb
|
|
159
133
|
- lib/redmine_with_git/patches/redmine_git_hosting/cache/database.rb
|
|
160
|
-
- lib/redmine_with_git/patches/redmine_git_hosting/commands/
|
|
161
|
-
- lib/redmine_with_git/patches/redmine_git_hosting/
|
|
134
|
+
- lib/redmine_with_git/patches/redmine_git_hosting/commands/git.rb
|
|
135
|
+
- lib/redmine_with_git/patches/redmine_git_hosting/gitolite_hook.rb
|
|
162
136
|
- lib/redmine_with_git/version.rb
|
|
163
137
|
- lib/tasks/redmine_with_git.rake
|
|
164
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 %>
|
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
|