avm-tools 0.52.0 → 0.53.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3764f4ca13b2ddc71f8c85c48e0b5d60652083caf844402118dde252bbf556ac
4
- data.tar.gz: '095d96b661591d076a37287c723ac69833a0b167474d4ac32c6157767662c60f'
3
+ metadata.gz: f84588df0d4cd0ec0d2140c037681209a2d20ad2631dced23607886bef8d18f5
4
+ data.tar.gz: 9f2fbd2b970e79076c229d536e5b764d096688b51ef9d4d22646ad7a1b33ff6a
5
5
  SHA512:
6
- metadata.gz: ed3c88ad9c85b8bb726f48f2a3dc08639bda36fdd71c28bc8b191e619956632ebaf3703a70f0bbf43eb4497f969aeca46b97e4e0e59da2c082acdaf2fa8971c7
7
- data.tar.gz: 3e637c06cbe3a99a0b2b63f3d6fce68b5798e9e8d2bec94c92bcad2862d4322963073c7a15e05855b9604defcc6a6c84bb474f7934171c54276d674f4ea87211
6
+ metadata.gz: 3bfad35dd4309a96a5a8f61b97cb1ba84203fd3ae20aac14394d6366269af231f8a50cafe8b9d9bb38c10fddd28dace0309738ef14d59ef64c2381faa166b5ff
7
+ data.tar.gz: 2eebd6a5654e278c8131630f500568ae6d4cf5f92f9eae4108b9ea497b3c229c539acc6f6c1dc6904109bcd2bdf4505f86682e0af3098503649bb7c6be8c13aa
@@ -7,10 +7,7 @@ module Avm
7
7
  module Issue
8
8
  class Complete
9
9
  def commits_result
10
- ::Avm::Result.success_or_error(
11
- commits.any? ? 'yes' : 'none',
12
- commits.any?
13
- )
10
+ ::Avm::Result.success_or_error(commits.any?, 'yes', 'none')
14
11
  end
15
12
 
16
13
  def commits_uncached
@@ -19,13 +19,13 @@ module Avm
19
19
  end
20
20
 
21
21
  def branch_name_result
22
- ::Avm::Result.success_or_error(branch_name, issue_id.present?)
22
+ ::Avm::Result.success_or_error(issue_id.present?, branch_name)
23
23
  end
24
24
 
25
25
  def branch_hash_result
26
26
  ::Avm::Result.success_or_error(
27
- branch_hash,
28
- branch_hash.present?
27
+ branch_hash.present?,
28
+ branch_hash
29
29
  )
30
30
  end
31
31
 
@@ -33,10 +33,7 @@ module Avm
33
33
  return ::Avm::Result.neutral('No branch hash') unless branch_hash
34
34
 
35
35
  r = follow_master?
36
- ::Avm::Result.success_or_error(
37
- r ? 'yes' : 'no',
38
- r
39
- )
36
+ ::Avm::Result.success_or_error(r, 'yes', 'no')
40
37
  end
41
38
 
42
39
  def follow_master?
@@ -17,7 +17,7 @@ module Avm
17
17
  else
18
18
  r.fetch(:stderr) + "\n#{::Shellwords.join(dry_push_args)}"
19
19
  end
20
- ::Avm::Result.success_or_error(message, r.fetch(:exit_code).zero?)
20
+ ::Avm::Result.success_or_error(r.fetch(:exit_code).zero?, message)
21
21
  end
22
22
 
23
23
  def push
@@ -6,7 +6,7 @@ module Avm
6
6
  class Complete
7
7
  def clean_workspace_result
8
8
  r = @git.dirty_files.none?
9
- ::Avm::Result.success_or_error(r ? 'yes' : 'no', r)
9
+ ::Avm::Result.success_or_error(r, 'yes', 'no')
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoCheck
9
+ require_sub __FILE__, include_modules: true
10
+ enable_console_speaker
11
+ enable_simple_cache
12
+
13
+ BLANK_TEXT = 'BLANK'
14
+
15
+ common_constructor :subrepo, :options
16
+
17
+ def blank_text
18
+ BLANK_TEXT
19
+ end
20
+
21
+ def check_remote?
22
+ options.fetch(:check_remote) ? true : false
23
+ end
24
+
25
+ def fix_parent?
26
+ options.fetch(:fix_parent) ? true : false
27
+ end
28
+
29
+ private
30
+
31
+ def result_uncached
32
+ return ::Avm::Result.error('Parent failed') if parent_result.error?
33
+ return ::Avm::Result.error('Remote failed') if remote_result.error?
34
+
35
+ ::Avm::Result.success('Parent and remote ok')
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/result'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoCheck
9
+ module Parent
10
+ def fix_parent
11
+ return if parent_result.success?
12
+
13
+ info(' Fixing...')
14
+ self.parent_hash = expected_parent_hash
15
+ info_banner
16
+ end
17
+
18
+ private
19
+
20
+ def expected_parent_hash_uncached
21
+ subrepo.local.rev_parse("#{last_file_change_rev}^")
22
+ end
23
+
24
+ def last_file_change_rev
25
+ subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
26
+ subrepo.config_relative_path.to_path).execute!.strip
27
+ end
28
+
29
+ def parent_hash
30
+ subrepo.parent_commit_id
31
+ end
32
+
33
+ def parent_hash=(new_hash)
34
+ subrepo.config.parent_commit_id = new_hash
35
+ subrepo.write_config
36
+ end
37
+
38
+ def parent_hash_ok?
39
+ return false if expected_parent_hash.blank? || parent_hash.blank?
40
+
41
+ expected_parent_hash == parent_hash
42
+ end
43
+
44
+ def parent_result_uncached
45
+ ::Avm::Result.success_or_error(parent_hash_ok?,
46
+ parent_hash.presence || blank_text)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/result'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoCheck
9
+ module Remote
10
+ private
11
+
12
+ def fetch_uncached
13
+ subrepo.command('clean').execute!
14
+ subrepo.command('fetch').execute!
15
+ end
16
+
17
+ def check_remote_disabled?
18
+ !check_remote?
19
+ end
20
+
21
+ def check_remote_disabled_result
22
+ ::Avm::Result.neutral('Check remote disabled')
23
+ end
24
+
25
+ def local_descend_remote?
26
+ local_id.present? && remote_id.present? && subrepo.local.descendant?(local_id, remote_id)
27
+ end
28
+
29
+ def local_descend_remote_result
30
+ ::Avm::Result.pending(remote_result_value)
31
+ end
32
+
33
+ def local_id_uncached
34
+ fetch
35
+ subrepo.command('branch', '--force').execute!
36
+ subrepo.local.rev_parse("subrepo/#{subrepo.subpath}")
37
+ end
38
+
39
+ def remote_descend_local?
40
+ local_id.present? && remote_id.present? && subrepo.local.descendant?(remote_id, local_id)
41
+ end
42
+
43
+ def remote_descend_local_result
44
+ ::Avm::Result.outdated(remote_result_value)
45
+ end
46
+
47
+ def remote_branches
48
+ ['', 'refs/heads/', 'refs/tags/'].map { |prefix| "#{prefix}#{subrepo.remote_branch}" }
49
+ end
50
+
51
+ def remote_id_uncached
52
+ ls_result = subrepo.remote.ls
53
+ remote_branches.each do |b|
54
+ return ls_result[b] if ls_result[b].present?
55
+ end
56
+ nil
57
+ end
58
+
59
+ def remote_result_uncached
60
+ %w[check_remote_disabled same_ids local_descend_remote remote_descend_local]
61
+ .each do |condition|
62
+ return send("#{condition}_result") if send("#{condition}?")
63
+ end
64
+
65
+ ::Avm::Result.error(remote_result_value)
66
+ end
67
+
68
+ def remote_result_value
69
+ local_s = local_id.presence || blank_text
70
+ remote_s = remote_id.presence || blank_text
71
+
72
+ if local_s == remote_s
73
+ "[L/R=#{local_s}]"
74
+ else
75
+ "[L=#{local_s}, R=#{remote_s}]"
76
+ end
77
+ end
78
+
79
+ def same_ids?
80
+ local_id.present? && remote_id.present? && local_id == remote_id
81
+ end
82
+
83
+ def same_ids_result
84
+ ::Avm::Result.success(remote_result_value)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoCheck
9
+ module ShowResult
10
+ def show_result
11
+ out(subrepo.subpath.to_path.cyan)
12
+ out_attr('parent', parent_result.label)
13
+ run_fix_parent
14
+ out_attr('remote', remote_result.label)
15
+ out("\n")
16
+ end
17
+
18
+ def run_fix_parent
19
+ return unless fix_parent?
20
+ return unless parent_result.error?
21
+
22
+ out('|Fixing...'.white)
23
+ self.parent_hash = expected_parent_hash
24
+ out_attr('new parent', parent_result.label)
25
+ end
26
+
27
+ def out_attr(key, value)
28
+ out('|' + "#{key}=".white + value)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoChecks
9
+ enable_console_speaker
10
+ enable_simple_cache
11
+ attr_accessor :check_remote, :fix_parent
12
+ common_constructor :repository
13
+
14
+ def add_all_subrepos
15
+ add_subrepos(
16
+ *repository.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
17
+ .select(&:present?)
18
+ )
19
+ end
20
+
21
+ def add_subrepos(*subpath_list)
22
+ subpath_list.each do |subpath|
23
+ subpaths.add(subpath)
24
+ end
25
+ reset_cache
26
+ self
27
+ end
28
+
29
+ def check_options
30
+ { fix_parent: fix_parent, check_remote: check_remote }
31
+ end
32
+
33
+ def show_result
34
+ checks.each(&:show_result)
35
+ infov 'Result', result.label
36
+ end
37
+
38
+ private
39
+
40
+ def checks_uncached
41
+ subpaths.map do |subpath|
42
+ ::Avm::Git::SubrepoCheck.new(repository.subrepo(subpath), check_options)
43
+ end
44
+ end
45
+
46
+ def result_uncached
47
+ error_count = checks.count { |check| check.result.error? }
48
+ ::Avm::Result.success_or_error(
49
+ error_count.zero?,
50
+ "#{error_count} of #{checks.count} subrepos failed"
51
+ )
52
+ end
53
+
54
+ def subpaths
55
+ @subpaths ||= ::Set.new
56
+ end
57
+ end
58
+ end
59
+ end
@@ -2,12 +2,13 @@
2
2
 
3
3
  require 'colorized_string'
4
4
  require 'eac_ruby_utils/listable'
5
+ require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avm
7
8
  class Result < ::SimpleDelegator
8
9
  include ::EacRubyUtils::Listable
9
10
 
10
- lists.add_string :type, :success, :error, :neutral
11
+ lists.add_string :type, :success, :error, :neutral, :pending, :outdated
11
12
 
12
13
  lists.type.values.each do |type| # rubocop:disable Style/HashEachMethods
13
14
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
@@ -20,10 +21,19 @@ module Avm
20
21
  TYPE_SUCCESS_COLOR = 'green'
21
22
  TYPE_ERROR_COLOR = 'red'
22
23
  TYPE_NEUTRAL_COLOR = 'light_black'
24
+ TYPE_PENDING_COLOR = 'yellow'
25
+ TYPE_OUTDATED_COLOR = 'blue'
23
26
 
24
27
  class << self
25
- def success_or_error(value, success)
26
- new(value, success ? ::Avm::Result::TYPE_SUCCESS : ::Avm::Result::TYPE_ERROR)
28
+ # Return Avm::Result.success(success_value) if +success+ is truthy.
29
+ # Return Avm::Result.error(error_value || success_value) if +success+ is falsely.
30
+ # @return [Avm::Result]
31
+ def success_or_error(success, success_value, error_value = nil)
32
+ if success
33
+ self.success(success_value)
34
+ else
35
+ error(error_value.presence || success_value)
36
+ end
27
37
  end
28
38
  end
29
39
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Git < ::EacRubyUtils::Console::DocoptRunner
10
+ class Subrepo < ::EacRubyUtils::Console::DocoptRunner
11
+ require_sub __FILE__
12
+ include ::EacCli::DefaultRunner
13
+
14
+ runner_definition do
15
+ desc 'Git-subrepo (https://github.com/ingydotnet/git-subrepo) utilities.'
16
+ subcommands
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_git/local'
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 Subrepo < ::EacRubyUtils::Console::DocoptRunner
12
+ class Check < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+
15
+ runner_definition do
16
+ desc 'Check status of subrepos.'
17
+ bool_opt '-a', '--all', 'Select all subrepos.'
18
+ bool_opt '-f', '--fix-parent', 'Fix parent SHA1.'
19
+ bool_opt '-r', '--remote', 'Check subrepos remote.'
20
+ pos_arg :subrepos, repeat: true, optional: true
21
+ end
22
+
23
+ def run
24
+ subrepo_checks.show_result
25
+ fatal_error 'Failed' if subrepo_checks.result.error?
26
+ end
27
+
28
+ private
29
+
30
+ def subrepo_checks_uncached
31
+ r = ::Avm::Git::SubrepoChecks.new(local_repos)
32
+ r.check_remote = options.fetch('--remote')
33
+ r.fix_parent = options.fetch('--fix-parent')
34
+ r.add_all_subrepos if options.fetch('--all')
35
+ r.add_subrepos(*options.fetch('<subrepos>'))
36
+ r
37
+ end
38
+
39
+ def local_repos_uncached
40
+ ::EacGit::Local.new(context(:git))
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.52.0'
5
+ VERSION = '0.53.0'
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_git/local'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/envs'
5
6
  require 'eac_launcher/paths/real'
@@ -16,21 +17,21 @@ module EacLauncher
16
17
  include ::EacLauncher::Git::Base::Subrepo
17
18
  include ::EacLauncher::Git::Base::Underlying
18
19
 
20
+ attr_reader :eac_git
21
+ delegate :descendant?, :merge_base, :rev_parse, to: :eac_git
22
+
23
+ def initialize(path)
24
+ super(path)
25
+
26
+ @eac_git = ::EacGit::Local.new(path)
27
+ end
28
+
19
29
  def init_bare
20
30
  FileUtils.mkdir_p(self)
21
31
  ::EacRubyUtils::Envs.local.command('git', 'init', '--bare', self).execute! unless
22
32
  File.exist?(subpath('.git'))
23
33
  end
24
34
 
25
- def rev_parse(ref, required = false)
26
- r = execute!('rev-parse', ref, exit_outputs: { 128 => nil, 32_768 => nil })
27
- r.strip! if r.is_a?(String)
28
- return r if r.present?
29
- return nil unless required
30
-
31
- raise "Reference \"#{ref}\" not found"
32
- end
33
-
34
35
  # @return [Pathname]
35
36
  def root_path
36
37
  @root_path ||= self.class.find_root(to_s)
@@ -44,17 +45,6 @@ module EacLauncher
44
45
  base == revparse
45
46
  end
46
47
 
47
- def merge_base(*commits)
48
- refs = commits.dup
49
- while refs.count > 1
50
- refs[1] = merge_base_pair(refs[0], refs[1])
51
- return nil if refs[1].blank?
52
-
53
- refs.shift
54
- end
55
- refs.first
56
- end
57
-
58
48
  def subtree_split(prefix)
59
49
  execute!('subtree', '-q', 'split', '-P', prefix).strip
60
50
  end
@@ -89,12 +79,6 @@ module EacLauncher
89
79
  def raise(message)
90
80
  ::Kernel.raise EacLauncher::Git::Error.new(self, message)
91
81
  end
92
-
93
- private
94
-
95
- def merge_base_pair(commit1, commit2)
96
- execute!('merge-base', commit1, commit2, exit_outputs: { 256 => '' }).strip
97
- end
98
82
  end
99
83
  end
100
84
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'eac_git/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'eac_git'
9
+ s.version = EacGit::VERSION
10
+ s.authors = ['Put here the authors']
11
+ s.summary = 'Put here de description.'
12
+
13
+ s.files = Dir['{lib}/**/*']
14
+
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.37'
16
+ s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
17
+
18
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
19
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ require_sub __FILE__
7
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs'
4
+ require 'eac_ruby_utils/simple_cache'
5
+
6
+ module EacGit
7
+ module Executables
8
+ class << self
9
+ include ::EacRubyUtils::SimpleCache
10
+
11
+ def env
12
+ ::EacRubyUtils::Envs.local
13
+ end
14
+
15
+ private
16
+
17
+ %w[git].each do |program|
18
+ define_method(program.underscore + '_uncached') do
19
+ env.executable(program, '--version')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/executables'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacGit
7
+ # A Git repository in local filesystem.
8
+ class Local
9
+ require_sub __FILE__
10
+
11
+ common_constructor :root_path do
12
+ self.root_path = root_path.to_pathname
13
+ end
14
+
15
+ def descendant?(descendant, ancestor)
16
+ base = merge_base(descendant, ancestor)
17
+ return false if base.blank?
18
+
19
+ revparse = command('rev-parse', '--verify', ancestor).execute!.strip
20
+ base == revparse
21
+ end
22
+
23
+ def merge_base(*commits)
24
+ refs = commits.dup
25
+ while refs.count > 1
26
+ refs[1] = merge_base_pair(refs[0], refs[1])
27
+ return nil if refs[1].blank?
28
+
29
+ refs.shift
30
+ end
31
+ refs.first
32
+ end
33
+
34
+ def command(*args)
35
+ ::EacGit::Executables.git.command('-C', root_path.to_path, *args)
36
+ end
37
+
38
+ def rev_parse(ref, required = false)
39
+ r = command('rev-parse', ref).execute!(exit_outputs: { 128 => nil, 32_768 => nil })
40
+ r.strip! if r.is_a?(String)
41
+ return r if r.present?
42
+ return nil unless required
43
+
44
+ raise "Reference \"#{ref}\" not found"
45
+ end
46
+
47
+ def subrepo(subpath)
48
+ ::EacGit::Local::Subrepo.new(self, subpath)
49
+ end
50
+
51
+ private
52
+
53
+ def merge_base_pair(commit1, commit2)
54
+ command('merge-base', commit1, commit2).execute!(exit_outputs: { 256 => nil }).strip
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/remote'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacGit
7
+ class Local
8
+ # A git-subrepo (https://github.com/ingydotnet/git-subrepo) in a [EacGit::Local].
9
+ class Subrepo
10
+ require_sub __FILE__
11
+ enable_simple_cache
12
+
13
+ common_constructor :local, :subpath do
14
+ self.subpath = subpath.to_pathname
15
+ raise "Config file \"#{config_absolute_path}\" not found" unless config_absolute_path.file?
16
+ end
17
+
18
+ def command(subrepo_subcommand, *subrepo_subcommand_args)
19
+ local.command('subrepo', subrepo_subcommand, subpath.to_path,
20
+ *subrepo_subcommand_args)
21
+ end
22
+
23
+ delegate(*::EacGit::Local::Subrepo::Config::MAPPING.keys, to: :config)
24
+
25
+ def write_config
26
+ config_absolute_path.write(config.to_content)
27
+ end
28
+
29
+ private
30
+
31
+ def config_uncached
32
+ ::EacGit::Local::Subrepo::Config.from_file(config_absolute_path)
33
+ end
34
+
35
+ def config_absolute_path_uncached
36
+ config_relative_path.expand_path(local.root_path)
37
+ end
38
+
39
+ def config_relative_path_uncached
40
+ subpath.join('.gitrepo')
41
+ end
42
+
43
+ def remote_uncached
44
+ ::EacGit::Remote.new(remote_uri)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'parseconfig'
5
+
6
+ module EacGit
7
+ class Local
8
+ class Subrepo
9
+ class Config
10
+ MAPPING = {
11
+ command_version: :cmdver, commit_id: :commit, join_method: :method,
12
+ parent_commit_id: :parent, remote_branch: :branch, remote_uri: :remote
13
+ }.freeze
14
+
15
+ class << self
16
+ def from_file(file_path)
17
+ new(
18
+ ::ParseConfig.new(file_path.to_pathname)['subrepo']
19
+ )
20
+ end
21
+ end
22
+
23
+ common_constructor :values do
24
+ self.values = values.with_indifferent_access
25
+ end
26
+
27
+ MAPPING.each do |method_name, _config_key|
28
+ define_method(method_name) do
29
+ values[MAPPING.fetch(method_name)]
30
+ end
31
+
32
+ define_method("#{method_name}=") do |value|
33
+ values[MAPPING.fetch(method_name)] = value
34
+ end
35
+ end
36
+
37
+ def to_content
38
+ "[subrepo]\n" + MAPPING.map { |k, v| " #{v} = #{send(k)}\n" }.join
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/executables'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacGit
7
+ # A Git remote repository referenced by URI.
8
+ class Remote
9
+ require_sub __FILE__
10
+
11
+ common_constructor :uri
12
+
13
+ def ls
14
+ ::EacGit::Remote::LsResult.by_ls_remote_command_output(
15
+ ::EacGit::Executables.git.command('ls-remote', uri).execute!
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ class Remote
7
+ class LsResult
8
+ class << self
9
+ def by_ls_remote_command_output(output)
10
+ new(
11
+ output.each_line.map { |line| line.strip.split(/\s+/) }.map { |x| [x[1], x[0]] }.to_h
12
+ )
13
+ end
14
+ end
15
+
16
+ common_constructor :hashes
17
+ delegate :fetch, :'[]', :count, :any?, :empty?, to: :hashes
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacGit
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
+
5
+ RSpec.describe ::RuboCop, slow: true do
6
+ include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
7
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ # # This allows you to limit a spec run to individual examples or groups
52
+ # # you care about by tagging them with `:focus` metadata. When nothing
53
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ # config.filter_run_when_matching :focus
57
+ #
58
+ # # Allows RSpec to persist some state between runs in order to support
59
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # # you configure your source control system to ignore this file.
61
+ # config.example_status_persistence_file_path = "spec/examples.txt"
62
+ #
63
+ # # Limits the available syntax to the non-monkey patched syntax that is
64
+ # # recommended. For more details, see:
65
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ # config.disable_monkey_patching!
69
+ #
70
+ # # This setting enables warnings. It's recommended, but in some cases may
71
+ # # be too noisy due to issues in dependencies.
72
+ # config.warnings = true
73
+ #
74
+ # # Many RSpec users commonly either run the entire suite or an individual
75
+ # # file, and it's useful to allow more verbose output when running an
76
+ # # individual spec file.
77
+ # if config.files_to_run.one?
78
+ # # Use the documentation formatter for detailed output,
79
+ # # unless a formatter has already been configured
80
+ # # (e.g. via a command-line flag).
81
+ # config.default_formatter = "doc"
82
+ # end
83
+ #
84
+ # # Print the 10 slowest examples and example groups at the
85
+ # # end of the spec run, to help surface which specs are running
86
+ # # particularly slow.
87
+ # config.profile_examples = 10
88
+ #
89
+ # # Run specs in random order to surface order dependencies. If you find an
90
+ # # order dependency and want to debug it, you can fix the order by providing
91
+ # # the seed, which is printed after each run.
92
+ # # --seed 1234
93
+ # config.order = :random
94
+ #
95
+ # # Seed global randomization in this process using the `--seed` CLI option.
96
+ # # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # # test failures related to randomization by passing the same `--seed` value
98
+ # # as the one that triggered the failure.
99
+ # Kernel.srand config.seed
100
+ 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.52.0
4
+ version: 0.53.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-06-20 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0.3'
109
+ - !ruby/object:Gem::Dependency
110
+ name: eac_git
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0.1'
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '0.1'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: eac_ruby_gems_utils
111
125
  requirement: !ruby/object:Gem::Requirement
@@ -278,6 +292,11 @@ files:
278
292
  - lib/avm/git/issue/complete/validation.rb
279
293
  - lib/avm/git/revision_test.rb
280
294
  - lib/avm/git/spec_helper.rb
295
+ - lib/avm/git/subrepo_check.rb
296
+ - lib/avm/git/subrepo_check/parent.rb
297
+ - lib/avm/git/subrepo_check/remote.rb
298
+ - lib/avm/git/subrepo_check/show_result.rb
299
+ - lib/avm/git/subrepo_checks.rb
281
300
  - lib/avm/instances.rb
282
301
  - lib/avm/instances/application.rb
283
302
  - lib/avm/instances/base.rb
@@ -379,6 +398,8 @@ files:
379
398
  - lib/avm/tools/runner/git/dirty_files.rb
380
399
  - lib/avm/tools/runner/git/issue.rb
381
400
  - lib/avm/tools/runner/git/revisions_test.rb
401
+ - lib/avm/tools/runner/git/subrepo.rb
402
+ - lib/avm/tools/runner/git/subrepo/check.rb
382
403
  - lib/avm/tools/runner/launcher.rb
383
404
  - lib/avm/tools/runner/ruby.rb
384
405
  - lib/avm/tools/runner/ruby/gems.rb
@@ -458,6 +479,18 @@ files:
458
479
  - template/avm/stereotypes/eac_ubuntu_base0/docker_image/Dockerfile
459
480
  - template/avm/stereotypes/eac_webapp_base0/apache_host/no_ssl.conf
460
481
  - template/avm/stereotypes/eac_wordpress_base0/deploy/wp-config.php.template
482
+ - vendor/gems/eac_git/Gemfile
483
+ - vendor/gems/eac_git/eac_git.gemspec
484
+ - vendor/gems/eac_git/lib/eac_git.rb
485
+ - vendor/gems/eac_git/lib/eac_git/executables.rb
486
+ - vendor/gems/eac_git/lib/eac_git/local.rb
487
+ - vendor/gems/eac_git/lib/eac_git/local/subrepo.rb
488
+ - vendor/gems/eac_git/lib/eac_git/local/subrepo/config.rb
489
+ - vendor/gems/eac_git/lib/eac_git/remote.rb
490
+ - vendor/gems/eac_git/lib/eac_git/remote/ls_result.rb
491
+ - vendor/gems/eac_git/lib/eac_git/version.rb
492
+ - vendor/gems/eac_git/spec/rubocop_spec.rb
493
+ - vendor/gems/eac_git/spec/spec_helper.rb
461
494
  - vendor/gems/eac_ruby_utils/Gemfile
462
495
  - vendor/gems/eac_ruby_utils/MIT-LICENCE
463
496
  - vendor/gems/eac_ruby_utils/README.rdoc