avm-tools 0.139.0 → 0.141.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/projects/stereotypes/git/publish.rb +2 -2
  3. data/lib/avm/projects/stereotypes/git/warp.rb +2 -2
  4. data/lib/avm/projects/stereotypes/git.rb +2 -2
  5. data/lib/avm/projects/stereotypes/git_subrepo/publish.rb +2 -2
  6. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +7 -7
  7. data/lib/avm/projects/stereotypes/git_subrepo.rb +4 -4
  8. data/lib/avm/projects/stereotypes/git_subtree/publish.rb +2 -2
  9. data/lib/avm/projects/stereotypes/git_subtree/warp.rb +4 -4
  10. data/lib/avm/projects/stereotypes/git_subtree.rb +3 -3
  11. data/lib/avm/projects/stereotypes/ruby_gem/publish.rb +2 -2
  12. data/lib/avm/projects/stereotypes/ruby_gem.rb +4 -4
  13. data/lib/avm/projects/stereotypes.rb +0 -9
  14. data/lib/avm/tools/core_ext.rb +0 -1
  15. data/lib/avm/tools/runner/files/format.rb +2 -2
  16. data/lib/avm/tools/runner/git/commit.rb +2 -2
  17. data/lib/avm/tools/runner/git/deploy.rb +2 -2
  18. data/lib/avm/tools/runner/git.rb +2 -2
  19. data/lib/avm/tools/runner/launcher.rb +1 -0
  20. data/lib/avm/tools/runner/source/info.rb +0 -4
  21. data/lib/avm/tools/runner/source/test.rb +1 -1
  22. data/lib/avm/tools/runner/source.rb +0 -12
  23. data/lib/avm/tools/version.rb +1 -1
  24. metadata +8 -40
  25. data/lib/avm/launcher/git/base/class_methods.rb +0 -28
  26. data/lib/avm/launcher/git/base/dirty_files.rb +0 -23
  27. data/lib/avm/launcher/git/base/remotes.rb +0 -40
  28. data/lib/avm/launcher/git/base/subrepo.rb +0 -44
  29. data/lib/avm/launcher/git/base/underlying.rb +0 -63
  30. data/lib/avm/launcher/git/base.rb +0 -86
  31. data/lib/avm/launcher/git/error.rb +0 -13
  32. data/lib/avm/launcher/git/mirror_update.rb +0 -38
  33. data/lib/avm/launcher/git/publish_base.rb +0 -125
  34. data/lib/avm/launcher/git/remote.rb +0 -55
  35. data/lib/avm/launcher/git/sub_warp_base.rb +0 -33
  36. data/lib/avm/launcher/git/warp_base.rb +0 -67
  37. data/lib/avm/launcher/git.rb +0 -7
  38. data/lib/avm/launcher/instances.rb +0 -6
  39. data/lib/avm/launcher/paths.rb +0 -4
  40. data/lib/avm/launcher/project.rb +0 -18
  41. data/lib/avm/launcher/publish.rb +0 -4
  42. data/lib/avm/launcher/ruby/gem/build.rb +0 -125
  43. data/lib/avm/launcher/ruby/gem/specification.rb +0 -63
  44. data/lib/avm/launcher/ruby/gem.rb +0 -4
  45. data/lib/avm/launcher/ruby.rb +0 -3
  46. data/lib/avm/patches/i18n.rb +0 -22
  47. data/lib/avm/patches.rb +0 -9
  48. data/lib/avm/projects/stereotype/job_comparator.rb +0 -32
  49. data/lib/avm/projects/stereotype.rb +0 -63
  50. data/lib/avm/projects/stereotypes/rails_application/local_project_mixin.rb +0 -18
  51. data/lib/avm/projects/stereotypes/rails_application.rb +0 -25
  52. data/lib/avm/projects/stereotypes/redmine_plugin.rb +0 -23
  53. data/lib/avm/stereotypes.rb +0 -9
  54. data/lib/avm/tools/source.rb +0 -64
  55. data/locale/en.yml +0 -7
  56. data/locale/pt-BR.yml +0 -7
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/object'
4
-
5
- module Avm
6
- module Launcher
7
- module Git
8
- class Base < ::Avm::Launcher::Paths::Real
9
- module Subrepo
10
- def subrepo_status(subrepo_path)
11
- s = execute!('subrepo', 'status', subrepo_path.gsub(%r{\A/}, ''))
12
- raise s.strip.to_s if s.include?('is not a subrepo')
13
-
14
- r = subrepo_status_parse_output(s)
15
- raise "Empty subrepo status for |#{s}|\n" unless r.any?
16
-
17
- r
18
- end
19
-
20
- def subrepo_remote_url(subrepo_path)
21
- h = subrepo_status(subrepo_path)
22
- url = h['Remote URL']
23
- return url if url.present?
24
-
25
- raise "Remote URL is blank for subrepo \"#{subrepo_path}\" (Subrepo status: #{h})"
26
- end
27
-
28
- private
29
-
30
- def subrepo_status_parse_output(output)
31
- r = {}.with_indifferent_access
32
- output.each_line do |l|
33
- m = /\A([^\:]+)\:(.*)\z/.match(l.strip)
34
- next unless m && m[2].present?
35
-
36
- r[m[1].strip] = m[2].strip
37
- end
38
- r
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_git/executables'
4
- require 'eac_ruby_utils/envs'
5
- require 'git'
6
- require 'avm/launcher/paths/real'
7
-
8
- module Avm
9
- module Launcher
10
- module Git
11
- class Base < ::Avm::Launcher::Paths::Real
12
- module Underlying
13
- def command(*args)
14
- args, options = build_args(args)
15
- r = ::EacGit::Executables.git.command(*args)
16
- (options[:exit_outputs] || {}).each do |status_code, result|
17
- r = r.status_result(status_code, result)
18
- end
19
- r
20
- end
21
-
22
- def execute(*args)
23
- command(*args).execute
24
- end
25
-
26
- def execute!(*args)
27
- command(*args).execute!
28
- end
29
-
30
- def system!(*args)
31
- command(*args).system!
32
- end
33
-
34
- def init
35
- git
36
- self
37
- end
38
-
39
- private
40
-
41
- def build_args(args)
42
- options = {}
43
- if args.last.is_a?(Hash)
44
- options = args.last
45
- args.pop
46
- end
47
- args = args.first if args.first.is_a?(Array)
48
- [['-C', self, '--no-pager'] + args, options]
49
- end
50
-
51
- def git_uncached
52
- FileUtils.mkdir_p(self)
53
- if File.exist?(subpath('.git'))
54
- ::Git.open(self)
55
- else
56
- ::Git.init(self)
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_git/local'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/envs'
6
- require 'avm/launcher/paths/real'
7
- require 'avm/launcher/git/error'
8
-
9
- module Avm
10
- module Launcher
11
- module Git
12
- class Base < ::Avm::Launcher::Paths::Real
13
- require_sub __FILE__
14
- enable_simple_cache
15
- extend ::Avm::Launcher::Git::Base::ClassMethods
16
- include ::Avm::Launcher::Git::Base::DirtyFiles
17
- include ::Avm::Launcher::Git::Base::Remotes
18
- include ::Avm::Launcher::Git::Base::Subrepo
19
- include ::Avm::Launcher::Git::Base::Underlying
20
-
21
- attr_reader :eac_git
22
- delegate :descendant?, :merge_base, :rev_parse, to: :eac_git
23
-
24
- def initialize(path)
25
- super(path)
26
-
27
- @eac_git = ::EacGit::Local.new(path)
28
- end
29
-
30
- def init_bare
31
- FileUtils.mkdir_p(self)
32
- ::EacRubyUtils::Envs.local.command('git', 'init', '--bare', self).execute! unless
33
- File.exist?(subpath('.git'))
34
- end
35
-
36
- # @return [Pathname]
37
- def root_path
38
- @root_path ||= self.class.find_root(to_s)
39
- end
40
-
41
- def descendant?(descendant, ancestor)
42
- base = merge_base(descendant, ancestor)
43
- return false if base.blank?
44
-
45
- revparse = execute!('rev-parse', '--verify', ancestor).strip
46
- base == revparse
47
- end
48
-
49
- def subtree_split(prefix)
50
- execute!('subtree', '-q', 'split', '-P', prefix).strip
51
- end
52
-
53
- def push(remote_name, refspecs, options = {})
54
- refspecs = [refspecs] unless refspecs.is_a?(Array)
55
- args = ['push']
56
- args << '--dry-run' if options[:dryrun]
57
- args << '--force' if options[:force]
58
- system!(args + [remote_name] + refspecs)
59
- end
60
-
61
- def push_all(remote_name)
62
- system!('push', '--all', remote_name)
63
- system!('push', '--tags', remote_name)
64
- end
65
-
66
- def fetch(remote_name, options = {})
67
- args = ['fetch', '-p', remote_name]
68
- args += %w[--tags --prune-tags --force] if options[:tags]
69
- execute!(*args)
70
- end
71
-
72
- def current_branch
73
- execute!(%w[symbolic-ref -q HEAD]).gsub(%r{\Arefs/heads/}, '').strip
74
- end
75
-
76
- def reset_hard(ref)
77
- execute!('reset', '--hard', ref)
78
- end
79
-
80
- def raise(message)
81
- ::Kernel.raise Avm::Launcher::Git::Error.new(self, message)
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Launcher
5
- module Git
6
- class Error < StandardError
7
- def initialize(git_instance, message)
8
- super("#{message} (Repository: #{git_instance})")
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/git/base'
4
-
5
- module Avm
6
- module Launcher
7
- module Git
8
- class MirrorUpdate < ::Avm::Launcher::Paths::Real
9
- include ::EacRubyUtils::SimpleCache
10
-
11
- def initialize(target_path, source_path, source_rev)
12
- super(target_path)
13
- @target_git = ::Avm::Launcher::Git::Base.new(self)
14
- @source_git = ::Avm::Launcher::Git::Base.new(source_path)
15
- @source_rev = source_rev
16
- run
17
- end
18
-
19
- private
20
-
21
- def run
22
- fetch_remote_source
23
- reset_source_rev
24
- end
25
-
26
- def fetch_remote_source
27
- @target_git.git
28
- @target_git.assert_remote_url('origin', @source_git)
29
- @target_git.fetch('origin', tags: true)
30
- end
31
-
32
- def reset_source_rev
33
- @target_git.reset_hard(@source_git.rev_parse(@source_rev, true))
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/simple_cache'
4
- require 'eac_ruby_utils/simple_cache'
5
- require 'avm/launcher/publish/base'
6
- require 'avm/launcher/publish/check_result'
7
-
8
- module Avm
9
- module Launcher
10
- module Git
11
- class PublishBase < ::Avm::Launcher::Publish::Base
12
- include ::EacRubyUtils::SimpleCache
13
- enable_speaker
14
-
15
- CHECKERS = %w[remote_url remote_fetch publish_remote_no_exist remote_equal remote_following
16
- local_following].freeze
17
-
18
- REMOTE_UNAVAILABLE_MESSAGES = ['could not resolve host', 'connection timed out',
19
- 'no route to host'].map(&:downcase).freeze
20
-
21
- protected
22
-
23
- def internal_check
24
- CHECKERS.each do |checker|
25
- result = send("#{checker}_check_result")
26
- return result if result
27
- end
28
- divergent_result_check_result
29
- rescue ::Avm::Launcher::Instances::Error => e
30
- ::Avm::Launcher::Publish::CheckResult.blocked(e.message)
31
- rescue ::StandardError => e
32
- raise e unless remote_unavailable_error?(e)
33
-
34
- ::Avm::Launcher::Publish::CheckResult.blocked(e.message)
35
- end
36
-
37
- private
38
-
39
- def remote_url_check_result
40
- remote = sgit.remote(remote_name)
41
- return if remote.exist? && remote.url.present?
42
-
43
- ::Avm::Launcher::Publish::CheckResult.blocked("Remote \"#{remote_name}\" has blank path")
44
- end
45
-
46
- def remote_fetch_check_result
47
- remote_fetch
48
- nil
49
- end
50
-
51
- def remote_unavailable_error?(error)
52
- error_message = error.message.downcase
53
- REMOTE_UNAVAILABLE_MESSAGES.any? do |message|
54
- error_message.include?(message)
55
- end
56
- end
57
-
58
- def publish_remote_no_exist_check_result
59
- return nil if sgit.remote_exist?(remote_name)
60
-
61
- ::Avm::Launcher::Publish::CheckResult.blocked('Remote does not exist')
62
- end
63
-
64
- def remote_equal_check_result
65
- return nil unless remote_sha.present? && remote_sha == local_sha
66
-
67
- ::Avm::Launcher::Publish::CheckResult.updated('Remote equal')
68
- end
69
-
70
- def remote_following_check_result
71
- return nil unless remote_sha.present? && sgit.descendant?(remote_sha, local_sha)
72
-
73
- ::Avm::Launcher::Publish::CheckResult.outdated('Remote following')
74
- end
75
-
76
- def divergent_result_check_result
77
- ::Avm::Launcher::Publish::CheckResult.blocked(
78
- "Divergent (L: #{local_sha}, R: #{remote_sha})"
79
- )
80
- end
81
-
82
- def local_following?
83
- return true if remote_sha.blank?
84
-
85
- sgit.descendant?(local_sha, remote_sha)
86
- end
87
-
88
- def local_following_check_result
89
- return nil unless local_following?
90
-
91
- ::Avm::Launcher::Publish::CheckResult.pending('Local following')
92
- end
93
-
94
- def sgit_uncached
95
- ::Avm::Launcher::Git::Base.new(instance.warped)
96
- end
97
-
98
- def publish
99
- info 'Pushing...'
100
- sgit.push(remote_name, 'HEAD:master',
101
- dryrun: !::Avm::Launcher::Context.current.publish_options[:confirm])
102
- info 'Pushed!'
103
- end
104
-
105
- def local_sha
106
- sgit.git.object('HEAD').sha
107
- end
108
-
109
- def remote_sha_uncached
110
- remote_fetch
111
- b = sgit.git.branches["#{remote_name}/master"]
112
- b ? b.gcommit.sha : nil
113
- end
114
-
115
- def remote_fetch_uncached
116
- sgit.fetch(remote_name)
117
- end
118
-
119
- def remote_name
120
- ::Avm::Launcher::Git::WarpBase::TARGET_REMOTE
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module Launcher
7
- module Git
8
- class Remote
9
- common_constructor :git, :name
10
-
11
- def exist?
12
- git.execute!('remote').each_line.any? { |line| line.strip == name }
13
- end
14
-
15
- def ls
16
- git.execute!(['ls-remote', name]).each_line.map do |line|
17
- x = line.strip.split(/\s+/)
18
- [x[1], x[0]]
19
- end.to_h
20
- end
21
-
22
- # +git remote add ...+
23
- def add(url)
24
- git.execute!('remote', 'add', name, url)
25
- end
26
-
27
- # +git remote rm ...+
28
- def remove
29
- git.execute!('remote', 'rm', name)
30
- end
31
-
32
- # +git remote get-url ...+
33
- def url
34
- git.execute!('remote', 'get-url', name).strip.if_present(nil)
35
- end
36
-
37
- # git remote set-url ...
38
- def url_set(url)
39
- git.execute!('remote', 'set-url', name, url)
40
- end
41
-
42
- # Add or set URL if +url+ is present, remove remote if is blank.
43
- def url=(url)
44
- if exist? && url.blank?
45
- remove
46
- elsif exist? && self.url != url
47
- url_set(url)
48
- elsif !exist?
49
- add(url)
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/projects/stereotype'
4
- require 'avm/launcher/errors/base'
5
-
6
- module Avm
7
- module Launcher
8
- module Git
9
- module SubWarpBase
10
- private
11
-
12
- def parent_instance_uncached
13
- r = find_parent_instance(instance.parent)
14
- return r if r
15
-
16
- ::Avm::Launcher::Errors::Base.new('Git parent not found')
17
- end
18
-
19
- def find_parent_instance(current)
20
- if ::Avm::Projects::Stereotype.git_stereotypes.any? { |s| current.stereotype?(s) }
21
- return current
22
- end
23
-
24
- current.parent ? find_parent_instance(current.parent) : nil
25
- end
26
-
27
- def to_parent_git_path
28
- instance.logical.gsub(%r{\A#{Regexp.quote(parent_instance.logical)}/}, '')
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/git/mirror_update'
4
- require 'avm/launcher/instances/error'
5
- require 'avm/git/vendor/github'
6
- require 'avm/projects/stereotypes/git/publish'
7
-
8
- module Avm
9
- module Launcher
10
- module Git
11
- # Métodos abstratos:
12
- # * source_instance
13
- # * source_remote_name
14
- # * current_ref
15
- class WarpBase < ::Avm::Launcher::Paths::Real
16
- include ::EacRubyUtils::SimpleCache
17
-
18
- TARGET_REMOTE = ::Avm::Projects::Stereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
19
-
20
- def initialize(instance)
21
- @instance = instance
22
- cache_git.git.reset_hard(current_ref)
23
- cache_git.remote(TARGET_REMOTE).url = target_remote_url
24
- super(path)
25
- end
26
-
27
- protected
28
-
29
- attr_reader :instance
30
-
31
- def validate_source_current_revision
32
- if source_git.rev_parse(source_instance.options.git_current_revision, false).present?
33
- return
34
- end
35
-
36
- raise ::Avm::Launcher::Instances::Error, 'Refspec ' \
37
- "\"#{source_instance.options.git_current_revision}\" not found in \"#{source_git}\""
38
- end
39
-
40
- def update
41
- validate_source_current_revision
42
- ::Avm::Launcher::Git::MirrorUpdate.new(
43
- path,
44
- source_instance.real,
45
- source_instance.options.git_current_revision
46
- )
47
- end
48
-
49
- def path
50
- instance.cache_path('git_repository')
51
- end
52
-
53
- def source_git_uncached
54
- ::Avm::Launcher::Git::Base.new(source_instance.real)
55
- end
56
-
57
- def cache_git_uncached
58
- ::Avm::Launcher::Git::Base.new(update)
59
- end
60
-
61
- def target_remote_url
62
- ::Avm::Git::Vendor::Github.to_ssh_url(source_git.git.remote(source_remote_name).url)
63
- end
64
- end
65
- end
66
- end
67
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/git/base'
4
- require 'avm/launcher/git/error'
5
- require 'avm/launcher/git/mirror_update'
6
- require 'avm/launcher/git/publish_base'
7
- require 'avm/launcher/git/warp_base'
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/errors/base'
4
- require 'avm/launcher/instances/base'
5
- require 'avm/launcher/instances/runner_helper'
6
- require 'avm/launcher/instances/settings'
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/paths/logical'
4
- require 'avm/launcher/paths/real'
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Launcher
5
- class Project
6
- attr_reader :name, :instances
7
-
8
- def initialize(name, instances)
9
- @name = name
10
- @instances = instances.to_a
11
- end
12
-
13
- def to_s
14
- name
15
- end
16
- end
17
- end
18
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/launcher/publish/base'
4
- require 'avm/launcher/publish/check_result'