avm-git 0.21.2 → 0.23.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5e3365c593041efd1512a07ec07777fed56aad6a4de8f07d29a9436a5adb03a
4
- data.tar.gz: 011b05583df24cea227ae16e47d178377bb856b534036e12879e67ab7844ad0d
3
+ metadata.gz: c4c0e911bba94f413eb588e697fc1cb9e554c234113525d54074717ac0a5f1c2
4
+ data.tar.gz: 270016ee525b2fc28b676506b500b0317fcecf091bb0d4c681bb54e65c78f50f
5
5
  SHA512:
6
- metadata.gz: 96451f44846dff848109d61142505edc68069df6a65db4c1a4bc0ca1e85c1e6857cf85c79f5d28e5301213bb0ebf4356e40742f71a3cd74a867e90a3152ce025
7
- data.tar.gz: d86e5f237409773b796672e88b3ccab0ed45da69a97e06304891cc361fbce96b018d14be020af1e92643d8b995093c3d0e7a8e4fadd6337bcd119080ba096c02
6
+ metadata.gz: 5a50ed12f4fbc5319220c03a8dd2b18cecd5b95331f65c23278a070eb7b22e04481e24196099efcb95e8dae3a82c870dc24d9a2277122e1f43de507a874edb19
7
+ data.tar.gz: 43ed4f6abd73fc9b70e47067d7cc91e04fef7981257ae7a1e6ac091fde237e5145b04a81708514307c2e1154b8b2d2eb31e4401f145847500d9bd38580398fb8
@@ -4,7 +4,7 @@ module Avm
4
4
  module Git
5
5
  class Commit
6
6
  class DiffTreeLine
7
- DIFF_TREE_PATTERN = /\A:(\d{6}) (\d{6}) (\S+) (\S+) (\S+)\t(\S.*)\z/.freeze
7
+ DIFF_TREE_PATTERN = /\A:(\d{6}) (\d{6}) (\S+) (\S+) (\S+)\t(\S.*)\z/
8
8
  FIELDS = %w[src_mode dst_mode src_sha1 dst_sha1 status path].freeze
9
9
  GIT_COMMAND_ARGS = %w[-c core.quotepath=off diff-tree --no-commit-id -r --full-index].freeze
10
10
 
@@ -9,7 +9,7 @@ module Avm
9
9
  return ::Avm::Result.error('Unclean workspace') unless clean_workspace?
10
10
 
11
11
  infom 'Checking Git subrepos...'
12
- r = ::Avm::Git::SubrepoChecks.new(::EacGit::Local.new(launcher_git)).add_all_subrepos
12
+ r = ::Avm::Git::Subrepo::Checks.new(::EacGit::Local.new(launcher_git)).add_all_subrepos
13
13
  r.check_remote = true
14
14
  r.result
15
15
  end
@@ -13,9 +13,9 @@ module Avm
13
13
  )
14
14
  end
15
15
 
16
- # @return [EacGit::Local::Subrepo::Config]
16
+ # @return [EacGit::Subrepo::Configuration]
17
17
  def config
18
- ::EacGit::Local::Subrepo::Config.from_file(config_path)
18
+ ::EacGit::Subrepo::Configuration.from_file(config_path)
19
19
  end
20
20
 
21
21
  # @return [String]
@@ -26,7 +26,7 @@ module Avm
26
26
  private
27
27
 
28
28
  def subrepo_checks_uncached
29
- r = ::Avm::Git::SubrepoChecks.new(local_repos)
29
+ r = ::Avm::Git::Subrepo::Checks.new(local_repos)
30
30
  r.check_remote = parsed.remote?
31
31
  r.fix_parent = parsed.fix_parent?
32
32
  r.add_all_subrepos if parsed.all?
@@ -45,7 +45,7 @@ module Avm
45
45
  end
46
46
 
47
47
  def new_check(fix_parent = false) # rubocop:disable Style/OptionalBooleanParameter
48
- r = ::Avm::Git::SubrepoChecks.new(local_repos).add_all_subrepos
48
+ r = ::Avm::Git::Subrepo::Checks.new(local_repos).add_all_subrepos
49
49
  r.fix_parent = fix_parent
50
50
  r
51
51
  end
@@ -12,7 +12,7 @@ module Avm
12
12
  delegate :git_repo, to: :git_scm
13
13
  delegate :id, to: :git_commit
14
14
 
15
- FIXUP_SUBJECT_PATTERN = /\Afixup!/.freeze
15
+ FIXUP_SUBJECT_PATTERN = /\Afixup!/
16
16
 
17
17
  # @return [Array<Pathname>]
18
18
  def changed_files
@@ -6,7 +6,7 @@ module Avm
6
6
  class GitSubBase < ::Avm::Scms::Base
7
7
  enable_abstract_methods
8
8
 
9
- delegate :commit_if_change, :current_milestone_base_commit,
9
+ delegate :commit_if_change, :current_milestone_base_commit, :git_repo,
10
10
  :head_commit, :reset_and_commit, :run_commit, to: :parent_scm
11
11
 
12
12
  # @return [Enumerable<Avm::Git::Scms::GitSubBase::ChangedFile>]
@@ -9,11 +9,6 @@ module Avm
9
9
  git_subrepo.command('pull').execute!
10
10
  end
11
11
 
12
- # @return [EacGit::Local]
13
- def git_repo
14
- @git_repo ||= ::EacGit::Local.find(path)
15
- end
16
-
17
12
  # @return [EacGit::Local::Subrepo]
18
13
  def git_subrepo
19
14
  @git_subrepo ||= git_repo.subrepo(subpath)
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Subrepo
6
+ class Check
7
+ module Parent
8
+ def fix_parent
9
+ return if parent_result.success?
10
+
11
+ info(' Fixing...')
12
+ self.parent_hash = expected_parent_hash
13
+ info_banner
14
+ end
15
+
16
+ private
17
+
18
+ def expected_parent_hash_uncached
19
+ subrepo.local.rev_parse("#{last_file_change_rev}^")
20
+ end
21
+
22
+ def last_file_change_rev
23
+ subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
24
+ subrepo.config_relative_path.to_path).execute!.strip
25
+ end
26
+
27
+ def parent_hash
28
+ subrepo.parent_commit_id
29
+ end
30
+
31
+ def parent_hash=(new_hash)
32
+ subrepo.config.parent_commit_id = new_hash
33
+ subrepo.write_config
34
+ end
35
+
36
+ def parent_hash_ok?
37
+ return false if expected_parent_hash.blank? || parent_hash.blank?
38
+
39
+ expected_parent_hash == parent_hash
40
+ end
41
+
42
+ def parent_result_uncached
43
+ ::Avm::Result.success_or_error(parent_hash_ok?,
44
+ parent_hash.presence || blank_text)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Subrepo
6
+ class Check
7
+ module Remote
8
+ private
9
+
10
+ def fetch_uncached
11
+ subrepo.command('clean').execute!
12
+ subrepo.command('fetch').execute!
13
+ end
14
+
15
+ def check_remote_disabled?
16
+ !check_remote?
17
+ end
18
+
19
+ def check_remote_disabled_result
20
+ ::Avm::Result.neutral('Check remote disabled')
21
+ end
22
+
23
+ def local_descend_remote?
24
+ local_id.present? && remote_id.present? && subrepo.local.descendant?(local_id,
25
+ remote_id)
26
+ end
27
+
28
+ def local_descend_remote_result
29
+ ::Avm::Result.pending(remote_result_value)
30
+ end
31
+
32
+ def local_id_uncached
33
+ fetch
34
+ subrepo.command('branch', '--force').execute!
35
+ subrepo.local.rev_parse("subrepo/#{subrepo.subpath}")
36
+ end
37
+
38
+ def remote_descend_local?
39
+ local_id.present? && remote_id.present? && subrepo.local.descendant?(remote_id,
40
+ 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
+ # @return [String, nil]
52
+ def remote_id_uncached
53
+ subrepo.remote.ls.then do |ls_result|
54
+ remote_branches.lazy.map { |b| ls_result[b] }.find(&:present?) ||
55
+ subrepo.remote_branch
56
+ end
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
90
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Subrepo
6
+ class Check
7
+ module ShowResult
8
+ def show_result
9
+ out(subrepo.subpath.to_path.cyan)
10
+ out_attr('parent', parent_result.label)
11
+ run_fix_parent
12
+ out_attr('remote', remote_result.label)
13
+ out("\n")
14
+ end
15
+
16
+ def run_fix_parent
17
+ return unless fix_parent?
18
+ return unless parent_result.error?
19
+
20
+ out('|Fixing...'.white)
21
+ self.parent_hash = expected_parent_hash
22
+ out_attr('new parent', parent_result.label)
23
+ end
24
+
25
+ def out_attr(key, value)
26
+ out("|#{"#{key}=".white}#{value}")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Subrepo
6
+ class Check
7
+ require_sub __FILE__, include_modules: true
8
+ enable_speaker
9
+ enable_simple_cache
10
+
11
+ BLANK_TEXT = 'BLANK'
12
+
13
+ common_constructor :subrepo, :options
14
+
15
+ def blank_text
16
+ BLANK_TEXT
17
+ end
18
+
19
+ def check_remote?
20
+ options.fetch(:check_remote) ? true : false
21
+ end
22
+
23
+ def fix_parent?
24
+ options.fetch(:fix_parent) ? true : false
25
+ end
26
+
27
+ private
28
+
29
+ def result_uncached
30
+ return ::Avm::Result.error('Parent failed') if parent_result.error?
31
+ return ::Avm::Result.error('Remote failed') if remote_result.error?
32
+
33
+ ::Avm::Result.success('Parent and remote ok')
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Subrepo
6
+ class Checks
7
+ enable_speaker
8
+ enable_simple_cache
9
+ attr_accessor :check_remote, :fix_parent
10
+
11
+ common_constructor :repository
12
+
13
+ def add_all_subrepos
14
+ add_subrepos(
15
+ *repository.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
16
+ .select(&:present?)
17
+ )
18
+ end
19
+
20
+ def add_subrepos(*subpath_list)
21
+ subpath_list.each do |subpath|
22
+ subpaths.add(subpath)
23
+ end
24
+ reset_cache
25
+ self
26
+ end
27
+
28
+ def check_options
29
+ { fix_parent: fix_parent, check_remote: check_remote }
30
+ end
31
+
32
+ def show_result
33
+ checks.each(&:show_result)
34
+ infov 'Result', result.label
35
+ end
36
+
37
+ private
38
+
39
+ def checks_uncached
40
+ subpaths.map do |subpath|
41
+ ::Avm::Git::Subrepo::Check.new(repository.subrepo(subpath), check_options)
42
+ end
43
+ end
44
+
45
+ def result_uncached
46
+ error_count = checks.count { |check| check.result.error? }
47
+ ::Avm::Result.success_or_error(
48
+ error_count.zero?,
49
+ "#{error_count} of #{checks.count} subrepos failed"
50
+ )
51
+ end
52
+
53
+ def subpaths
54
+ @subpaths ||= ::Set.new
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Git
5
- VERSION = '0.21.2'
5
+ VERSION = '0.23.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.2
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-02-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: avm
@@ -16,74 +15,56 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '0.98'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.98.4
18
+ version: '0.103'
23
19
  type: :runtime
24
20
  prerelease: false
25
21
  version_requirements: !ruby/object:Gem::Requirement
26
22
  requirements:
27
23
  - - "~>"
28
24
  - !ruby/object:Gem::Version
29
- version: '0.98'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.98.4
25
+ version: '0.103'
33
26
  - !ruby/object:Gem::Dependency
34
27
  name: eac_git
35
28
  requirement: !ruby/object:Gem::Requirement
36
29
  requirements:
37
30
  - - "~>"
38
31
  - !ruby/object:Gem::Version
39
- version: '0.18'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.18.1
32
+ version: '0.22'
43
33
  type: :runtime
44
34
  prerelease: false
45
35
  version_requirements: !ruby/object:Gem::Requirement
46
36
  requirements:
47
37
  - - "~>"
48
38
  - !ruby/object:Gem::Version
49
- version: '0.18'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.18.1
39
+ version: '0.22'
53
40
  - !ruby/object:Gem::Dependency
54
41
  name: eac_ruby_utils
55
42
  requirement: !ruby/object:Gem::Requirement
56
43
  requirements:
57
44
  - - "~>"
58
45
  - !ruby/object:Gem::Version
59
- version: '0.129'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.129.1
46
+ version: '0.134'
63
47
  type: :runtime
64
48
  prerelease: false
65
49
  version_requirements: !ruby/object:Gem::Requirement
66
50
  requirements:
67
51
  - - "~>"
68
52
  - !ruby/object:Gem::Version
69
- version: '0.129'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.129.1
53
+ version: '0.134'
73
54
  - !ruby/object:Gem::Dependency
74
55
  name: filesize
75
56
  requirement: !ruby/object:Gem::Requirement
76
57
  requirements:
77
- - - ">="
58
+ - - "~>"
78
59
  - !ruby/object:Gem::Version
79
- version: '0'
60
+ version: '0.2'
80
61
  type: :runtime
81
62
  prerelease: false
82
63
  version_requirements: !ruby/object:Gem::Requirement
83
64
  requirements:
84
- - - ">="
65
+ - - "~>"
85
66
  - !ruby/object:Gem::Version
86
- version: '0'
67
+ version: '0.2'
87
68
  - !ruby/object:Gem::Dependency
88
69
  name: git
89
70
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +92,9 @@ dependencies:
111
92
  - - "~>"
112
93
  - !ruby/object:Gem::Version
113
94
  version: '0.7'
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 0.7.2
114
98
  type: :development
115
99
  prerelease: false
116
100
  version_requirements: !ruby/object:Gem::Requirement
@@ -118,48 +102,43 @@ dependencies:
118
102
  - - "~>"
119
103
  - !ruby/object:Gem::Version
120
104
  version: '0.7'
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 0.7.2
121
108
  - !ruby/object:Gem::Dependency
122
109
  name: avm-tools
123
110
  requirement: !ruby/object:Gem::Requirement
124
111
  requirements:
125
112
  - - "~>"
126
113
  - !ruby/object:Gem::Version
127
- version: '0.163'
114
+ version: '0.164'
128
115
  - - ">="
129
116
  - !ruby/object:Gem::Version
130
- version: 0.163.6
117
+ version: 0.164.1
131
118
  type: :development
132
119
  prerelease: false
133
120
  version_requirements: !ruby/object:Gem::Requirement
134
121
  requirements:
135
122
  - - "~>"
136
123
  - !ruby/object:Gem::Version
137
- version: '0.163'
124
+ version: '0.164'
138
125
  - - ">="
139
126
  - !ruby/object:Gem::Version
140
- version: 0.163.6
127
+ version: 0.164.1
141
128
  - !ruby/object:Gem::Dependency
142
129
  name: eac_ruby_gem_support
143
130
  requirement: !ruby/object:Gem::Requirement
144
131
  requirements:
145
132
  - - "~>"
146
133
  - !ruby/object:Gem::Version
147
- version: '0.12'
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: 0.12.1
134
+ version: '0.15'
151
135
  type: :development
152
136
  prerelease: false
153
137
  version_requirements: !ruby/object:Gem::Requirement
154
138
  requirements:
155
139
  - - "~>"
156
140
  - !ruby/object:Gem::Version
157
- version: '0.12'
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: 0.12.1
161
- description:
162
- email:
141
+ version: '0.15'
163
142
  executables: []
164
143
  extensions: []
165
144
  extra_rdoc_files: []
@@ -239,19 +218,17 @@ files:
239
218
  - lib/avm/git/scms/git_subrepo.rb
240
219
  - lib/avm/git/scms/git_subtree.rb
241
220
  - lib/avm/git/scms/provider.rb
242
- - lib/avm/git/subrepo_check.rb
243
- - lib/avm/git/subrepo_check/parent.rb
244
- - lib/avm/git/subrepo_check/remote.rb
245
- - lib/avm/git/subrepo_check/show_result.rb
246
- - lib/avm/git/subrepo_checks.rb
221
+ - lib/avm/git/subrepo/check.rb
222
+ - lib/avm/git/subrepo/check/parent.rb
223
+ - lib/avm/git/subrepo/check/remote.rb
224
+ - lib/avm/git/subrepo/check/show_result.rb
225
+ - lib/avm/git/subrepo/checks.rb
247
226
  - lib/avm/git/vendor/github.rb
248
227
  - lib/avm/git/version.rb
249
228
  - locale/en.yml
250
229
  - locale/pt-BR.yml
251
- homepage:
252
230
  licenses: []
253
231
  metadata: {}
254
- post_install_message:
255
232
  rdoc_options: []
256
233
  require_paths:
257
234
  - lib
@@ -266,8 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
243
  - !ruby/object:Gem::Version
267
244
  version: '0'
268
245
  requirements: []
269
- rubygems_version: 3.4.19
270
- signing_key:
246
+ rubygems_version: 3.6.9
271
247
  specification_version: 4
272
248
  summary: Put here de description.
273
249
  test_files: []
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Git
5
- class SubrepoCheck
6
- module Parent
7
- def fix_parent
8
- return if parent_result.success?
9
-
10
- info(' Fixing...')
11
- self.parent_hash = expected_parent_hash
12
- info_banner
13
- end
14
-
15
- private
16
-
17
- def expected_parent_hash_uncached
18
- subrepo.local.rev_parse("#{last_file_change_rev}^")
19
- end
20
-
21
- def last_file_change_rev
22
- subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
23
- subrepo.config_relative_path.to_path).execute!.strip
24
- end
25
-
26
- def parent_hash
27
- subrepo.parent_commit_id
28
- end
29
-
30
- def parent_hash=(new_hash)
31
- subrepo.config.parent_commit_id = new_hash
32
- subrepo.write_config
33
- end
34
-
35
- def parent_hash_ok?
36
- return false if expected_parent_hash.blank? || parent_hash.blank?
37
-
38
- expected_parent_hash == parent_hash
39
- end
40
-
41
- def parent_result_uncached
42
- ::Avm::Result.success_or_error(parent_hash_ok?,
43
- parent_hash.presence || blank_text)
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Git
5
- class SubrepoCheck
6
- module Remote
7
- private
8
-
9
- def fetch_uncached
10
- subrepo.command('clean').execute!
11
- subrepo.command('fetch').execute!
12
- end
13
-
14
- def check_remote_disabled?
15
- !check_remote?
16
- end
17
-
18
- def check_remote_disabled_result
19
- ::Avm::Result.neutral('Check remote disabled')
20
- end
21
-
22
- def local_descend_remote?
23
- local_id.present? && remote_id.present? && subrepo.local.descendant?(local_id, remote_id)
24
- end
25
-
26
- def local_descend_remote_result
27
- ::Avm::Result.pending(remote_result_value)
28
- end
29
-
30
- def local_id_uncached
31
- fetch
32
- subrepo.command('branch', '--force').execute!
33
- subrepo.local.rev_parse("subrepo/#{subrepo.subpath}")
34
- end
35
-
36
- def remote_descend_local?
37
- local_id.present? && remote_id.present? && subrepo.local.descendant?(remote_id, local_id)
38
- end
39
-
40
- def remote_descend_local_result
41
- ::Avm::Result.outdated(remote_result_value)
42
- end
43
-
44
- def remote_branches
45
- ['', 'refs/heads/', 'refs/tags/'].map { |prefix| "#{prefix}#{subrepo.remote_branch}" }
46
- end
47
-
48
- def remote_id_uncached
49
- ls_result = subrepo.remote.ls
50
- remote_branches.each do |b|
51
- return ls_result[b] if ls_result[b].present?
52
- end
53
- nil
54
- end
55
-
56
- def remote_result_uncached
57
- %w[check_remote_disabled same_ids local_descend_remote remote_descend_local]
58
- .each do |condition|
59
- return send("#{condition}_result") if send("#{condition}?")
60
- end
61
-
62
- ::Avm::Result.error(remote_result_value)
63
- end
64
-
65
- def remote_result_value
66
- local_s = local_id.presence || blank_text
67
- remote_s = remote_id.presence || blank_text
68
-
69
- if local_s == remote_s
70
- "[L/R=#{local_s}]"
71
- else
72
- "[L=#{local_s}, R=#{remote_s}]"
73
- end
74
- end
75
-
76
- def same_ids?
77
- local_id.present? && remote_id.present? && local_id == remote_id
78
- end
79
-
80
- def same_ids_result
81
- ::Avm::Result.success(remote_result_value)
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Git
5
- class SubrepoCheck
6
- module ShowResult
7
- def show_result
8
- out(subrepo.subpath.to_path.cyan)
9
- out_attr('parent', parent_result.label)
10
- run_fix_parent
11
- out_attr('remote', remote_result.label)
12
- out("\n")
13
- end
14
-
15
- def run_fix_parent
16
- return unless fix_parent?
17
- return unless parent_result.error?
18
-
19
- out('|Fixing...'.white)
20
- self.parent_hash = expected_parent_hash
21
- out_attr('new parent', parent_result.label)
22
- end
23
-
24
- def out_attr(key, value)
25
- out("|#{"#{key}=".white}#{value}")
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Git
5
- class SubrepoCheck
6
- require_sub __FILE__, include_modules: true
7
- enable_speaker
8
- enable_simple_cache
9
-
10
- BLANK_TEXT = 'BLANK'
11
-
12
- common_constructor :subrepo, :options
13
-
14
- def blank_text
15
- BLANK_TEXT
16
- end
17
-
18
- def check_remote?
19
- options.fetch(:check_remote) ? true : false
20
- end
21
-
22
- def fix_parent?
23
- options.fetch(:fix_parent) ? true : false
24
- end
25
-
26
- private
27
-
28
- def result_uncached
29
- return ::Avm::Result.error('Parent failed') if parent_result.error?
30
- return ::Avm::Result.error('Remote failed') if remote_result.error?
31
-
32
- ::Avm::Result.success('Parent and remote ok')
33
- end
34
- end
35
- end
36
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Git
5
- class SubrepoChecks
6
- enable_speaker
7
- enable_simple_cache
8
- attr_accessor :check_remote, :fix_parent
9
-
10
- common_constructor :repository
11
-
12
- def add_all_subrepos
13
- add_subrepos(
14
- *repository.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
15
- .select(&:present?)
16
- )
17
- end
18
-
19
- def add_subrepos(*subpath_list)
20
- subpath_list.each do |subpath|
21
- subpaths.add(subpath)
22
- end
23
- reset_cache
24
- self
25
- end
26
-
27
- def check_options
28
- { fix_parent: fix_parent, check_remote: check_remote }
29
- end
30
-
31
- def show_result
32
- checks.each(&:show_result)
33
- infov 'Result', result.label
34
- end
35
-
36
- private
37
-
38
- def checks_uncached
39
- subpaths.map do |subpath|
40
- ::Avm::Git::SubrepoCheck.new(repository.subrepo(subpath), check_options)
41
- end
42
- end
43
-
44
- def result_uncached
45
- error_count = checks.count { |check| check.result.error? }
46
- ::Avm::Result.success_or_error(
47
- error_count.zero?,
48
- "#{error_count} of #{checks.count} subrepos failed"
49
- )
50
- end
51
-
52
- def subpaths
53
- @subpaths ||= ::Set.new
54
- end
55
- end
56
- end
57
- end