avm-tools 0.58.1 → 0.59.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/local_projects.rb +9 -0
  3. data/lib/avm/local_projects/instance.rb +28 -0
  4. data/lib/avm/projects.rb +9 -0
  5. data/lib/avm/projects/stereotype.rb +55 -0
  6. data/lib/avm/projects/stereotypes.rb +20 -0
  7. data/lib/avm/projects/stereotypes/git.rb +25 -0
  8. data/lib/avm/projects/stereotypes/git/publish.rb +15 -0
  9. data/lib/avm/projects/stereotypes/git/warp.rb +27 -0
  10. data/lib/avm/projects/stereotypes/git_subrepo.rb +34 -0
  11. data/lib/avm/projects/stereotypes/git_subrepo/publish.rb +14 -0
  12. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +87 -0
  13. data/lib/avm/projects/stereotypes/git_subtree.rb +51 -0
  14. data/lib/avm/projects/stereotypes/git_subtree/publish.rb +12 -0
  15. data/lib/avm/projects/stereotypes/git_subtree/warp.rb +29 -0
  16. data/lib/avm/projects/stereotypes/rails_application.rb +23 -0
  17. data/lib/avm/projects/stereotypes/redmine_plugin.rb +23 -0
  18. data/lib/avm/projects/stereotypes/ruby_gem.rb +30 -0
  19. data/lib/avm/projects/stereotypes/ruby_gem/publish.rb +129 -0
  20. data/lib/avm/tools/runner/launcher.rb +10 -2
  21. data/lib/avm/tools/runner/launcher/instances.rb +45 -0
  22. data/lib/avm/tools/runner/launcher/projects.rb +50 -0
  23. data/lib/avm/tools/runner/launcher/publish.rb +65 -0
  24. data/lib/avm/tools/runner/local_project.rb +32 -0
  25. data/lib/avm/tools/runner/local_project/info.rb +25 -0
  26. data/lib/avm/tools/version.rb +1 -1
  27. data/lib/eac_launcher.rb +1 -2
  28. data/lib/eac_launcher/git/publish_base.rb +1 -0
  29. data/lib/eac_launcher/git/sub_warp_base.rb +1 -1
  30. data/lib/eac_launcher/git/warp_base.rb +2 -2
  31. data/lib/eac_launcher/instances/base.rb +2 -2
  32. data/lib/eac_launcher/instances/runner_helper.rb +1 -1
  33. data/lib/eac_launcher/paths/logical.rb +2 -2
  34. metadata +25 -21
  35. data/lib/eac_launcher/runner.rb +0 -21
  36. data/lib/eac_launcher/runner/instances.rb +0 -41
  37. data/lib/eac_launcher/runner/projects.rb +0 -46
  38. data/lib/eac_launcher/runner/publish.rb +0 -59
  39. data/lib/eac_launcher/stereotype.rb +0 -52
  40. data/lib/eac_launcher/stereotypes.rb +0 -14
  41. data/lib/eac_launcher/stereotypes/git.rb +0 -21
  42. data/lib/eac_launcher/stereotypes/git/publish.rb +0 -13
  43. data/lib/eac_launcher/stereotypes/git/warp.rb +0 -25
  44. data/lib/eac_launcher/stereotypes/git_subrepo.rb +0 -30
  45. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +0 -12
  46. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +0 -85
  47. data/lib/eac_launcher/stereotypes/git_subtree.rb +0 -47
  48. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +0 -10
  49. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +0 -27
  50. data/lib/eac_launcher/stereotypes/rails.rb +0 -21
  51. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +0 -21
  52. data/lib/eac_launcher/stereotypes/ruby_gem.rb +0 -27
  53. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a3ff307d9acdf109cb9100bce6daf269eb0b8a0b8c2e55769219cb434ad924c
4
- data.tar.gz: c5388fa85a9306f2a9cfceee9e4ae9e10223ce59d500d7d29b1397de4bf21c82
3
+ metadata.gz: '08d973e58416ce742fea0b91630ad75c85c48838f302019cdbd4362594704cb8'
4
+ data.tar.gz: 6984410c1a7cf6e36f846fa6c388abca39b6b5f9eb8aec359b9bf069cd2d74a8
5
5
  SHA512:
6
- metadata.gz: 2a4529f053c88376e1b6bcbb5531a9460e8343aa92af0a0a3bea99327ca2a7fa7e085bb718d972971c4ec5c7e48f30a68cdfdb246360bae509d31b299e691103
7
- data.tar.gz: 20bc88ce9a348b8bd07a3ba09132533ff8a1ed07b9f2f0878281eaccccddec346eb71f5734a70037566a1d9fab2528557f41ac2ecb7129b55f5055ce257e7d14
6
+ metadata.gz: 2d019bdb2a01a137afa8a5e01aeb35b9d29214e185eddad3ab926215bbf0267ca1aa21f57927fea98482f381e09fa52e6ba6497da618bcdcc6f522d7672afa5a
7
+ data.tar.gz: 17f2e21690f779b7c67405e4397343b13083b8cf8984a8b521031f5f65f8998a0f44062099425e6acb6c9d1a33771a21dd487678afe2929a384f3a6c5a89bfc1
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module LocalProjects
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/paths/real'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'avm/projects/stereotypes'
6
+
7
+ module Avm
8
+ module LocalProject
9
+ class Instance
10
+ enable_simple_cache
11
+ common_constructor :path do
12
+ self.path = path.to_pathname
13
+ end
14
+
15
+ # Backward compatibility with [EacLauncher::Paths::Logical].
16
+ # @return [EacLauncher::Paths::Real].
17
+ def real
18
+ ::EacLauncher::Paths::Real.new(path.to_path)
19
+ end
20
+
21
+ private
22
+
23
+ def stereotypes_uncached
24
+ ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Projects
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'colorized_string'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotype
9
+ class << self
10
+ attr_reader :stereotypes
11
+
12
+ def included(base)
13
+ @stereotypes ||= []
14
+ @stereotypes << base
15
+ base.extend(ClassMethods)
16
+ end
17
+
18
+ def git_stereotypes
19
+ stereotypes.select { |c| c.name.demodulize.downcase.match('git') }
20
+ end
21
+
22
+ def nogit_stereotypes
23
+ stereotypes - git_stereotypes
24
+ end
25
+ end
26
+
27
+ module ClassMethods
28
+ def label
29
+ ::ColorizedString.new(stereotype_name).send(color)
30
+ end
31
+
32
+ def stereotype_name
33
+ name.gsub(/^.*::/, '')
34
+ end
35
+
36
+ def publish_class
37
+ sub_class('Publish')
38
+ end
39
+
40
+ def warp_class
41
+ sub_class('Warp')
42
+ end
43
+
44
+ private
45
+
46
+ def sub_class(sub_class_name)
47
+ klass = const_get(sub_class_name)
48
+ klass.is_a?(Class) ? klass : nil
49
+ rescue NameError
50
+ nil
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ require_sub __FILE__, base: nil
10
+
11
+ class << self
12
+ def list
13
+ @list ||= constants.map { |c| const_get(c) }
14
+ .select { |c| c.included_modules.include?(Avm::Projects::Stereotype) }
15
+ .freeze
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class Git
10
+ require_sub __FILE__
11
+ include Avm::Projects::Stereotype
12
+
13
+ class << self
14
+ def match?(path)
15
+ File.directory?(path.real.subpath('.git'))
16
+ end
17
+
18
+ def color
19
+ :white
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/publish_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class Git
9
+ class Publish < ::EacLauncher::Git::PublishBase
10
+ PUBLISH_GIT_REMOTE_NAME = 'publish'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/warp_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class Git
9
+ class Warp < ::EacLauncher::Git::WarpBase
10
+ private
11
+
12
+ def current_ref
13
+ 'HEAD'
14
+ end
15
+
16
+ def source_instance
17
+ instance
18
+ end
19
+
20
+ def source_remote_name
21
+ ::Avm::Projects::Stereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/error'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'avm/projects/stereotype'
6
+
7
+ module Avm
8
+ module Projects
9
+ module Stereotypes
10
+ class GitSubrepo
11
+ require_sub __FILE__
12
+ include Avm::Projects::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ File.exist?(path.real.subpath('.gitrepo')) && subrepo_url(path.real) != 'none'
17
+ end
18
+
19
+ def color
20
+ :light_cyan
21
+ end
22
+
23
+ def subrepo_url(path)
24
+ File.read(path.subpath('.gitrepo')).each_line do |l|
25
+ m = /remote\s*=\s(.+)/.match(l)
26
+ return m[1] if m
27
+ end
28
+ raise ::EacLauncher::Git::Error.new(path, '"remote = ... " not found')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/publish_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class GitSubrepo
9
+ class Publish < ::EacLauncher::Git::PublishBase
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+ require 'eac_launcher/git/sub_warp_base'
5
+ require 'eac_launcher/instances/error'
6
+ require 'eac_launcher/paths/real'
7
+ require 'eac_launcher/vendor/github'
8
+
9
+ module Avm
10
+ module Projects
11
+ module Stereotypes
12
+ class GitSubrepo
13
+ class Warp < ::EacLauncher::Paths::Real
14
+ include ::EacLauncher::Git::SubWarpBase
15
+ include ::EacRubyUtils::SimpleCache
16
+
17
+ attr_reader :instance
18
+
19
+ def initialize(instance)
20
+ @instance = instance
21
+ check_parent
22
+ init_aux
23
+ push_to_aux
24
+ reset
25
+ assert_target_remote
26
+ super(warped_git)
27
+ end
28
+
29
+ private
30
+
31
+ def check_parent
32
+ return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
33
+ parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
34
+
35
+ raise EacLauncher::Instances::Error, "Subrepo parent hash \"#{subrepo_parent_hash}\""\
36
+ " not found in \"#{parent_git_warped}\""
37
+ end
38
+
39
+ def subrepo_parent_hash
40
+ data = parent_git_warped.subrepo_status(to_parent_git_path)
41
+ h = data['Pull Parent']
42
+ return h if h.present?
43
+
44
+ raise EacLauncher::Instances::Error, "Subrepo parent hash is blank: #{data}"
45
+ end
46
+
47
+ def init_aux
48
+ ::EacLauncher::Git::Base.new(aux_path).init_bare
49
+ end
50
+
51
+ def parent_git_warped_uncached
52
+ ::EacLauncher::Git::Base.new(parent_instance.warped)
53
+ end
54
+
55
+ def aux_path
56
+ instance.cache_path('subrepo_aux_git_repository')
57
+ end
58
+
59
+ def warped_git_uncached
60
+ ::EacLauncher::Git::Base.new(instance.cache_path('git_repository'))
61
+ end
62
+
63
+ def push_to_aux
64
+ parent_git_warped.execute!('subrepo', 'branch', to_parent_git_path, '-fF')
65
+ h = parent_git_warped.rev_parse("subrepo/#{to_parent_git_path}", true)
66
+ parent_git_warped.execute!('push', aux_path, "#{h}:refs/heads/master", '--force')
67
+ end
68
+
69
+ def reset
70
+ ::EacLauncher::Git::MirrorUpdate.new(warped_git, aux_path, 'master')
71
+ end
72
+
73
+ def assert_target_remote
74
+ warped_git.assert_remote_url(::EacLauncher::Git::WarpBase::TARGET_REMOTE,
75
+ target_remote_url)
76
+ end
77
+
78
+ def target_remote_url
79
+ ::EacLauncher::Vendor::Github.to_ssh_url(
80
+ parent_git_warped.subrepo_remote_url(to_parent_git_path)
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'avm/projects/stereotypes/git'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Projects
9
+ module Stereotypes
10
+ class GitSubtree
11
+ require_sub __FILE__
12
+ include Avm::Projects::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ return false if other_git_stereotype?(path)
17
+ return false unless other_nogit_stereotype?(path)
18
+
19
+ parent = parent_git(path.parent_path)
20
+ return false unless parent
21
+
22
+ ::Git.open(parent.real).remote(path.real.basename).url ? true : false
23
+ end
24
+
25
+ def color
26
+ :green
27
+ end
28
+
29
+ def parent_git(parent_path)
30
+ return nil unless parent_path
31
+
32
+ if ::Avm::Projects::Stereotypes::Git.match?(parent_path)
33
+ parent_path
34
+ else
35
+ parent_git(parent_path.parent_path)
36
+ end
37
+ end
38
+
39
+ def other_git_stereotype?(path)
40
+ ::Avm::Projects::Stereotypes::Git.match?(path) ||
41
+ ::Avm::Projects::Stereotypes::GitSubrepo.match?(path)
42
+ end
43
+
44
+ def other_nogit_stereotype?(path)
45
+ Avm::Projects::Stereotype.nogit_stereotypes.any? { |s| s.match?(path) }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Projects
5
+ module Stereotypes
6
+ class GitSubtree
7
+ class Publish < ::EacLauncher::Git::PublishBase
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Projects
5
+ module Stereotypes
6
+ class GitSubtree
7
+ class Warp < ::EacLauncher::Git::WarpBase
8
+ include ::EacLauncher::Git::SubWarpBase
9
+
10
+ private
11
+
12
+ def current_ref
13
+ instance.cache_key("git_subtree.parent.#{cache_git.git.object('HEAD').sha}") do
14
+ cache_git.subtree_split(to_parent_git_path)
15
+ end
16
+ end
17
+
18
+ def source_instance
19
+ parent_instance
20
+ end
21
+
22
+ def source_remote_name
23
+ instance.project_name
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end