redmine_with_git 0.1.6 → 0.2.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/app/controllers/redmine_with_git_controller.rb +4 -1
- data/app/helpers/redmine_with_git_helper.rb +8 -6
- data/app/models/redmine_with_git/tableless/load.rb +5 -2
- data/config/initializers/000_dependencies.rb +3 -1
- data/config/initializers/001_patches.rb +2 -0
- data/config/locales/en.yml +8 -0
- data/config/locales/pt-BR.yml +8 -0
- data/config/routes.rb +2 -0
- data/init.rb +2 -0
- data/lib/redmine_with_git/dump/all.rb +5 -3
- data/lib/redmine_with_git/dump/base.rb +50 -11
- data/lib/redmine_with_git/dump/database.rb +2 -0
- data/lib/redmine_with_git/dump/files.rb +2 -0
- data/lib/redmine_with_git/dump/git.rb +2 -0
- data/lib/redmine_with_git/dump_load/all.rb +6 -4
- data/lib/redmine_with_git/dump_load/base.rb +2 -0
- data/lib/redmine_with_git/dump_load/database.rb +2 -0
- data/lib/redmine_with_git/dump_load/files.rb +2 -0
- data/lib/redmine_with_git/dump_load/git.rb +2 -0
- data/lib/redmine_with_git/load/all.rb +2 -0
- data/lib/redmine_with_git/load/base.rb +2 -0
- data/lib/redmine_with_git/load/database.rb +6 -3
- data/lib/redmine_with_git/load/files.rb +2 -0
- data/lib/redmine_with_git/load/git.rb +2 -0
- data/lib/redmine_with_git/patches/redmine_git_hosting/commands/git/git_patch.rb +2 -0
- data/lib/redmine_with_git/version.rb +1 -1
- data/lib/tasks/redmine_with_git.rake +17 -7
- metadata +18 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a34a6641c46dca0c41d62bdc1e816c9f4570092c09115b2e51976e6a42f27faf
|
4
|
+
data.tar.gz: 4d4e3099dae281d66f3b8dd5fd6fa19dff1e9f460eae9edcd6778b0a9d851cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e96d18022267e48569eb1b41195bb68b8684d6a7ce935ba22af72c28d37fb1377a48e152e1a8a00fd48f434fa6f27d2936602731811540b0126adc5679dcf08d
|
7
|
+
data.tar.gz: 5d34f055c0a6ff833f242d63e520d0a9ec9bd2dff7cccf468a1acc8df7183017385b56cbc5b7beba449a4dff7d039ceaa8d65b5a446cc149de3c791feb4be772
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class RedmineWithGitController < ApplicationController
|
2
4
|
before_filter :require_admin
|
3
5
|
|
@@ -42,7 +44,8 @@ class RedmineWithGitController < ApplicationController
|
|
42
44
|
|
43
45
|
def import_params
|
44
46
|
ps = params[::RedmineWithGit::Tableless::Load.model_name.param_key]
|
45
|
-
return {}
|
47
|
+
return {} if ps.blank?
|
48
|
+
|
46
49
|
ps.permit(:path)
|
47
50
|
end
|
48
51
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RedmineWithGitHelper
|
2
4
|
def export_api_curl_command
|
3
5
|
curl_command("curl -JLO '#{export_redmine_with_git_url(key: User.current.api_key)}'")
|
4
6
|
end
|
5
7
|
|
6
8
|
def import_api_curl_command
|
7
|
-
curl_command(
|
8
|
-
curl -X POST \\
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
IMPORT_CURL
|
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_redmine_with_git_url(format: 'json')}
|
14
|
+
IMPORT_CURL
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RedmineWithGit
|
2
4
|
module Tableless
|
3
5
|
class Load < ::EacRailsUtils::TablelessModel
|
@@ -7,10 +9,11 @@ module RedmineWithGit
|
|
7
9
|
|
8
10
|
def save
|
9
11
|
return false unless valid?
|
12
|
+
|
10
13
|
::RedmineWithGit::Load::All.new(path.path)
|
11
14
|
true
|
12
|
-
rescue StandardError =>
|
13
|
-
errors.add(:path,
|
15
|
+
rescue StandardError => e
|
16
|
+
errors.add(:path, e.message)
|
14
17
|
false
|
15
18
|
end
|
16
19
|
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Redmine::Plugin.post_register :redmine_with_git do
|
2
4
|
# Source: https://github.com/esquilo-azul/redmine_plugins_helper
|
3
|
-
requires_redmine_plugin(:redmine_plugins_helper, version_or_higher: '0.
|
5
|
+
requires_redmine_plugin(:redmine_plugins_helper, version_or_higher: '0.5.0')
|
4
6
|
# Source: https://github.com/jbox-web/redmine_bootstrap_kit.git
|
5
7
|
# Note: redmine_bootstrap_kit is a redmine_git_hosting's dependency.
|
6
8
|
requires_redmine_plugin(:redmine_bootstrap_kit, version_or_higher: '0.2.5')
|
data/config/locales/en.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
data/config/routes.rb
CHANGED
data/init.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RedmineWithGit
|
2
4
|
module Dump
|
3
5
|
class All < ::RedmineWithGit::Dump::Base
|
@@ -7,13 +9,13 @@ module RedmineWithGit
|
|
7
9
|
|
8
10
|
def run_command
|
9
11
|
on_temp_dir do
|
10
|
-
RESOURCES.each { |
|
12
|
+
RESOURCES.each { |resource| build_sub(resource) }
|
11
13
|
super
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
def build_sub(
|
16
|
-
resource_class(
|
17
|
+
def build_sub(resource)
|
18
|
+
resource_class(resource).new(resource_file_path(resource), overwrite)
|
17
19
|
end
|
18
20
|
|
19
21
|
def build_command
|
@@ -1,21 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/files/rotate'
|
4
|
+
require 'eac_ruby_utils/listable'
|
5
|
+
|
1
6
|
module RedmineWithGit
|
2
7
|
module Dump
|
3
8
|
class Base < ::RedmineWithGit::DumpLoad::Base
|
4
|
-
|
5
|
-
|
9
|
+
include ::EacRubyUtils::Listable
|
10
|
+
|
11
|
+
lists.add_integer :overwrite, 1 => :denied, 2 => :allowed, 3 => :rotate
|
12
|
+
|
13
|
+
def initialize(path, options = {})
|
14
|
+
@options = options
|
15
|
+
validate_overwrite
|
6
16
|
super(path)
|
7
17
|
end
|
8
18
|
|
9
|
-
|
19
|
+
def overwrite
|
20
|
+
v = @options[:overwrite]
|
21
|
+
v.present? ? v.to_i : OVERWRITE_DENIED
|
22
|
+
end
|
10
23
|
|
11
|
-
|
24
|
+
private
|
12
25
|
|
13
26
|
def run
|
14
27
|
start_banner
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
28
|
+
return unless run_if_overwrite_denied
|
29
|
+
return unless run_if_rotate
|
30
|
+
|
19
31
|
run_command
|
20
32
|
validate_exported
|
21
33
|
end_banner
|
@@ -23,29 +35,56 @@ module RedmineWithGit
|
|
23
35
|
|
24
36
|
def start_banner
|
25
37
|
Rails.logger.info "Dumping resource \"#{resource_name}\" to \"#{path}\"..."
|
38
|
+
Rails.logger.info "Overwrite: #{overwrite}"
|
26
39
|
end
|
27
40
|
|
28
41
|
def end_banner
|
29
42
|
Rails.logger.info("#{path}: #{number_to_human_size(::File.size(path))}, #{path_type}")
|
30
43
|
end
|
31
44
|
|
45
|
+
def run_if_overwrite_denied
|
46
|
+
if ::File.exist?(path) && overwrite == OVERWRITE_DENIED
|
47
|
+
Rails.logger.warn "File \"#{path}\" already exists"
|
48
|
+
false
|
49
|
+
else
|
50
|
+
true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_if_rotate
|
55
|
+
if ::File.exist?(path) && overwrite == OVERWRITE_ROTATE
|
56
|
+
rotate = ::Avm::Files::Rotate.new(path)
|
57
|
+
::Rails.logger.info "Rotating \"#{rotate.source_path}\"..."
|
58
|
+
rotate.run
|
59
|
+
::Rails.logger.info "Rotated to \"#{rotate.target_path}\""
|
60
|
+
end
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
32
64
|
def run_command
|
33
65
|
build_command.execute!(output_file: path)
|
34
66
|
end
|
35
67
|
|
36
68
|
def create_tar_command(dir, compression = true)
|
37
69
|
tar = "cd #{Shellwords.escape(dir)}; tar -c *"
|
38
|
-
tar
|
70
|
+
tar += " | #{compress_args.join(' ')}" if compression
|
39
71
|
env.command(['bash', '-c', tar])
|
40
72
|
end
|
41
73
|
|
42
74
|
def compress_args
|
43
|
-
%w
|
75
|
+
%w[gzip -9 -c -]
|
44
76
|
end
|
45
77
|
|
46
78
|
def validate_exported
|
47
79
|
raise "File \"#{path}\" was not generated" unless ::File.exist?(path)
|
48
|
-
raise "File \"#{path}\" has zero size" unless ::File.size(path)
|
80
|
+
raise "File \"#{path}\" has zero size" unless ::File.size(path).positive?
|
81
|
+
end
|
82
|
+
|
83
|
+
def validate_overwrite
|
84
|
+
klass = ::RedmineWithGit::Dump::Base
|
85
|
+
return if klass.lists.overwrite.values.include?(overwrite)
|
86
|
+
|
87
|
+
raise "Invalid overwrite value: \"#{overwrite}\" (Valid: #{klass.lists.overwrite.values})"
|
49
88
|
end
|
50
89
|
end
|
51
90
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RedmineWithGit
|
2
4
|
module DumpLoad
|
3
5
|
module All
|
4
|
-
DATABASE = 'database.gz'
|
5
|
-
FILES = 'files.tar.gz'
|
6
|
-
GIT = 'git.tar.gz'
|
6
|
+
DATABASE = 'database.gz'
|
7
|
+
FILES = 'files.tar.gz'
|
8
|
+
GIT = 'git.tar.gz'
|
7
9
|
|
8
|
-
RESOURCES = %w
|
10
|
+
RESOURCES = %w[database files git].freeze
|
9
11
|
|
10
12
|
private
|
11
13
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_dependency 'redmine_plugins_helper'
|
2
4
|
|
3
5
|
module RedmineWithGit
|
@@ -8,9 +10,10 @@ module RedmineWithGit
|
|
8
10
|
private
|
9
11
|
|
10
12
|
def before_clear
|
11
|
-
raise(
|
12
|
-
Settings table does not exist.
|
13
|
-
|
13
|
+
raise(<<~MESSAGE) unless ::RedminePluginsHelper.settings_table_exist?
|
14
|
+
Settings table does not exist.
|
15
|
+
MESSAGE
|
16
|
+
|
14
17
|
@redmine_git_hosting_setting = ::Setting.plugin_redmine_git_hosting
|
15
18
|
end
|
16
19
|
|
@@ -1,11 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
namespace :redmine_with_git do
|
2
|
-
%w
|
4
|
+
%w[database files git all].each do |a|
|
3
5
|
namespace :dump do
|
4
|
-
|
5
|
-
|
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
|
+
DESCRIPTION
|
13
|
+
task a, %i[path overwrite] => :environment do |_t, args|
|
14
|
+
::RedmineWithGit::Dump.const_get(a.camelize).new(args.path, overwrite: args.overwrite)
|
6
15
|
end
|
7
16
|
end
|
8
17
|
namespace :load do
|
18
|
+
desc "Load backup file for \"#{a}\" resource(s)"
|
9
19
|
task a, [:path] => :environment do |_t, args|
|
10
20
|
::RedmineWithGit::Load.const_get(a.camelize).new(args.path)
|
11
21
|
end
|
@@ -13,10 +23,10 @@ namespace :redmine_with_git do
|
|
13
23
|
end
|
14
24
|
|
15
25
|
desc 'Executa as operações de "Rescue" da configuração do plugin RedmineGitHosting'
|
16
|
-
task rescue: [
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
task rescue: %i[redmine_git_hosting:install_hook_parameters
|
27
|
+
redmine_git_hosting:migration_tools:update_repositories_type
|
28
|
+
redmine_git_hosting:install_hook_files
|
29
|
+
redmine_git_hosting:fetch_changesets] do |_t, _args|
|
20
30
|
RedmineGitHosting::GitoliteAccessor.update_projects(
|
21
31
|
'all',
|
22
32
|
message: 'Forced resync of all projects (active, closed, archived)...',
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: avm-tools
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: eac_rails_utils
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,20 +44,14 @@ dependencies:
|
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.1.2
|
47
|
+
version: '0.10'
|
37
48
|
type: :runtime
|
38
49
|
prerelease: false
|
39
50
|
version_requirements: !ruby/object:Gem::Requirement
|
40
51
|
requirements:
|
41
52
|
- - "~>"
|
42
53
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.1.2
|
54
|
+
version: '0.10'
|
47
55
|
description:
|
48
56
|
email:
|
49
57
|
executables: []
|