avm-tools 0.44.2 → 0.49.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/git/issue/complete.rb +1 -1
- data/lib/avm/git/issue/complete/_test.rb +43 -0
- data/lib/avm/git/issue/complete/_validations.rb +11 -15
- data/lib/avm/git/issue/complete/validation.rb +31 -0
- data/lib/avm/git/revision_test.rb +2 -2
- data/lib/avm/instances/configuration.rb +12 -0
- data/lib/avm/instances/configuration/_rubocop.rb +24 -0
- data/lib/avm/instances/configuration/_tests.rb +27 -0
- data/lib/avm/rails.rb +9 -0
- data/lib/avm/rails/runners.rb +11 -0
- data/lib/avm/rails/runners/bundle.rb +35 -0
- data/lib/avm/ruby.rb +0 -20
- data/lib/avm/ruby/rubocop/_configured.rb +4 -16
- data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +2 -2
- data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +3 -3
- data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +14 -0
- data/lib/avm/tools/runner/eac_redmine_base0/bundle.rb +2 -24
- data/lib/avm/tools/runner/eac_redmine_base0/runner.rb +43 -0
- data/lib/avm/tools/runner/files/format.rb +1 -1
- data/lib/avm/tools/runner/git.rb +1 -1
- data/lib/avm/tools/runner/launcher.rb +12 -0
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher.rb +17 -0
- data/lib/eac_launcher/context.rb +81 -0
- data/lib/eac_launcher/context/instance_discovery.rb +54 -0
- data/lib/eac_launcher/context/instance_manager.rb +94 -0
- data/lib/eac_launcher/context/settings.rb +51 -0
- data/lib/eac_launcher/git.rb +7 -0
- data/lib/eac_launcher/git/base.rb +100 -0
- data/lib/eac_launcher/git/base/class_methods.rb +26 -0
- data/lib/eac_launcher/git/base/dirty_files.rb +30 -0
- data/lib/eac_launcher/git/base/remotes.rb +38 -0
- data/lib/eac_launcher/git/base/subrepo.rb +42 -0
- data/lib/eac_launcher/git/base/underlying.rb +59 -0
- data/lib/eac_launcher/git/error.rb +11 -0
- data/lib/eac_launcher/git/mirror_update.rb +36 -0
- data/lib/eac_launcher/git/publish_base.rb +118 -0
- data/lib/eac_launcher/git/remote.rb +53 -0
- data/lib/eac_launcher/git/sub_warp_base.rb +30 -0
- data/lib/eac_launcher/git/warp_base.rb +54 -0
- data/lib/eac_launcher/instances.rb +6 -0
- data/lib/eac_launcher/instances/base.rb +91 -0
- data/lib/eac_launcher/instances/base/cache.rb +41 -0
- data/lib/eac_launcher/instances/error.rb +8 -0
- data/lib/eac_launcher/instances/runner_helper.rb +42 -0
- data/lib/eac_launcher/instances/settings.rb +23 -0
- data/lib/eac_launcher/paths.rb +4 -0
- data/lib/eac_launcher/paths/logical.rb +80 -0
- data/lib/eac_launcher/paths/real.rb +42 -0
- data/lib/eac_launcher/project.rb +16 -0
- data/lib/eac_launcher/publish.rb +4 -0
- data/lib/eac_launcher/publish/base.rb +45 -0
- data/lib/eac_launcher/publish/check_result.rb +65 -0
- data/lib/eac_launcher/ruby.rb +3 -0
- data/lib/eac_launcher/ruby/gem.rb +4 -0
- data/lib/eac_launcher/ruby/gem/build.rb +123 -0
- data/lib/eac_launcher/ruby/gem/specification.rb +61 -0
- data/lib/eac_launcher/runner.rb +21 -0
- data/lib/eac_launcher/runner/instances.rb +41 -0
- data/lib/eac_launcher/runner/projects.rb +46 -0
- data/lib/eac_launcher/runner/publish.rb +59 -0
- data/lib/eac_launcher/stereotype.rb +52 -0
- data/lib/eac_launcher/stereotypes.rb +14 -0
- data/lib/eac_launcher/stereotypes/git.rb +21 -0
- data/lib/eac_launcher/stereotypes/git/publish.rb +13 -0
- data/lib/eac_launcher/stereotypes/git/warp.rb +25 -0
- data/lib/eac_launcher/stereotypes/git_subrepo.rb +30 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +12 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +85 -0
- data/lib/eac_launcher/stereotypes/git_subtree.rb +47 -0
- data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +10 -0
- data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +27 -0
- data/lib/eac_launcher/stereotypes/rails.rb +21 -0
- data/lib/eac_launcher/stereotypes/redmine_plugin.rb +21 -0
- data/lib/eac_launcher/stereotypes/ruby_gem.rb +27 -0
- data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +127 -0
- data/lib/eac_launcher/vendor.rb +3 -0
- data/lib/eac_launcher/vendor/github.rb +18 -0
- data/lib/eac_launcher/version.rb +5 -0
- metadata +126 -46
- data/lib/avm/patches/eac_launcher_git_base.rb +0 -77
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacLauncher
|
4
|
+
module Git
|
5
|
+
class Base < ::EacLauncher::Paths::Real
|
6
|
+
module ClassMethods
|
7
|
+
# @return [EacLauncher::Git::Base]
|
8
|
+
def by_root(search_base_path)
|
9
|
+
new(find_root(search_base_path).to_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Searches the root path for the Git repository which includes +search_base_path+.
|
13
|
+
# @return [Pathname]
|
14
|
+
def find_root(search_base_path)
|
15
|
+
path = search_base_path.to_pathname.expand_path
|
16
|
+
loop do
|
17
|
+
return path if path.join('.git').exist?
|
18
|
+
raise "\".git\" not found for \"#{search_base_path}\"" if path.parent.root?
|
19
|
+
|
20
|
+
path = path.parent
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Git
|
7
|
+
class Base < ::EacLauncher::Paths::Real
|
8
|
+
module DirtyFiles
|
9
|
+
def dirty?
|
10
|
+
dirty_files.any?
|
11
|
+
end
|
12
|
+
|
13
|
+
def dirty_files
|
14
|
+
execute!('status', '--porcelain', '--untracked-files').each_line.map do |line|
|
15
|
+
parse_status_line(line.gsub(/\n\z/, ''))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def parse_status_line(line)
|
22
|
+
m = /\A(.)(.)\s(.+)\z/.match(line)
|
23
|
+
::Kernel.raise "Status pattern does not match \"#{line}\"" unless m
|
24
|
+
::OpenStruct.new(index: m[1], worktree: m[2], path: m[3],
|
25
|
+
absolute_path: ::File.expand_path(m[3], self))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_launcher/git/remote'
|
5
|
+
|
6
|
+
module EacLauncher
|
7
|
+
module Git
|
8
|
+
class Base < ::EacLauncher::Paths::Real
|
9
|
+
module Remotes
|
10
|
+
# @return [EacLauncher::Git::Remote]
|
11
|
+
def remote(name)
|
12
|
+
::EacLauncher::Git::Remote.new(self, name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def remote_hashs(remote_name)
|
16
|
+
remote(remote_name).ls
|
17
|
+
end
|
18
|
+
|
19
|
+
def remote_exist?(remote_name)
|
20
|
+
remote(remote_name).exist?
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_remote_url(remote_name, url)
|
24
|
+
r = git.remote(remote_name)
|
25
|
+
if !r.url || r.url != url
|
26
|
+
r.remove if r.url
|
27
|
+
git.add_remote(remote_name, url)
|
28
|
+
end
|
29
|
+
r
|
30
|
+
end
|
31
|
+
|
32
|
+
def remote_branch_sha(remote_name, branch_name)
|
33
|
+
remote_hashs(remote_name)["refs/heads/#{branch_name}"]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Git
|
7
|
+
class Base < ::EacLauncher::Paths::Real
|
8
|
+
module Subrepo
|
9
|
+
def subrepo_status(subrepo_path)
|
10
|
+
s = execute!('subrepo', 'status', subrepo_path.gsub(%r{\A/}, ''))
|
11
|
+
raise s.strip.to_s if s.include?('is not a subrepo')
|
12
|
+
|
13
|
+
r = subrepo_status_parse_output(s)
|
14
|
+
raise "Empty subrepo status for |#{s}|\n" unless r.any?
|
15
|
+
|
16
|
+
r
|
17
|
+
end
|
18
|
+
|
19
|
+
def subrepo_remote_url(subrepo_path)
|
20
|
+
h = subrepo_status(subrepo_path)
|
21
|
+
url = h['Remote URL']
|
22
|
+
return url if url.present?
|
23
|
+
|
24
|
+
raise "Remote URL is blank for subrepo \"#{subrepo_path}\" (Subrepo status: #{h})"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def subrepo_status_parse_output(output)
|
30
|
+
r = {}.with_indifferent_access
|
31
|
+
output.each_line do |l|
|
32
|
+
m = /\A([^\:]+)\:(.*)\z/.match(l.strip)
|
33
|
+
next unless m && m[2].present?
|
34
|
+
|
35
|
+
r[m[1].strip] = m[2].strip
|
36
|
+
end
|
37
|
+
r
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/envs'
|
4
|
+
require 'git'
|
5
|
+
require 'eac_launcher/paths/real'
|
6
|
+
|
7
|
+
module EacLauncher
|
8
|
+
module Git
|
9
|
+
class Base < ::EacLauncher::Paths::Real
|
10
|
+
module Underlying
|
11
|
+
def command(*args)
|
12
|
+
args, _options = build_args(args)
|
13
|
+
::EacRubyUtils::Envs.local.command(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute(*args)
|
17
|
+
args, options = build_args(args)
|
18
|
+
::EacRubyUtils::Envs.local.command(*args).execute(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute!(*args)
|
22
|
+
args, options = build_args(args)
|
23
|
+
::EacRubyUtils::Envs.local.command(*args).execute!(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def system!(*args)
|
27
|
+
args, options = build_args(args)
|
28
|
+
::EacRubyUtils::Envs.local.command(*args).system!(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def init
|
32
|
+
git
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def build_args(args)
|
39
|
+
options = {}
|
40
|
+
if args.last.is_a?(Hash)
|
41
|
+
options = args.last
|
42
|
+
args.pop
|
43
|
+
end
|
44
|
+
args = args.first if args.first.is_a?(Array)
|
45
|
+
[['git', '-C', self, '--no-pager'] + args, options]
|
46
|
+
end
|
47
|
+
|
48
|
+
def git_uncached
|
49
|
+
FileUtils.mkdir_p(self)
|
50
|
+
if File.exist?(subpath('.git'))
|
51
|
+
::Git.open(self)
|
52
|
+
else
|
53
|
+
::Git.init(self)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/git/base'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Git
|
7
|
+
class MirrorUpdate < ::EacLauncher::Paths::Real
|
8
|
+
include ::EacRubyUtils::SimpleCache
|
9
|
+
|
10
|
+
def initialize(target_path, source_path, source_rev)
|
11
|
+
super(target_path)
|
12
|
+
@target_git = ::EacLauncher::Git::Base.new(self)
|
13
|
+
@source_git = ::EacLauncher::Git::Base.new(source_path)
|
14
|
+
@source_rev = source_rev
|
15
|
+
run
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def run
|
21
|
+
fetch_remote_source
|
22
|
+
reset_source_rev
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch_remote_source
|
26
|
+
@target_git.git
|
27
|
+
@target_git.assert_remote_url('origin', @source_git)
|
28
|
+
@target_git.fetch('origin', tags: true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def reset_source_rev
|
32
|
+
@target_git.reset_hard(@source_git.rev_parse(@source_rev, true))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'eac_launcher/publish/base'
|
6
|
+
|
7
|
+
module EacLauncher
|
8
|
+
module Git
|
9
|
+
class PublishBase < ::EacLauncher::Publish::Base
|
10
|
+
include ::EacRubyUtils::SimpleCache
|
11
|
+
include ::EacRubyUtils::Console::Speaker
|
12
|
+
|
13
|
+
CHECKERS = %w[remote_url remote_fetch publish_remote_no_exist remote_equal remote_following
|
14
|
+
local_following].freeze
|
15
|
+
|
16
|
+
REMOTE_UNAVAILABLE_MESSAGES = ['could not resolve host', 'connection timed out',
|
17
|
+
'no route to host'].map(&:downcase).freeze
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def internal_check
|
22
|
+
CHECKERS.each do |checker|
|
23
|
+
result = send("#{checker}_check_result")
|
24
|
+
return result if result
|
25
|
+
end
|
26
|
+
divergent_result_check_result
|
27
|
+
rescue ::StandardError => e
|
28
|
+
raise e unless remote_unavailable_error?(e)
|
29
|
+
|
30
|
+
::EacLauncher::Publish::CheckResult.blocked(e.message)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def remote_url_check_result
|
36
|
+
remote = sgit.remote(remote_name)
|
37
|
+
return if remote.exist? && remote.url.present?
|
38
|
+
|
39
|
+
::EacLauncher::Publish::CheckResult.blocked("Remote \"#{remote_name}\" has blank path")
|
40
|
+
end
|
41
|
+
|
42
|
+
def remote_fetch_check_result
|
43
|
+
remote_fetch
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def remote_unavailable_error?(error)
|
48
|
+
error_message = error.message.downcase
|
49
|
+
REMOTE_UNAVAILABLE_MESSAGES.any? do |message|
|
50
|
+
error_message.include?(message)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def publish_remote_no_exist_check_result
|
55
|
+
return nil if sgit.remote_exist?(remote_name)
|
56
|
+
|
57
|
+
::EacLauncher::Publish::CheckResult.blocked('Remote does not exist')
|
58
|
+
end
|
59
|
+
|
60
|
+
def remote_equal_check_result
|
61
|
+
return nil unless remote_sha.present? && remote_sha == local_sha
|
62
|
+
|
63
|
+
::EacLauncher::Publish::CheckResult.updated('Remote equal')
|
64
|
+
end
|
65
|
+
|
66
|
+
def remote_following_check_result
|
67
|
+
return nil unless remote_sha.present? && sgit.descendant?(remote_sha, local_sha)
|
68
|
+
|
69
|
+
::EacLauncher::Publish::CheckResult.outdated('Remote following')
|
70
|
+
end
|
71
|
+
|
72
|
+
def divergent_result_check_result
|
73
|
+
::EacLauncher::Publish::CheckResult.blocked(
|
74
|
+
"Divergent (L: #{local_sha}, R: #{remote_sha})"
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def local_following?
|
79
|
+
return true if remote_sha.blank?
|
80
|
+
|
81
|
+
sgit.descendant?(local_sha, remote_sha)
|
82
|
+
end
|
83
|
+
|
84
|
+
def local_following_check_result
|
85
|
+
::EacLauncher::Publish::CheckResult.pending('Local following')
|
86
|
+
end
|
87
|
+
|
88
|
+
def sgit_uncached
|
89
|
+
::EacLauncher::Git::Base.new(instance.warped)
|
90
|
+
end
|
91
|
+
|
92
|
+
def publish
|
93
|
+
info 'Pushing...'
|
94
|
+
sgit.push(remote_name, 'HEAD:master',
|
95
|
+
dryrun: !::EacLauncher::Context.current.publish_options[:confirm])
|
96
|
+
info 'Pushed!'
|
97
|
+
end
|
98
|
+
|
99
|
+
def local_sha
|
100
|
+
sgit.git.object('HEAD').sha
|
101
|
+
end
|
102
|
+
|
103
|
+
def remote_sha_uncached
|
104
|
+
remote_fetch
|
105
|
+
b = sgit.git.branches["#{remote_name}/master"]
|
106
|
+
b ? b.gcommit.sha : nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def remote_fetch_uncached
|
110
|
+
sgit.fetch(remote_name)
|
111
|
+
end
|
112
|
+
|
113
|
+
def remote_name
|
114
|
+
::EacLauncher::Git::WarpBase::TARGET_REMOTE
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Git
|
7
|
+
class Remote
|
8
|
+
common_constructor :git, :name
|
9
|
+
|
10
|
+
def exist?
|
11
|
+
git.execute!('remote').each_line.any? { |line| line.strip == name }
|
12
|
+
end
|
13
|
+
|
14
|
+
def ls
|
15
|
+
git.execute!(['ls-remote', name]).each_line.map do |line|
|
16
|
+
x = line.strip.split(/\s+/)
|
17
|
+
[x[1], x[0]]
|
18
|
+
end.to_h
|
19
|
+
end
|
20
|
+
|
21
|
+
# +git remote add ...+
|
22
|
+
def add(url)
|
23
|
+
git.execute!('remote', 'add', name, url)
|
24
|
+
end
|
25
|
+
|
26
|
+
# +git remote rm ...+
|
27
|
+
def remove
|
28
|
+
git.execute!('remote', 'rm', name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# +git remote get-url ...+
|
32
|
+
def url
|
33
|
+
git.execute!('remote', 'get-url', name).strip.if_present(nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
# git remote set-url ...
|
37
|
+
def url_set(url)
|
38
|
+
git.execute!('remote', 'set-url', name, url)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add or set URL if +url+ is present, remove remote if is blank.
|
42
|
+
def url=(url)
|
43
|
+
if exist? && url.blank?
|
44
|
+
remove
|
45
|
+
elsif exist? && self.url != url
|
46
|
+
url_set(url)
|
47
|
+
elsif !exist?
|
48
|
+
add(url)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/instances/error'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Git
|
7
|
+
module SubWarpBase
|
8
|
+
private
|
9
|
+
|
10
|
+
def parent_instance_uncached
|
11
|
+
r = find_parent_instance(instance.parent)
|
12
|
+
return r if r
|
13
|
+
|
14
|
+
::EacLauncher::Instances::Error.new('Git parent not found')
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_parent_instance(current)
|
18
|
+
if ::EacLauncher::Stereotype.git_stereotypes.any? { |s| current.stereotype?(s) }
|
19
|
+
return current
|
20
|
+
end
|
21
|
+
|
22
|
+
current.parent ? find_parent_instance(current.parent) : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_parent_git_path
|
26
|
+
instance.logical.gsub(%r{\A#{Regexp.quote(parent_instance.logical)}/}, '')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|