avm-git 0.22.0 → 0.24.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 +4 -4
- data/lib/avm/git/issue/complete/commits.rb +1 -1
- data/lib/avm/git/issue/complete/git_subrepos.rb +1 -1
- data/lib/avm/git/launcher_stereotypes/git_subrepo.rb +9 -5
- data/lib/avm/git/runners/base/subrepo/check.rb +1 -1
- data/lib/avm/git/runners/base/subrepo/fix/rebase.rb +51 -0
- data/lib/avm/git/runners/base/subrepo/fix.rb +42 -33
- data/lib/avm/git/subrepo/check/parent.rb +50 -0
- data/lib/avm/git/subrepo/check/remote.rb +90 -0
- data/lib/avm/git/subrepo/check/show_result.rb +32 -0
- data/lib/avm/git/subrepo/check.rb +38 -0
- data/lib/avm/git/subrepo/checks.rb +59 -0
- data/lib/avm/git/version.rb +1 -1
- metadata +19 -12
- data/lib/avm/git/subrepo_check/parent.rb +0 -48
- data/lib/avm/git/subrepo_check/remote.rb +0 -86
- data/lib/avm/git/subrepo_check/show_result.rb +0 -30
- data/lib/avm/git/subrepo_check.rb +0 -36
- data/lib/avm/git/subrepo_checks.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f463713bd688c8f5f38ab60a0798195009a1c7c9e3fdbca0b63019de18af4e7e
|
|
4
|
+
data.tar.gz: 45b78d469200bcb7425ea018167b8ef987036892d255c08b9afc5c6cca25772e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 430a782734bd006d843458a05bce5b469d6bb5392215cd1e34110a1f397aabcf0b3d171fb4b7771b37d8b130334838fdf8b54eca5f14ae3b832c1a2393fc79a6
|
|
7
|
+
data.tar.gz: 239b3e62804fe65116688785d63d61a4da64e002d01bb149b75156a14aafc65c56c5c8d92678e537832c46288925198205122430c8dc1096259dfb0596b05f32
|
|
@@ -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::
|
|
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
|
|
@@ -18,11 +18,15 @@ module Avm
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def subrepo_url(path)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
configuration(path).remote_uri ||
|
|
22
|
+
raise(::Avm::Git::Launcher::Error.new(path, '"remote = ... " not found'))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# @return [EacGit::Subrepo::Configuration]
|
|
28
|
+
def configuration(path)
|
|
29
|
+
::EacGit::Subrepo::Configuration.from_file(path.subpath(CONFIG_SUBPATH))
|
|
26
30
|
end
|
|
27
31
|
end
|
|
28
32
|
end
|
|
@@ -26,7 +26,7 @@ module Avm
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
28
|
def subrepo_checks_uncached
|
|
29
|
-
r = ::Avm::Git::
|
|
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?
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'shellwords'
|
|
4
|
+
|
|
5
|
+
module Avm
|
|
6
|
+
module Git
|
|
7
|
+
module Runners
|
|
8
|
+
class Base
|
|
9
|
+
class Subrepo
|
|
10
|
+
class Fix
|
|
11
|
+
class Rebase
|
|
12
|
+
# @!method initialize(local, upstream, commands)
|
|
13
|
+
# @param local [EacGit::Local]
|
|
14
|
+
# @param upstream [String]
|
|
15
|
+
# @param commands [Hash<String, String>] Commands indexed by full commit ID.
|
|
16
|
+
common_constructor :local, :upstream, :commands
|
|
17
|
+
|
|
18
|
+
# @return [void]
|
|
19
|
+
def perform
|
|
20
|
+
::EacRubyUtils::Fs::Temp.on_file do |todo_file|
|
|
21
|
+
todo_file.write(todo)
|
|
22
|
+
local.command('rebase', '-i', upstream)
|
|
23
|
+
.envvar('GIT_SEQUENCE_EDITOR', "cp #{todo_file.to_path.shellescape}").system!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [String]
|
|
28
|
+
def todo
|
|
29
|
+
commits.flat_map { |commit| commit_lines(commit) }.map { |line| "#{line}\n" }.join
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
# @param commit [String]
|
|
35
|
+
# @return [Array<String>]
|
|
36
|
+
def commit_lines(commit)
|
|
37
|
+
["pick #{commit}", commands[commit].if_present { |v| "exec #{v}" }].compact
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [Array<String>]
|
|
41
|
+
def commits
|
|
42
|
+
local.command('rev-list', '--reverse', '--no-merges', "#{upstream}..HEAD")
|
|
43
|
+
.execute!.split
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -1,65 +1,74 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'shellwords'
|
|
4
|
+
|
|
3
5
|
module Avm
|
|
4
6
|
module Git
|
|
5
7
|
module Runners
|
|
6
8
|
class Base
|
|
7
9
|
class Subrepo
|
|
8
10
|
class Fix
|
|
11
|
+
UPSTREAM = 'origin/master'
|
|
12
|
+
|
|
9
13
|
runner_with :help do
|
|
10
14
|
desc 'Fix git-subrepos\' parent property.'
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
def run
|
|
14
|
-
|
|
15
|
-
break if fix
|
|
18
|
+
return unless check_failed?
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
+
rebase
|
|
21
|
+
fatal_error 'Failed' if check_failed?
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
private
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[::Avm::Scms::AutoCommit::Rules::Unique.new]
|
|
31
|
-
).run
|
|
32
|
-
end
|
|
26
|
+
# @return [Boolean]
|
|
27
|
+
def check_failed?
|
|
28
|
+
infom 'Checking...'
|
|
29
|
+
checks = ::Avm::Git::Subrepo::Checks.new(local_repos).add_all_subrepos
|
|
30
|
+
checks.show_result
|
|
31
|
+
checks.result.error?
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
# @param subrepos [Array<EacGit::Local::Subrepo>]
|
|
35
|
+
# @return [String]
|
|
36
|
+
def fix_parent_command(subrepos)
|
|
37
|
+
paths = subrepos.map { |subrepo| subrepo.config_relative_path.to_path.shellescape }
|
|
38
|
+
paths.map { |path| fix_parent_path_command(path) }
|
|
39
|
+
.push("git add -- #{paths.join(' ')}", 'git commit --amend --no-edit')
|
|
40
|
+
.join(' && ')
|
|
40
41
|
end
|
|
41
42
|
|
|
42
|
-
# @
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
# @param path [String]
|
|
44
|
+
# @return [String]
|
|
45
|
+
def fix_parent_path_command(path)
|
|
46
|
+
"git config --file=#{path} subrepo.parent \"$(git rev-parse HEAD^)\""
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
# @param subrepo [EacGit::Local::Subrepo]
|
|
50
|
+
# @return [String]
|
|
51
|
+
def last_config_change(subrepo)
|
|
52
|
+
local_repos.command('log', '-n', '1', '--pretty=format:%H', '--',
|
|
53
|
+
subrepo.config_relative_path.to_path).execute!.strip
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
# @return [EacGit::Local]
|
|
57
|
+
memoize def local_repos
|
|
54
58
|
::EacGit::Local.new(runner_context.call(:git))
|
|
55
59
|
end
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
).
|
|
61
|
+
# @return [void]
|
|
62
|
+
def rebase
|
|
63
|
+
::Avm::Git::Runners::Base::Subrepo::Fix::Rebase.new(
|
|
64
|
+
local_repos, UPSTREAM,
|
|
65
|
+
subrepos_by_last_config_change.transform_values { |v| fix_parent_command(v) }
|
|
66
|
+
).perform
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @return [Hash<String, Array<EacGit::Local::Subrepo>>]
|
|
70
|
+
memoize def subrepos_by_last_config_change
|
|
71
|
+
local_repos.subrepos.group_by { |subrepo| last_config_change(subrepo) }
|
|
63
72
|
end
|
|
64
73
|
end
|
|
65
74
|
end
|
|
@@ -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?) # rubocop:disable Rails/CompactBlank
|
|
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
|
data/lib/avm/git/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avm-git
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Put here the authors
|
|
@@ -29,28 +29,34 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0.
|
|
32
|
+
version: '0.22'
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 0.22.1
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
37
40
|
- - "~>"
|
|
38
41
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0.
|
|
42
|
+
version: '0.22'
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 0.22.1
|
|
40
46
|
- !ruby/object:Gem::Dependency
|
|
41
47
|
name: eac_ruby_utils
|
|
42
48
|
requirement: !ruby/object:Gem::Requirement
|
|
43
49
|
requirements:
|
|
44
50
|
- - "~>"
|
|
45
51
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.
|
|
52
|
+
version: '0.136'
|
|
47
53
|
type: :runtime
|
|
48
54
|
prerelease: false
|
|
49
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
56
|
requirements:
|
|
51
57
|
- - "~>"
|
|
52
58
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.
|
|
59
|
+
version: '0.136'
|
|
54
60
|
- !ruby/object:Gem::Dependency
|
|
55
61
|
name: filesize
|
|
56
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,14 +137,14 @@ dependencies:
|
|
|
131
137
|
requirements:
|
|
132
138
|
- - "~>"
|
|
133
139
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: '0.
|
|
140
|
+
version: '0.16'
|
|
135
141
|
type: :development
|
|
136
142
|
prerelease: false
|
|
137
143
|
version_requirements: !ruby/object:Gem::Requirement
|
|
138
144
|
requirements:
|
|
139
145
|
- - "~>"
|
|
140
146
|
- !ruby/object:Gem::Version
|
|
141
|
-
version: '0.
|
|
147
|
+
version: '0.16'
|
|
142
148
|
executables: []
|
|
143
149
|
extensions: []
|
|
144
150
|
extra_rdoc_files: []
|
|
@@ -195,6 +201,7 @@ files:
|
|
|
195
201
|
- lib/avm/git/runners/base/subrepo/check.rb
|
|
196
202
|
- lib/avm/git/runners/base/subrepo/clone.rb
|
|
197
203
|
- lib/avm/git/runners/base/subrepo/fix.rb
|
|
204
|
+
- lib/avm/git/runners/base/subrepo/fix/rebase.rb
|
|
198
205
|
- lib/avm/git/scms/git.rb
|
|
199
206
|
- lib/avm/git/scms/git/branch.rb
|
|
200
207
|
- lib/avm/git/scms/git/branches.rb
|
|
@@ -218,11 +225,11 @@ files:
|
|
|
218
225
|
- lib/avm/git/scms/git_subrepo.rb
|
|
219
226
|
- lib/avm/git/scms/git_subtree.rb
|
|
220
227
|
- lib/avm/git/scms/provider.rb
|
|
221
|
-
- lib/avm/git/
|
|
222
|
-
- lib/avm/git/
|
|
223
|
-
- lib/avm/git/
|
|
224
|
-
- lib/avm/git/
|
|
225
|
-
- lib/avm/git/
|
|
228
|
+
- lib/avm/git/subrepo/check.rb
|
|
229
|
+
- lib/avm/git/subrepo/check/parent.rb
|
|
230
|
+
- lib/avm/git/subrepo/check/remote.rb
|
|
231
|
+
- lib/avm/git/subrepo/check/show_result.rb
|
|
232
|
+
- lib/avm/git/subrepo/checks.rb
|
|
226
233
|
- lib/avm/git/vendor/github.rb
|
|
227
234
|
- lib/avm/git/version.rb
|
|
228
235
|
- locale/en.yml
|
|
@@ -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
|