eac_tools 0.34.0 → 0.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +32 -18
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +1 -1
  5. data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_collector.rb +0 -0
  6. data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_discovery.rb +0 -0
  7. data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager/cached_instance.rb +0 -0
  8. data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager/cached_instances.rb +0 -0
  9. data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager.rb +0 -0
  10. data/sub/{avm-tools → avm}/lib/avm/launcher/context/settings.rb +0 -0
  11. data/sub/{avm-tools → avm}/lib/avm/launcher/context.rb +0 -0
  12. data/sub/avm/lib/avm/launcher/errors.rb +11 -0
  13. data/sub/{avm-tools → avm}/lib/avm/launcher/instances/base/cache.rb +0 -0
  14. data/sub/{avm-tools → avm}/lib/avm/launcher/instances/base.rb +0 -0
  15. data/sub/{avm-tools → avm}/lib/avm/launcher/instances/error.rb +0 -0
  16. data/sub/{avm-tools → avm}/lib/avm/launcher/instances/runner_helper.rb +0 -0
  17. data/sub/{avm-tools → avm}/lib/avm/launcher/instances/settings.rb +0 -0
  18. data/sub/avm/lib/avm/launcher/instances.rb +11 -0
  19. data/sub/{avm-tools → avm}/lib/avm/launcher/paths/logical.rb +0 -0
  20. data/sub/avm/lib/avm/launcher/paths.rb +11 -0
  21. data/sub/{avm-tools → avm}/lib/avm/launcher/project.rb +4 -5
  22. data/sub/{avm-tools → avm}/lib/avm/launcher/publish/base.rb +2 -5
  23. data/sub/avm/lib/avm/launcher/publish.rb +11 -0
  24. data/sub/avm/lib/avm/launcher.rb +9 -0
  25. data/sub/avm/lib/avm/registry.rb +0 -2
  26. data/sub/avm/lib/avm/version.rb +1 -1
  27. data/sub/avm-eac_php_base0/Gemfile +8 -0
  28. data/sub/avm-eac_php_base0/avm-eac_php_base0.gemspec +18 -0
  29. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/version.rb +7 -0
  30. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0.rb +9 -0
  31. data/sub/avm-eac_php_base0/spec/rubocop_spec.rb +3 -0
  32. data/sub/avm-eac_php_base0/spec/spec_helper.rb +4 -0
  33. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +1 -1
  34. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_host.rb +2 -1
  35. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/git_info.rb +2 -1
  36. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy.rb +0 -1
  37. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  38. data/sub/avm-git/Gemfile +8 -0
  39. data/sub/avm-git/avm-git.gemspec +22 -0
  40. data/sub/avm-git/lib/avm/git/auto_commit/commit_info.rb +23 -0
  41. data/sub/avm-git/lib/avm/git/auto_commit/rules/base.rb +39 -0
  42. data/sub/avm-git/lib/avm/git/auto_commit/rules/last.rb +19 -0
  43. data/sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb +45 -0
  44. data/sub/avm-git/lib/avm/git/auto_commit/rules/new.rb +24 -0
  45. data/sub/avm-git/lib/avm/git/auto_commit/rules/nth.rb +31 -0
  46. data/sub/avm-git/lib/avm/git/auto_commit/rules/unique.rb +21 -0
  47. data/sub/avm-git/lib/avm/git/auto_commit/rules.rb +31 -0
  48. data/sub/avm-git/lib/avm/git/auto_commit_path/ruby.rb +20 -0
  49. data/sub/avm-git/lib/avm/git/auto_commit_path.rb +28 -0
  50. data/sub/avm-git/lib/avm/git/commit/class_methods.rb +31 -0
  51. data/sub/avm-git/lib/avm/git/commit/deploy.rb +38 -0
  52. data/sub/avm-git/lib/avm/git/commit/deploy_methods.rb +19 -0
  53. data/sub/avm-git/lib/avm/git/commit/diff_tree_line.rb +32 -0
  54. data/sub/avm-git/lib/avm/git/commit/file.rb +46 -0
  55. data/sub/avm-git/lib/avm/git/commit.rb +59 -0
  56. data/sub/avm-git/lib/avm/git/file_auto_fixup.rb +83 -0
  57. data/sub/avm-git/lib/avm/git/issue/complete/commits.rb +42 -0
  58. data/sub/avm-git/lib/avm/git/issue/complete/git_subrepos.rb +23 -0
  59. data/sub/avm-git/lib/avm/git/issue/complete/local_branch.rb +61 -0
  60. data/sub/avm-git/lib/avm/git/issue/complete/local_tag.rb +39 -0
  61. data/sub/avm-git/lib/avm/git/issue/complete/push.rb +60 -0
  62. data/sub/avm-git/lib/avm/git/issue/complete/remote.rb +33 -0
  63. data/sub/avm-git/lib/avm/git/issue/complete/test.rb +40 -0
  64. data/sub/avm-git/lib/avm/git/issue/complete/tracker.rb +28 -0
  65. data/sub/avm-git/lib/avm/git/issue/complete/validation.rb +39 -0
  66. data/sub/avm-git/lib/avm/git/issue/complete/validations.rb +53 -0
  67. data/sub/avm-git/lib/avm/git/issue/complete/working_tree.rb +19 -0
  68. data/sub/avm-git/lib/avm/git/issue/complete.rb +66 -0
  69. data/sub/avm-git/lib/avm/git/issue/deliver.rb +56 -0
  70. data/sub/{avm-tools/lib/avm/patches.rb → avm-git/lib/avm/git/issue.rb} +3 -1
  71. data/sub/avm-git/lib/avm/git/organize/reference_update.rb +34 -0
  72. data/sub/avm-git/lib/avm/git/organize/repository.rb +76 -0
  73. data/sub/avm-git/lib/avm/git/organize.rb +11 -0
  74. data/sub/avm-git/lib/avm/git/revision_test.rb +105 -0
  75. data/sub/avm-git/lib/avm/git/scms/git/change_tracker.rb +35 -0
  76. data/sub/avm-git/lib/avm/git/scms/git/commit.rb +55 -0
  77. data/sub/avm-git/lib/avm/git/scms/git.rb +73 -0
  78. data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +39 -0
  79. data/sub/avm-git/lib/avm/git/scms/provider.rb +19 -0
  80. data/sub/avm-git/lib/avm/git/scms.rb +11 -0
  81. data/sub/avm-git/lib/avm/git/subrepo_check/parent.rb +51 -0
  82. data/sub/avm-git/lib/avm/git/subrepo_check/remote.rb +89 -0
  83. data/sub/avm-git/lib/avm/git/subrepo_check/show_result.rb +32 -0
  84. data/sub/avm-git/lib/avm/git/subrepo_check.rb +38 -0
  85. data/sub/avm-git/lib/avm/git/subrepo_checks.rb +59 -0
  86. data/sub/{avm-tools/lib/avm/launcher → avm-git/lib/avm/git}/vendor/github.rb +1 -1
  87. data/sub/avm-git/lib/avm/git/vendor.rb +11 -0
  88. data/sub/avm-git/lib/avm/git/version.rb +7 -0
  89. data/sub/avm-git/lib/avm/git.rb +11 -0
  90. data/sub/avm-git/spec/lib/avm/git/auto_commit_path_spec.rb +21 -0
  91. data/sub/avm-git/spec/lib/avm/git/commit/deploy_spec.rb +93 -0
  92. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec.rb +13 -0
  93. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/add.source.out +1 -0
  94. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
  95. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/modify.source.out +1 -0
  96. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
  97. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/remove.source.out +1 -0
  98. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
  99. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename.source.out +2 -0
  100. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
  101. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
  102. data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
  103. data/sub/avm-git/spec/lib/avm/git/commit_spec.rb +56 -0
  104. data/sub/avm-git/spec/lib/avm/git/scms/git_spec.rb +8 -0
  105. data/sub/avm-git/spec/lib/avm/git/scms/git_subrepo_spec.rb +8 -0
  106. data/sub/{avm-tools/spec/lib/avm/launcher → avm-git/spec/lib/avm/git}/vendor/github_spec.rb +4 -4
  107. data/sub/avm-git/spec/rubocop_spec.rb +3 -0
  108. data/sub/avm-git/spec/spec_helper.rb +4 -0
  109. data/sub/avm-tools/avm-tools.gemspec +3 -3
  110. data/sub/avm-tools/lib/avm/launcher/git/warp_base.rb +2 -2
  111. data/sub/avm-tools/lib/avm/projects/stereotypes/git_subrepo/warp.rb +2 -2
  112. data/sub/avm-tools/lib/avm/projects/stereotypes.rb +0 -9
  113. data/sub/avm-tools/lib/avm/tools/core_ext.rb +0 -1
  114. data/sub/avm-tools/lib/avm/tools/runner/launcher.rb +1 -0
  115. data/sub/avm-tools/lib/avm/tools/runner/source/info.rb +0 -4
  116. data/sub/avm-tools/lib/avm/tools/runner/source/test.rb +1 -1
  117. data/sub/avm-tools/lib/avm/tools/runner/source.rb +0 -12
  118. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  119. data/sub/avm-tools/spec/lib/avm/launcher/context_spec.rb +3 -3
  120. data/sub/eac_docker/eac_docker.gemspec +2 -2
  121. data/sub/eac_docker/lib/eac_docker/images/templatized.rb +7 -1
  122. data/sub/eac_docker/lib/eac_docker/version.rb +1 -1
  123. metadata +123 -37
  124. data/sub/avm-tools/lib/avm/launcher/instances.rb +0 -6
  125. data/sub/avm-tools/lib/avm/launcher/paths.rb +0 -4
  126. data/sub/avm-tools/lib/avm/launcher/publish.rb +0 -4
  127. data/sub/avm-tools/lib/avm/launcher/vendor.rb +0 -3
  128. data/sub/avm-tools/lib/avm/patches/i18n.rb +0 -22
  129. data/sub/avm-tools/lib/avm/projects/stereotype/job_comparator.rb +0 -32
  130. data/sub/avm-tools/lib/avm/projects/stereotypes/rails_application/local_project_mixin.rb +0 -18
  131. data/sub/avm-tools/lib/avm/projects/stereotypes/rails_application.rb +0 -25
  132. data/sub/avm-tools/lib/avm/projects/stereotypes/redmine_plugin.rb +0 -23
  133. data/sub/avm-tools/lib/avm/stereotypes.rb +0 -9
  134. data/sub/avm-tools/lib/avm/tools/source.rb +0 -64
  135. data/sub/avm-tools/locale/en.yml +0 -7
  136. data/sub/avm-tools/locale/pt-BR.yml +0 -7
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/base'
4
+ require 'eac_git/local'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Git
9
+ module Scms
10
+ class GitSubrepo < ::Avm::Scms::Base
11
+ delegate :commit_if_change, to: :parent_scm
12
+
13
+ def update
14
+ git_subrepo.command('clean').execute!
15
+ git_subrepo.command('pull').execute!
16
+ end
17
+
18
+ # @return [EacGit::Local]
19
+ def git_repo
20
+ @git_repo ||= ::EacGit::Local.find(path)
21
+ end
22
+
23
+ # @return [EacGit::Local::Subrepo]
24
+ def git_subrepo
25
+ @git_subrepo ||= git_repo.subrepo(subpath)
26
+ end
27
+
28
+ # @return [Pathname]
29
+ def subpath
30
+ path.expand_path.relative_path_from(git_repo.root_path.expand_path)
31
+ end
32
+
33
+ def valid?
34
+ path.join('.gitrepo').file?
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/scms/git'
4
+ require 'avm/git/scms/git_subrepo'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Git
9
+ module Scms
10
+ class Provider
11
+ SCMS = [::Avm::Git::Scms::Git, ::Avm::Git::Scms::GitSubrepo].freeze
12
+
13
+ def all
14
+ SCMS
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -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 Scms
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ 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,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ class SubrepoCheck
8
+ module ShowResult
9
+ def show_result
10
+ out(subrepo.subpath.to_path.cyan)
11
+ out_attr('parent', parent_result.label)
12
+ run_fix_parent
13
+ out_attr('remote', remote_result.label)
14
+ out("\n")
15
+ end
16
+
17
+ def run_fix_parent
18
+ return unless fix_parent?
19
+ return unless parent_result.error?
20
+
21
+ out('|Fixing...'.white)
22
+ self.parent_hash = expected_parent_hash
23
+ out_attr('new parent', parent_result.label)
24
+ end
25
+
26
+ def out_attr(key, value)
27
+ out('|' + "#{key}=".white + value)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ class SubrepoCheck
8
+ require_sub __FILE__, include_modules: true
9
+ enable_speaker
10
+ enable_simple_cache
11
+
12
+ BLANK_TEXT = 'BLANK'
13
+
14
+ common_constructor :subrepo, :options
15
+
16
+ def blank_text
17
+ BLANK_TEXT
18
+ end
19
+
20
+ def check_remote?
21
+ options.fetch(:check_remote) ? true : false
22
+ end
23
+
24
+ def fix_parent?
25
+ options.fetch(:fix_parent) ? true : false
26
+ end
27
+
28
+ private
29
+
30
+ def result_uncached
31
+ return ::Avm::Result.error('Parent failed') if parent_result.error?
32
+ return ::Avm::Result.error('Remote failed') if remote_result.error?
33
+
34
+ ::Avm::Result.success('Parent and remote ok')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/subrepo_check'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ class SubrepoChecks
9
+ enable_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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- module Launcher
4
+ module Git
5
5
  module Vendor
6
6
  module Github
7
7
  class << self
@@ -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 Vendor
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ VERSION = '0.5.0'
6
+ end
7
+ end
@@ -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
+ require_sub __FILE__
8
+
9
+ DEFAULT_REMOTE_NAME = 'origin'
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit_path'
4
+
5
+ RSpec.describe ::Avm::Git::AutoCommitPath, git: true do
6
+ let(:git) { stubbed_git_local_repo }
7
+
8
+ describe '#class_name' do
9
+ {
10
+ 'app/models/mynamespace/the_class.rb' => 'Mynamespace::TheClass',
11
+ 'lib/ruby/lib/cliutils/eac_redmine_base0/activity.rb' => 'Cliutils::EacRedmineBase0::Activity'
12
+ }.each do |relative_path, expected_class_name|
13
+ context "when path is \"#{relative_path}\"" do
14
+ let(:path) { git.root_path.join(relative_path) }
15
+ let(:instance) { described_class.new(git, path) }
16
+
17
+ it { expect(instance.class_name).to eq(expected_class_name) }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/commit'
4
+ require 'avm/git/commit/deploy'
5
+ require 'eac_ruby_utils/fs/temp'
6
+
7
+ RSpec.describe ::Avm::Git::Commit::Deploy, git: true do
8
+ class << self
9
+ FROM_DEPLOY = %w[a.txt b.txt c.txt appended].freeze # rubocop:disable RSpec/LeakyConstantDeclaration
10
+ NOT_FROM_DEPLOY = %w[to_be_removed].freeze # rubocop:disable RSpec/LeakyConstantDeclaration
11
+
12
+ def check_files(from_deploy_exist)
13
+ if from_deploy_exist
14
+ check_files_exist(FROM_DEPLOY)
15
+ check_files_not_exist(NOT_FROM_DEPLOY)
16
+ else
17
+ check_files_not_exist(FROM_DEPLOY)
18
+ check_files_exist(NOT_FROM_DEPLOY)
19
+ end
20
+ end
21
+
22
+ def check_file_exist(basename)
23
+ it("expect \"#{basename}\" to exist") { expect(target_dir.join(basename)).to exist }
24
+ end
25
+
26
+ def check_file_not_exist(basename)
27
+ it("expect \"#{basename}\" to not exist") { expect(target_dir.join(basename)).not_to exist }
28
+ end
29
+
30
+ def check_files_exist(basenames)
31
+ basenames.each { |basename| check_file_exist(basename) }
32
+ end
33
+
34
+ def check_files_not_exist(basenames)
35
+ basenames.each { |basename| check_file_not_exist(basename) }
36
+ end
37
+ end
38
+
39
+ let(:git) { stubbed_git_local_repo }
40
+
41
+ let(:commit_sha1) do
42
+ git.file('a.txt').write('AAA')
43
+ git.file('b.txt').write('BBB')
44
+ git.command('add', '.').execute!
45
+ git.command('commit', '-m', 'First commit.').execute!
46
+ git.rev_parse('HEAD')
47
+ end
48
+
49
+ let(:appended_dir) do
50
+ r = ::EacRubyUtils::Fs::Temp.directory
51
+ r.join('appended.template').write('Needs a %%ABC%% value.')
52
+ r
53
+ end
54
+
55
+ let(:target_dir) do
56
+ r = ::EacRubyUtils::Fs::Temp.directory
57
+ ::FileUtils.touch(r.join('to_be_removed').to_path)
58
+ r
59
+ end
60
+
61
+ let(:commit) { ::Avm::Git::Commit.new(git, commit_sha1) }
62
+ let(:variables_source_class) do
63
+ ::Class.new do
64
+ attr_reader :abc
65
+
66
+ def initialize(abc)
67
+ @abc = abc
68
+ end
69
+ end
70
+ end
71
+ let(:variables_source) { variables_source_class.new('Any value') }
72
+ let(:target_env) { ::EacRubyUtils::Envs.local }
73
+ let(:instance) do
74
+ described_class.new(commit, target_env, target_dir).append_templatized_directory(appended_dir)
75
+ .append_file_content('c.txt', 'Any content')
76
+ .variables_source_set(variables_source)
77
+ end
78
+
79
+ after do
80
+ appended_dir.remove
81
+ target_dir.remove
82
+ end
83
+
84
+ context 'without run' do # rubocop:disable RSpec/EmptyExampleGroup
85
+ check_files(false)
86
+ end
87
+
88
+ context 'with run' do # rubocop:disable RSpec/EmptyExampleGroup
89
+ before { instance.run }
90
+
91
+ check_files(true)
92
+ end
93
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/commit/diff_tree_line'
4
+
5
+ RSpec.describe ::Avm::Git::Commit::DiffTreeLine, git: true do
6
+ include_examples 'source_target_fixtures', __FILE__ do
7
+ def source_data(source_file)
8
+ ::File.read(source_file).each_line.map do |line|
9
+ described_class.new(line).fields
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ :000000 100644 0000000000000000000000000000000000000000 f380aec0bd8dd777edac43b11636e46cad04273a A nomes.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '000000'
3
+ dst_mode: '100644'
4
+ src_sha1: '0000000000000000000000000000000000000000'
5
+ dst_sha1: f380aec0bd8dd777edac43b11636e46cad04273a
6
+ status: A
7
+ path: nomes.txt
@@ -0,0 +1 @@
1
+ :100644 100644 40bcdecb4214cd8a3fcf96cd25a2beb87e7e7cd8 4a30dfae816b984f05cfb594e0d5958bb8c387ae M nomes.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '100644'
4
+ src_sha1: 40bcdecb4214cd8a3fcf96cd25a2beb87e7e7cd8
5
+ dst_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
6
+ status: M
7
+ path: nomes.txt
@@ -0,0 +1 @@
1
+ :100644 000000 10728718a2915256ab162f1e05178ebff9efa6ce 0000000000000000000000000000000000000000 D nomes3.txt
@@ -0,0 +1,7 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 10728718a2915256ab162f1e05178ebff9efa6ce
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes3.txt
@@ -0,0 +1,2 @@
1
+ :100644 000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae 0000000000000000000000000000000000000000 D nomes.txt
2
+ :000000 100644 0000000000000000000000000000000000000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae A nomes2.txt
@@ -0,0 +1,13 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes.txt
8
+ - src_mode: '000000'
9
+ dst_mode: '100644'
10
+ src_sha1: '0000000000000000000000000000000000000000'
11
+ dst_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
12
+ status: A
13
+ path: nomes2.txt
@@ -0,0 +1,2 @@
1
+ :100644 000000 4a30dfae816b984f05cfb594e0d5958bb8c387ae 0000000000000000000000000000000000000000 D nomes2.txt
2
+ :000000 100644 0000000000000000000000000000000000000000 10728718a2915256ab162f1e05178ebff9efa6ce A nomes3.txt
@@ -0,0 +1,13 @@
1
+ ---
2
+ - src_mode: '100644'
3
+ dst_mode: '000000'
4
+ src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
5
+ dst_sha1: '0000000000000000000000000000000000000000'
6
+ status: D
7
+ path: nomes2.txt
8
+ - src_mode: '000000'
9
+ dst_mode: '100644'
10
+ src_sha1: '0000000000000000000000000000000000000000'
11
+ dst_sha1: 10728718a2915256ab162f1e05178ebff9efa6ce
12
+ status: A
13
+ path: nomes3.txt
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/commit'
4
+
5
+ RSpec.describe ::Avm::Git::Commit, git: true do
6
+ let(:git) { stubbed_git_local_repo }
7
+
8
+ let(:first_commit_sha1) do
9
+ git.file('a.txt').write('AAA')
10
+ git.file('b.txt').write('BBB')
11
+ git.command('add', '.').execute!
12
+ git.command('commit', '-m', 'First commit.').execute!
13
+ git.rev_parse('HEAD')
14
+ end
15
+
16
+ let(:second_commit_sha1) do
17
+ first_commit_sha1
18
+ git.file('a.txt').write('AAAAA')
19
+ git.file('b.txt').delete
20
+ git.file('ç.txt').write('CCC')
21
+ git.command('add', '.').execute!
22
+ git.command('commit', '-m', 'Second commit.').execute!
23
+ git.rev_parse('HEAD')
24
+ end
25
+
26
+ let(:first_commit) { described_class.new(git, first_commit_sha1) }
27
+ let(:second_commit) { described_class.new(git, second_commit_sha1) }
28
+
29
+ describe '#files' do
30
+ it { expect(first_commit.files.count).to eq(2) }
31
+ it { expect(second_commit.files.count).to eq(3) }
32
+
33
+ {
34
+ 'first_commit' => %w[a.txt b.txt],
35
+ 'second_commit' => %w[a.txt b.txt ç.txt]
36
+ }.each do |commit_name, filenames|
37
+ filenames.each do |filename|
38
+ it "find file \"#{filename}\" in commit \"#{commit_name}\"" do
39
+ commit = send(commit_name)
40
+ file = commit.files.find { |f| f.path == filename }
41
+ expect(file).to be_a(::Avm::Git::Commit::File)
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#files_size' do
48
+ it { expect(first_commit.files_size).to eq(6) }
49
+ it { expect(second_commit.files_size).to eq(8) }
50
+ end
51
+
52
+ describe '#root_child?' do
53
+ it { expect(first_commit.root_child?).to eq(true) }
54
+ it { expect(second_commit.root_child?).to eq(false) }
55
+ end
56
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry'
4
+ require 'avm/git/scms/git'
5
+
6
+ ::RSpec.describe ::Avm::Git::Scms::Git do
7
+ include_examples 'in_avm_registry', 'scms'
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry'
4
+ require 'avm/git/scms/git_subrepo'
5
+
6
+ ::RSpec.describe ::Avm::Git::Scms::GitSubrepo do
7
+ include_examples 'in_avm_registry', 'scms'
8
+ end