avm-tools 0.62.0 → 0.63.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/git/organize.rb +11 -0
  3. data/lib/avm/git/organize/reference_update.rb +34 -0
  4. data/lib/avm/git/organize/repository.rb +76 -0
  5. data/lib/avm/instances/configuration.rb +11 -3
  6. data/lib/avm/instances/configuration/_tests.rb +1 -1
  7. data/lib/avm/launcher/context/instance_manager.rb +76 -0
  8. data/lib/avm/launcher/context/instance_manager/cached_instance.rb +37 -0
  9. data/lib/avm/launcher/context/instance_manager/cached_instances.rb +35 -0
  10. data/lib/avm/launcher/errors/base.rb +10 -0
  11. data/lib/avm/launcher/errors/non_project.rb +15 -0
  12. data/lib/avm/launcher/instances/base.rb +94 -0
  13. data/lib/avm/launcher/instances/base/cache.rb +43 -0
  14. data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +29 -0
  15. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +5 -4
  16. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +1 -1
  17. data/lib/avm/ruby/rubocop/_gemfile.rb +2 -2
  18. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +3 -1
  19. data/lib/avm/tools/runner/git/organize.rb +78 -0
  20. data/lib/avm/tools/version.rb +1 -1
  21. data/lib/eac_launcher/context.rb +2 -2
  22. data/lib/eac_launcher/context/instance_discovery.rb +2 -2
  23. data/lib/eac_launcher/git/base/dirty_files.rb +1 -1
  24. data/lib/eac_launcher/git/sub_warp_base.rb +3 -2
  25. data/lib/eac_launcher/instances.rb +2 -2
  26. data/lib/eac_launcher/instances/error.rb +7 -3
  27. data/lib/eac_launcher/paths/logical.rb +2 -2
  28. data/lib/eac_launcher/publish/base.rb +2 -2
  29. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/install.sh.template +0 -0
  30. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/secrets.yml +0 -0
  31. data/vendor/eac_git/lib/eac_git/local.rb +4 -0
  32. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  33. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +1 -1
  34. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  35. metadata +16 -7
  36. data/lib/eac_launcher/context/instance_manager.rb +0 -95
  37. data/lib/eac_launcher/instances/base.rb +0 -91
  38. data/lib/eac_launcher/instances/base/cache.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37ce02b35f53298066d48205ff8442084a1d702baecb901c91ba3dffe5d2cd0d
4
- data.tar.gz: f4bf6b545744791267fdbdc0eb47f4dc1f0d6b5c1ebef912dd1cbaa8c06b6bfe
3
+ metadata.gz: 855b0d8610e334378c5f061444ae6c414739fa383b9d09d64229ef8014feba53
4
+ data.tar.gz: '09008022bebd8de5a6c3104406c7b5f415f94b1c0f2d84700e92a2b29d4fa530'
5
5
  SHA512:
6
- metadata.gz: a2c271e9d1e95373e7957b55d26b3ffc87b227e1fe4a4d90d94b686e16d4bbf90e40e9be639ab4ea2063698aa42d5e43284472e5e271e3d8e55d4a68acc2e5e3
7
- data.tar.gz: 58d5924ed8c0e329292240d866b7c567bd1eec97f1774d4ef8573fa4d77b09477a07aa6c90e4ae99806f235af4892d752653667d5d9de7dc3806dee507d2a774
6
+ metadata.gz: c4f2e3cb91702b6b93963c1478c38498c0774617538b75a8401ce96b00b505156aeb5d6554c595d5837c678a6f245b86352a57f86056c6599a40f5fbefae3cd7
7
+ data.tar.gz: a577468f0221af04fb6fc08a5f6ada465dc9e64228b4be577ac0b6cbdaed4cd995108ca0f88f713226cadacf4152b1243b18986f3d9212d20742b75a84e651ff
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ class ReferenceUpdate
9
+ enable_listable
10
+ lists.add_symbol :operation, :remove
11
+
12
+ common_constructor :repository, :reference, :operation
13
+
14
+ def run_operation
15
+ send("run_operation_#{operation}")
16
+ end
17
+
18
+ def to_s
19
+ "#{reference} [#{operation}]"
20
+ end
21
+
22
+ private
23
+
24
+ def reference_pathname
25
+ repository.refs_root.join(reference)
26
+ end
27
+
28
+ def run_operation_remove
29
+ reference_pathname.unlink
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ class Repository
9
+ enable_simple_cache
10
+ common_constructor :eac_git_local
11
+
12
+ def collected_references
13
+ @collected_references || []
14
+ end
15
+
16
+ def collect_subrepos
17
+ collect_references_with_pattern(
18
+ %r{\Asubrepo/},
19
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
20
+ )
21
+ collect_references_with_pattern(
22
+ %r{\Aheads/subrepo/},
23
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
24
+ )
25
+ end
26
+
27
+ def collect_originals
28
+ collect_references_with_pattern(
29
+ %r{\Aoriginal/},
30
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
31
+ )
32
+ end
33
+
34
+ def all_branches
35
+ eac_git_local.execute!
36
+ end
37
+
38
+ delegate :to_s, to: :eac_git_local
39
+
40
+ private
41
+
42
+ def all_references
43
+ ::Pathname.glob("#{refs_root}/**/*").select(&:file?)
44
+ .map { |p| p.relative_path_from(refs_root).to_path }
45
+ end
46
+
47
+ def reference_update_by_ref(reference)
48
+ collected_references.find { |ru| ru.reference == reference }
49
+ end
50
+
51
+ def collect_reference(reference, operation)
52
+ new_ru = ::Avm::Git::Organize::ReferenceUpdate.new(self, reference, operation)
53
+ reference_update_by_ref(new_ru.reference).if_present do |ru_found|
54
+ raise "Reference #{new_ru} already added (#{ru_found})"
55
+ end
56
+ @collected_references ||= []
57
+ @collected_references << new_ru
58
+ end
59
+
60
+ def collect_references_with_pattern(pattern, operation)
61
+ references_with_pattern(pattern).each do |reference|
62
+ collect_reference(reference, operation)
63
+ end
64
+ end
65
+
66
+ def references_with_pattern(pattern)
67
+ all_references.select { |reference| pattern.if_match(reference, false) }
68
+ end
69
+
70
+ def refs_root_uncached
71
+ eac_git_local.root_path / '.git' / 'refs'
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -17,15 +17,23 @@ module Avm
17
17
  internal_find_path(path.expand_path)
18
18
  end
19
19
 
20
- private
21
-
22
- def internal_find_path(absolute_pathname)
20
+ def find_in_path(path)
21
+ absolute_pathname = path.to_pathname.expand_path
23
22
  if absolute_pathname.directory?
24
23
  FILENAMES.each do |filename|
25
24
  file = absolute_pathname.join(filename)
26
25
  return new(file) if file.exist?
27
26
  end
28
27
  end
28
+ nil
29
+ end
30
+
31
+ private
32
+
33
+ def internal_find_path(absolute_pathname)
34
+ r = find_in_path(absolute_pathname)
35
+ return r if r.present?
36
+
29
37
  internal_find_path(absolute_pathname.dirname) unless absolute_pathname.root?
30
38
  end
31
39
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gems_utils/gem'
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
4
 
5
5
  module Avm
6
6
  module Instances
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_launcher/publish/check_result'
5
+ require('yaml')
6
+
7
+ module Avm
8
+ module Launcher
9
+ class Context
10
+ class InstanceManager
11
+ require_sub __FILE__
12
+ enable_simple_cache
13
+ common_constructor :context
14
+
15
+ def publish_state_set(instance, stereotype_name, check_status)
16
+ data = cached_instances_file_content_uncached
17
+ data[instance.logical] ||= {}
18
+ data[instance.logical][:publish_state] ||= {}
19
+ data[instance.logical][:publish_state][stereotype_name] = check_status
20
+ write_cache_file(data)
21
+ end
22
+
23
+ def pending_instances
24
+ instances.select { |instance| pending_instance?(instance) }
25
+ end
26
+
27
+ private
28
+
29
+ def instances_uncached
30
+ (cached_instances || search_instances).select(&:included?)
31
+ end
32
+
33
+ def search_instances
34
+ cache_instances(::EacLauncher::Context::InstanceDiscovery.new(context).instances)
35
+ end
36
+
37
+ def cached_instances
38
+ return nil if context.recache
39
+ return nil unless cached_instances_file_content
40
+
41
+ CachedInstances.new(self, cached_instances_file_content).instances
42
+ end
43
+
44
+ def cached_instances_file_content_uncached
45
+ r = YAML.load_file(cache_file_path)
46
+ r.is_a?(::Hash) ? r : nil
47
+ rescue Errno::ENOENT
48
+ nil
49
+ end
50
+
51
+ def cache_instances(instances)
52
+ write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
53
+ instances
54
+ end
55
+
56
+ def write_cache_file(data)
57
+ ::File.write(cache_file_path, data.to_yaml)
58
+ end
59
+
60
+ def cache_file_path
61
+ ::File.join(context.cache_root, 'instances.yml')
62
+ end
63
+
64
+ def pending_instance?(instance)
65
+ data = cached_instances_file_content
66
+ return false unless data[instance.logical]
67
+ return false unless data[instance.logical][:publish_state].is_a?(Hash)
68
+
69
+ data[instance.logical][:publish_state].any? do |_k, v|
70
+ ::EacLauncher::Publish::CheckResult.pending_status?(v)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Launcher
8
+ class Context
9
+ class InstanceManager
10
+ class CachedInstance
11
+ enable_console_speaker
12
+ enable_simple_cache
13
+ common_constructor :cached_instances, :data
14
+
15
+ private
16
+
17
+ def instance_uncached
18
+ ::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
19
+ rescue ::Avm::Launcher::Errors::NonProject
20
+ warn "Cached instance \"#{data[:logical]}\" not found"
21
+ nil
22
+ end
23
+
24
+ def parent_instance_uncached
25
+ data[:parent]
26
+ .if_present { |v| cached_instances.by_logical_path(v) }
27
+ .if_present(&:instance)
28
+ end
29
+
30
+ def path_uncached
31
+ ::EacLauncher::Paths::Logical.from_h(cached_instances.context, data)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/context/instance_manager/cached_instance'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Launcher
8
+ class Context
9
+ class InstanceManager
10
+ class CachedInstances
11
+ enable_simple_cache
12
+ common_constructor :context, :content
13
+
14
+ def instances
15
+ content.keys.map { |k| by_logical_path(k).instance }.reject(&:blank?)
16
+ end
17
+
18
+ def by_logical_path(key)
19
+ cached_instances[key].if_blank do
20
+ cached_instances[key] = ::Avm::Launcher::Context::InstanceManager::CachedInstance.new(
21
+ self, content.fetch(key)
22
+ )
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def cached_instances_uncached
29
+ {}
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Errors
6
+ class Base < ::StandardError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/errors/base'
4
+
5
+ module Avm
6
+ module Launcher
7
+ module Errors
8
+ class NonProject < ::Avm::Launcher::Errors::Base
9
+ def initialize(path)
10
+ super("#{path} is not a project")
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base/cache'
4
+ require 'avm/launcher/errors/non_project'
5
+
6
+ module Avm
7
+ module Launcher
8
+ module Instances
9
+ module Base
10
+ class << self
11
+ def extend_object(object)
12
+ object.extend ::EacRubyUtils::SimpleCache
13
+ object.extend ::EacRubyUtils::Console::Speaker
14
+ object.extend ::Avm::Launcher::Instances::Base::Cache
15
+ super
16
+ end
17
+
18
+ def instanciate(path, parent)
19
+ unless path.is_a?(::Avm::Launcher::Instances::Base)
20
+ raise ::Avm::Launcher::Errors::NonProject, path unless path.project?
21
+
22
+ path.extend(::Avm::Launcher::Instances::Base)
23
+ path.parent = parent
24
+ end
25
+ path
26
+ end
27
+ end
28
+
29
+ attr_accessor :parent
30
+
31
+ def name
32
+ logical
33
+ end
34
+
35
+ def stereotype?(stereotype)
36
+ stereotypes.include?(stereotype)
37
+ end
38
+
39
+ def to_parent_path
40
+ return self unless @parent
41
+
42
+ logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
43
+ end
44
+
45
+ def project?
46
+ stereotypes.any?
47
+ end
48
+
49
+ def publish_run
50
+ stereotypes.each do |s|
51
+ next unless publish?(s)
52
+
53
+ infov(name, "publishing #{s.label}")
54
+ s.publish_class.new(self).run
55
+ end
56
+ end
57
+
58
+ def publish_check
59
+ stereotypes.each do |s|
60
+ next unless publish?(s)
61
+
62
+ puts "#{name.to_s.cyan}|#{s.label}|" \
63
+ "#{s.publish_class.new(self).check}"
64
+ end
65
+ end
66
+
67
+ def project_name
68
+ ::File.basename(logical)
69
+ end
70
+
71
+ def included?
72
+ !::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
73
+ end
74
+
75
+ def to_h
76
+ super.to_h.merge(parent: parent ? parent.logical : nil)
77
+ end
78
+
79
+ private
80
+
81
+ def publish?(stereotype)
82
+ return false unless stereotype.publish_class
83
+
84
+ filter = ::EacLauncher::Context.current.publish_options[:stereotype]
85
+ filter.blank? ? true : filter == stereotype.name.demodulize
86
+ end
87
+
88
+ def options_uncached
89
+ ::EacLauncher::Context.current.settings.instance_settings(self)
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Instances
6
+ module Base
7
+ module Cache
8
+ def cache_path(subpath)
9
+ File.join(cache_root, subpath)
10
+ end
11
+
12
+ def cache_key(key, &block)
13
+ v = cache_key_get(key)
14
+ return v if v.present? || block.nil?
15
+
16
+ v = yield
17
+ cache_key_write(key, v)
18
+ v
19
+ end
20
+
21
+ private
22
+
23
+ def cache_key_get(key)
24
+ File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
25
+ end
26
+
27
+ def cache_key_write(key, value)
28
+ FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
29
+ File.write(cache_key_path(key), value)
30
+ end
31
+
32
+ def cache_key_path(key)
33
+ File.join(cache_root, 'keys', key.parameterize)
34
+ end
35
+
36
+ def cache_root
37
+ File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/configuration'
4
+ require 'eac_ruby_gems_utils/gem'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Patches
9
+ module EacRubyGemsUtils
10
+ module Gem
11
+ enable_simple_cache
12
+
13
+ private
14
+
15
+ def configuration_uncached
16
+ ::Avm::Instances::Configuration.find_in_path(root)
17
+ end
18
+
19
+ def gemfile_path_uncached
20
+ return super unless configuration.present? && configuration.rubocop_gemfile.present?
21
+
22
+ configuration.rubocop_gemfile
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ ::EacRubyGemsUtils::Gem.prepend(::Avm::Patches::EacRubyGemsUtils::Gem)
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/simple_cache'
4
4
  require 'eac_launcher/git/sub_warp_base'
5
- require 'eac_launcher/instances/error'
5
+ require 'avm/launcher/errors/base'
6
6
  require 'eac_launcher/paths/real'
7
7
  require 'eac_launcher/vendor/github'
8
8
 
@@ -32,8 +32,9 @@ module Avm
32
32
  return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
33
33
  parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
34
34
 
35
- raise EacLauncher::Instances::Error, "Subrepo parent hash \"#{subrepo_parent_hash}\""\
36
- " not found in \"#{parent_git_warped}\""
35
+ raise EacLauncher::Instances::Errors::Base,
36
+ "Subrepo parent hash \"#{subrepo_parent_hash}\"" \
37
+ " not found in \"#{parent_git_warped}\""
37
38
  end
38
39
 
39
40
  def subrepo_parent_hash
@@ -41,7 +42,7 @@ module Avm
41
42
  h = data['Pull Parent']
42
43
  return h if h.present?
43
44
 
44
- raise EacLauncher::Instances::Error, "Subrepo parent hash is blank: #{data}"
45
+ raise EacLauncher::Instances::Errors::Base, "Subrepo parent hash is blank: #{data}"
45
46
  end
46
47
 
47
48
  def init_aux
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gems_utils/gem'
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gems_utils/gem'
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
  require 'eac_ruby_utils/on_clean_ruby_environment'
6
6
 
@@ -14,7 +14,7 @@ module Avm
14
14
  end
15
15
 
16
16
  def rubocop_command_by_gemfile_path(path)
17
- ::EacRubyGemsUtils::Gem.new(path).bundle('exec', 'rubocop')
17
+ ::EacRubyGemsUtils::Gem.new(path).bundle('exec', 'rubocop').chdir_root
18
18
  end
19
19
 
20
20
  def rubocop_gemfile?
@@ -32,7 +32,9 @@ module Avm
32
32
  end
33
33
 
34
34
  def stereotype_module
35
- "Avm::Stereotypes::#{stereotype_name}".constantize
35
+ ::Avm::Stereotypes.const_get(stereotype_name)
36
+ rescue ::NameError
37
+ ::Avm.const_get(stereotype_name)
36
38
  end
37
39
 
38
40
  def stereotype_name
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/organize/repository'
4
+ require 'eac_cli/default_runner'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Git < ::EacRubyUtils::Console::DocoptRunner
11
+ class Organize < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacCli::DefaultRunner
13
+
14
+ runner_definition do
15
+ desc 'Organize branches.'
16
+ bool_opt '-a', '--all', 'Run all organizations.'
17
+ bool_opt '-n', '--no', 'Do not run operations.'
18
+ bool_opt '-o', '--originals', 'Remove refs/original branches.'
19
+ bool_opt '-s', '--subrepos', 'Remove git-subrepo branches.'
20
+ bool_opt '-y', '--yes', 'Run operations without confirmation.'
21
+ end
22
+
23
+ def run
24
+ start_banner
25
+ collect_references
26
+ after_collect_banner
27
+ run_operations
28
+ end
29
+
30
+ private
31
+
32
+ def after_collect_banner
33
+ infov 'Collected references', repository.collected_references.count
34
+ repository.collected_references.each do |ru|
35
+ infov " * #{ru.reference}", ru.operation
36
+ end
37
+ end
38
+
39
+ def collect?(type)
40
+ options.fetch("--#{type}") || options.fetch('--all')
41
+ end
42
+
43
+ def collect_references
44
+ %w[subrepos originals].each do |type|
45
+ repository.send("collect_#{type}") if collect?(type)
46
+ end
47
+ end
48
+
49
+ def run_operations
50
+ return warn('No operations to run (Run with --help to see options)') if
51
+ repository.collected_references.empty?
52
+ return unless run_operations?
53
+
54
+ repository.collected_references.each do |ru|
55
+ info "Doing operation #{ru}..."
56
+ ru.run_operation
57
+ end
58
+ end
59
+
60
+ def run_operations?
61
+ return true if options.fetch('--yes')
62
+ return false if options.fetch('--no')
63
+
64
+ request_input('Confirm operations?', bool: true)
65
+ end
66
+
67
+ def repository_uncached
68
+ ::Avm::Git::Organize::Repository.new(context(:git).eac_git)
69
+ end
70
+
71
+ def start_banner
72
+ infov 'Repository', repository
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.62.0'
5
+ VERSION = '0.63.0'
6
6
  end
7
7
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/hash/indifferent_access'
4
+ require 'avm/launcher/context/instance_manager'
4
5
  require 'eac_ruby_utils/simple_cache'
5
6
  require 'eac_ruby_utils/console/speaker'
6
7
  require 'eac_launcher/context/instance_discovery'
7
- require 'eac_launcher/context/instance_manager'
8
8
  require 'eac_launcher/context/settings'
9
9
  require 'eac_launcher/paths/logical'
10
10
  require 'eac_launcher/project'
@@ -39,7 +39,7 @@ module EacLauncher
39
39
  @settings = ::EacLauncher::Context::Settings.new(build_option(:settings_file))
40
40
  @cache_root = build_option(:cache_root)
41
41
  @publish_options = { new: false, confirm: false, stereotype: nil }
42
- @instance_manager = ::EacLauncher::Context::InstanceManager.new(self)
42
+ @instance_manager = ::Avm::Launcher::Context::InstanceManager.new(self)
43
43
  @recache = false
44
44
  end
45
45
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ruby-progressbar'
4
- require 'eac_launcher/instances/base'
4
+ require 'avm/launcher/instances/base'
5
5
 
6
6
  module EacLauncher
7
7
  class Context
@@ -22,7 +22,7 @@ module EacLauncher
22
22
  update_progress_format(path)
23
23
  on_rescued_path_instances(path) do |r|
24
24
  if path.project?
25
- parent_instance = ::EacLauncher::Instances::Base.instanciate(path, parent_instance)
25
+ parent_instance = ::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
26
26
  r << path
27
27
  end
28
28
  children = path.children
@@ -6,7 +6,7 @@ module EacLauncher
6
6
  module Git
7
7
  class Base < ::EacLauncher::Paths::Real
8
8
  module DirtyFiles
9
- delegate :dirty, to: :eac_git
9
+ delegate :dirty?, to: :eac_git
10
10
 
11
11
  def dirty_files
12
12
  eac_git.dirty_files.map do |df|
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher/instances/error'
3
+ require 'avm/projects/stereotype'
4
+ require 'avm/launcher/errors/base'
4
5
 
5
6
  module EacLauncher
6
7
  module Git
@@ -11,7 +12,7 @@ module EacLauncher
11
12
  r = find_parent_instance(instance.parent)
12
13
  return r if r
13
14
 
14
- ::EacLauncher::Instances::Error.new('Git parent not found')
15
+ ::EacLauncher::Instances::Errors::Base.new('Git parent not found')
15
16
  end
16
17
 
17
18
  def find_parent_instance(current)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher/instances/base'
4
- require 'eac_launcher/instances/error'
3
+ require 'avm/launcher/errors/base'
4
+ require 'avm/launcher/instances/base'
5
5
  require 'eac_launcher/instances/runner_helper'
6
6
  require 'eac_launcher/instances/settings'
@@ -1,8 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module EacLauncher
4
- module Instances
5
- class Error < StandardError
3
+ module Avm
4
+ module Launcher
5
+ module Instances
6
+ module Errors
7
+ class Error < StandardError
8
+ end
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/stereotypes'
3
+ require 'avm/projects/stereotypes'
4
4
  require 'eac_launcher/paths/real'
5
5
 
6
6
  module EacLauncher
@@ -68,7 +68,7 @@ module EacLauncher
68
68
  end
69
69
 
70
70
  def warped_uncached
71
- if is_a?(::EacLauncher::Instances::Base)
71
+ if is_a?(::Avm::Launcher::Instances::Base)
72
72
  stereotypes.each do |s|
73
73
  return s.warp_class.new(self) if s.warp_class
74
74
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher/instances/error'
3
+ require 'avm/launcher/errors/base'
4
4
 
5
5
  module EacLauncher
6
6
  module Publish
@@ -35,7 +35,7 @@ module EacLauncher
35
35
 
36
36
  def check_with_rescue
37
37
  internal_check
38
- rescue ::EacLauncher::Instances::Error => e
38
+ rescue ::EacLauncher::Instances::Errors::Base => e
39
39
  ::EacLauncher::Publish::CheckResult.blocked("Error: #{e}")
40
40
  rescue ::EacLauncher::Git::Error => e
41
41
  ::EacLauncher::Publish::CheckResult.blocked("Git error: #{e}")
@@ -48,6 +48,10 @@ module EacGit
48
48
  ::EacGit::Local::Subrepo.new(self, subpath)
49
49
  end
50
50
 
51
+ def to_s
52
+ "#{self.class}[#{root_path}]"
53
+ end
54
+
51
55
  private
52
56
 
53
57
  def merge_base_pair(commit1, commit2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -64,7 +64,7 @@ module EacRubyGemsUtils
64
64
  end
65
65
 
66
66
  def gemfile_lock_path_uncached
67
- root.join('Gemfile.lock')
67
+ gemfile_path.basename_sub { |b| "#{b}.lock" }
68
68
  end
69
69
 
70
70
  def gemspec_path_uncached
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.0
4
+ version: 0.63.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -336,6 +336,9 @@ files:
336
336
  - lib/avm/git/issue/complete/_validations.rb
337
337
  - lib/avm/git/issue/complete/_working_tree.rb
338
338
  - lib/avm/git/issue/complete/validation.rb
339
+ - lib/avm/git/organize.rb
340
+ - lib/avm/git/organize/reference_update.rb
341
+ - lib/avm/git/organize/repository.rb
339
342
  - lib/avm/git/revision_test.rb
340
343
  - lib/avm/git/spec_helper.rb
341
344
  - lib/avm/git/subrepo_check.rb
@@ -363,10 +366,18 @@ files:
363
366
  - lib/avm/instances/entries.rb
364
367
  - lib/avm/instances/entries/entry_reader.rb
365
368
  - lib/avm/instances/entry_keys.rb
369
+ - lib/avm/launcher/context/instance_manager.rb
370
+ - lib/avm/launcher/context/instance_manager/cached_instance.rb
371
+ - lib/avm/launcher/context/instance_manager/cached_instances.rb
372
+ - lib/avm/launcher/errors/base.rb
373
+ - lib/avm/launcher/errors/non_project.rb
374
+ - lib/avm/launcher/instances/base.rb
375
+ - lib/avm/launcher/instances/base/cache.rb
366
376
  - lib/avm/local_projects.rb
367
377
  - lib/avm/local_projects/instance.rb
368
378
  - lib/avm/local_projects/jobs/update.rb
369
379
  - lib/avm/patches.rb
380
+ - lib/avm/patches/eac_ruby_gems_utils/gem.rb
370
381
  - lib/avm/patches/object/template.rb
371
382
  - lib/avm/path_string.rb
372
383
  - lib/avm/projects.rb
@@ -467,6 +478,7 @@ files:
467
478
  - lib/avm/tools/runner/git/deploy.rb
468
479
  - lib/avm/tools/runner/git/dirty_files.rb
469
480
  - lib/avm/tools/runner/git/issue.rb
481
+ - lib/avm/tools/runner/git/organize.rb
470
482
  - lib/avm/tools/runner/git/revisions_test.rb
471
483
  - lib/avm/tools/runner/git/subrepo.rb
472
484
  - lib/avm/tools/runner/git/subrepo/check.rb
@@ -487,7 +499,6 @@ files:
487
499
  - lib/eac_launcher.rb
488
500
  - lib/eac_launcher/context.rb
489
501
  - lib/eac_launcher/context/instance_discovery.rb
490
- - lib/eac_launcher/context/instance_manager.rb
491
502
  - lib/eac_launcher/context/settings.rb
492
503
  - lib/eac_launcher/git.rb
493
504
  - lib/eac_launcher/git/base.rb
@@ -503,8 +514,6 @@ files:
503
514
  - lib/eac_launcher/git/sub_warp_base.rb
504
515
  - lib/eac_launcher/git/warp_base.rb
505
516
  - lib/eac_launcher/instances.rb
506
- - lib/eac_launcher/instances/base.rb
507
- - lib/eac_launcher/instances/base/cache.rb
508
517
  - lib/eac_launcher/instances/error.rb
509
518
  - lib/eac_launcher/instances/runner_helper.rb
510
519
  - lib/eac_launcher/instances/settings.rb
@@ -522,6 +531,8 @@ files:
522
531
  - lib/eac_launcher/vendor.rb
523
532
  - lib/eac_launcher/vendor/github.rb
524
533
  - lib/eac_launcher/version.rb
534
+ - template/avm/eac_redmine_base0/deploy/config/install.sh.template
535
+ - template/avm/eac_redmine_base0/deploy/config/secrets.yml
525
536
  - template/avm/ruby/gems/generator/gemspec.template
526
537
  - template/avm/ruby/gems/generator/root_lib.template
527
538
  - template/avm/ruby/gems/generator/static/Gemfile
@@ -531,8 +542,6 @@ files:
531
542
  - template/avm/self/docker_image/Dockerfile
532
543
  - template/avm/self/docker_image/entrypoint.sh
533
544
  - template/avm/stereotypes/eac_rails_base0/deploy/config/database.yml.template
534
- - template/avm/stereotypes/eac_redmine_base0/deploy/config/install.sh.template
535
- - template/avm/stereotypes/eac_redmine_base0/deploy/config/secrets.yml
536
545
  - template/avm/stereotypes/eac_ubuntu_base0/docker_image/Dockerfile
537
546
  - template/avm/stereotypes/eac_webapp_base0/apache_host/no_ssl.conf
538
547
  - template/avm/stereotypes/eac_wordpress_base0/deploy/wp-config.php.template
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_launcher/publish/check_result'
4
- require('yaml')
5
-
6
- module EacLauncher
7
- class Context
8
- class InstanceManager
9
- include ::EacRubyUtils::SimpleCache
10
-
11
- def initialize(context)
12
- @context = context
13
- end
14
-
15
- def publish_state_set(instance, stereotype_name, check_status)
16
- data = cached_instances_file_content_uncached
17
- data[instance.logical] ||= {}
18
- data[instance.logical][:publish_state] ||= {}
19
- data[instance.logical][:publish_state][stereotype_name] = check_status
20
- write_cache_file(data)
21
- end
22
-
23
- def pending_instances
24
- instances.select { |instance| pending_instance?(instance) }
25
- end
26
-
27
- private
28
-
29
- def instances_uncached
30
- (cached_instances || search_instances).select(&:included?)
31
- end
32
-
33
- def search_instances
34
- cache_instances(::EacLauncher::Context::InstanceDiscovery.new(@context).instances)
35
- end
36
-
37
- def cached_instances
38
- return nil if @context.recache
39
- return nil unless cached_instances_file_content
40
-
41
- CachedInstances.new(cached_instances_file_content).instances
42
- end
43
-
44
- def cached_instances_file_content_uncached
45
- r = YAML.load_file(cache_file_path)
46
- r.is_a?(::Hash) ? r : nil
47
- rescue Errno::ENOENT
48
- nil
49
- end
50
-
51
- def cache_instances(instances)
52
- write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
53
- instances
54
- end
55
-
56
- def write_cache_file(data)
57
- ::File.write(cache_file_path, data.to_yaml)
58
- end
59
-
60
- def cache_file_path
61
- ::File.join(@context.cache_root, 'instances.yml')
62
- end
63
-
64
- def pending_instance?(instance)
65
- data = cached_instances_file_content
66
- return false unless data[instance.logical]
67
- return false unless data[instance.logical][:publish_state].is_a?(Hash)
68
-
69
- data[instance.logical][:publish_state].any? do |_k, v|
70
- ::EacLauncher::Publish::CheckResult.pending_status?(v)
71
- end
72
- end
73
-
74
- class CachedInstances
75
- def initialize(content)
76
- @content = content
77
- @instances = {}
78
- end
79
-
80
- def instances
81
- @content.keys.map { |k| by_logical_path(k) }
82
- end
83
-
84
- def by_logical_path(key)
85
- return @instances[key] if @instances.key?(key)
86
-
87
- h = @content[key]
88
- parent_instance = h[:parent] ? by_logical_path(h[:parent]) : nil
89
- path = ::EacLauncher::Paths::Logical.from_h(@context, h)
90
- @instances[key] = ::EacLauncher::Instances::Base.instanciate(path, parent_instance)
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base/cache'
4
-
5
- module EacLauncher
6
- module Instances
7
- module Base
8
- class << self
9
- def extend_object(object)
10
- object.extend ::EacRubyUtils::SimpleCache
11
- object.extend ::EacRubyUtils::Console::Speaker
12
- object.extend ::EacLauncher::Instances::Base::Cache
13
- super
14
- end
15
-
16
- def instanciate(path, parent)
17
- unless path.is_a?(::EacLauncher::Instances::Base)
18
- raise "#{path} is not a project" unless path.project?
19
-
20
- path.extend(::EacLauncher::Instances::Base)
21
- path.parent = parent
22
- end
23
- path
24
- end
25
- end
26
-
27
- attr_accessor :parent
28
-
29
- def name
30
- logical
31
- end
32
-
33
- def stereotype?(stereotype)
34
- stereotypes.include?(stereotype)
35
- end
36
-
37
- def to_parent_path
38
- return self unless @parent
39
-
40
- logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
41
- end
42
-
43
- def project?
44
- stereotypes.any?
45
- end
46
-
47
- def publish_run
48
- stereotypes.each do |s|
49
- next unless publish?(s)
50
-
51
- infov(name, "publishing #{s.label}")
52
- s.publish_class.new(self).run
53
- end
54
- end
55
-
56
- def publish_check
57
- stereotypes.each do |s|
58
- next unless publish?(s)
59
-
60
- puts "#{name.to_s.cyan}|#{s.label}|" \
61
- "#{s.publish_class.new(self).check}"
62
- end
63
- end
64
-
65
- def project_name
66
- ::File.basename(logical)
67
- end
68
-
69
- def included?
70
- !::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
71
- end
72
-
73
- def to_h
74
- super.to_h.merge(parent: parent ? parent.logical : nil)
75
- end
76
-
77
- private
78
-
79
- def publish?(stereotype)
80
- return false unless stereotype.publish_class
81
-
82
- filter = ::EacLauncher::Context.current.publish_options[:stereotype]
83
- filter.blank? ? true : filter == stereotype.name.demodulize
84
- end
85
-
86
- def options_uncached
87
- ::EacLauncher::Context.current.settings.instance_settings(self)
88
- end
89
- end
90
- end
91
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacLauncher
4
- module Instances
5
- module Base
6
- module Cache
7
- def cache_path(subpath)
8
- File.join(cache_root, subpath)
9
- end
10
-
11
- def cache_key(key, &block)
12
- v = cache_key_get(key)
13
- return v if v.present? || block.nil?
14
-
15
- v = yield
16
- cache_key_write(key, v)
17
- v
18
- end
19
-
20
- private
21
-
22
- def cache_key_get(key)
23
- File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
24
- end
25
-
26
- def cache_key_write(key, value)
27
- FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
28
- File.write(cache_key_path(key), value)
29
- end
30
-
31
- def cache_key_path(key)
32
- File.join(cache_root, 'keys', key.parameterize)
33
- end
34
-
35
- def cache_root
36
- File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
37
- end
38
- end
39
- end
40
- end
41
- end