avm-git 0.15.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/git/issue/complete/tracker.rb +0 -7
- data/lib/avm/git/issue/complete.rb +9 -6
- data/lib/avm/git/runners/base/commit.rb +102 -0
- data/lib/avm/git/runners/base/deploy.rb +111 -0
- data/lib/avm/git/runners/base/dirty_files.rb +44 -0
- data/lib/avm/git/runners/base/organize.rb +75 -0
- data/lib/avm/git/runners/base/revisions_test.rb +66 -0
- data/lib/avm/git/runners/base/subrepo/check.rb +48 -0
- data/lib/avm/git/runners/base/subrepo/clone.rb +83 -0
- data/lib/avm/git/runners/base/subrepo/fix.rb +76 -0
- data/lib/avm/git/runners/base/subrepo.rb +19 -0
- data/lib/avm/git/runners/base.rb +43 -0
- data/lib/avm/git/runners.rb +11 -0
- data/lib/avm/git/scms/git.rb +7 -0
- data/lib/avm/git/version.rb +1 -1
- metadata +55 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 127237b1bf254ced145bd74a7f70317df4f455b000e27a4f8b9b0a6a8dd37353
|
4
|
+
data.tar.gz: f619d4b32d1ded3780f8176bba97729c925ca941d3caf6ba22c02920a4140cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15892e24b21bbac290597b6f3d08fd50bdbe799f45be0be157f4976b99a4e372bf66d26ba64610c3dfcf92648260aec65a6ba4714ad878d66d71e2ca5978ceb1
|
7
|
+
data.tar.gz: 0c3b1519d8298e997db7540d7538b6701f88d9adfd82b8b9c9a315306cecbee80b3a02c8654cdc3f8d6480326d743b29c912252ce43dec7fd43b53f5048bb5bc
|
@@ -1,17 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'clipboard'
|
4
|
-
|
5
3
|
module Avm
|
6
4
|
module Git
|
7
5
|
module Issue
|
8
6
|
class Complete
|
9
7
|
module Tracker
|
10
|
-
def clipboard_copy_tracker_message
|
11
|
-
::Clipboard.copy(textile_tracker_message)
|
12
|
-
infov 'Copied to clipboard', textile_tracker_message
|
13
|
-
end
|
14
|
-
|
15
8
|
private
|
16
9
|
|
17
10
|
def textile_tracker_message_uncached
|
@@ -11,17 +11,21 @@ module Avm
|
|
11
11
|
enable_simple_cache
|
12
12
|
enable_speaker
|
13
13
|
|
14
|
-
|
14
|
+
attr_reader :scm, :skip_validations
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
def initialize(options)
|
16
|
+
def initialize(scm, options)
|
17
|
+
@scm = scm
|
19
18
|
consumer = ::EacRubyUtils::OptionsConsumer.new(options)
|
20
|
-
@
|
19
|
+
@skip_validations = consumer.consume(:skip_validations)
|
21
20
|
validate_skip_validations
|
22
21
|
consumer.validate
|
23
22
|
end
|
24
23
|
|
24
|
+
# @return [String]
|
25
|
+
def dir
|
26
|
+
scm.path.to_path
|
27
|
+
end
|
28
|
+
|
25
29
|
def start_banner
|
26
30
|
validations_banner
|
27
31
|
end
|
@@ -32,7 +36,6 @@ module Avm
|
|
32
36
|
assert_tag
|
33
37
|
push
|
34
38
|
remove_local_branch
|
35
|
-
clipboard_copy_tracker_message
|
36
39
|
true
|
37
40
|
end
|
38
41
|
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/speaker'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'avm/git/launcher/base'
|
6
|
+
require 'filesize'
|
7
|
+
require 'avm/git/commit'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module Git
|
11
|
+
module Runners
|
12
|
+
class Base
|
13
|
+
class Commit
|
14
|
+
runner_with :help do
|
15
|
+
desc 'Mostra informações de um commit.'
|
16
|
+
bool_opt '-f', '--files', 'Mostra os arquivos.'
|
17
|
+
bool_opt '-s', '--size', 'Mostra o tamanho de arquivos.'
|
18
|
+
pos_arg :ref
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
input_banner
|
23
|
+
validate
|
24
|
+
main_info_banner
|
25
|
+
files_banner
|
26
|
+
size_banner
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def input_banner
|
32
|
+
infov 'Repository', git
|
33
|
+
infov 'Reference', reference
|
34
|
+
end
|
35
|
+
|
36
|
+
def validate
|
37
|
+
return if reference_id.present?
|
38
|
+
|
39
|
+
fatal_error "Object ID not found for reference \"#{reference}\""
|
40
|
+
end
|
41
|
+
|
42
|
+
def main_info_banner
|
43
|
+
infov 'Reference ID', reference_id
|
44
|
+
infov 'Subject', commit.subject
|
45
|
+
infov 'Author', commit.author_all
|
46
|
+
infov 'Commiter', commit.commiter_all
|
47
|
+
infov 'Files', commit.files.count
|
48
|
+
end
|
49
|
+
|
50
|
+
def size_banner
|
51
|
+
return unless show_size?
|
52
|
+
|
53
|
+
infov 'Total files size', bytes_size(commit.files_size)
|
54
|
+
end
|
55
|
+
|
56
|
+
def files_banner
|
57
|
+
return unless parsed.files?
|
58
|
+
|
59
|
+
commit.files.each do |file|
|
60
|
+
infov " #{file.path}", file_value(file)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def file_value(file)
|
65
|
+
s = file.status
|
66
|
+
s += ", #{bytes_size(file.dst_size)}" if show_size?
|
67
|
+
s
|
68
|
+
end
|
69
|
+
|
70
|
+
def reference_id
|
71
|
+
git.rev_parse(reference)
|
72
|
+
end
|
73
|
+
|
74
|
+
def reference
|
75
|
+
parsed.ref
|
76
|
+
end
|
77
|
+
|
78
|
+
def git_uncached
|
79
|
+
::Avm::Git::Launcher::Base.new(runner_context.call(:repository_path))
|
80
|
+
end
|
81
|
+
|
82
|
+
def commit_uncached
|
83
|
+
::Avm::Git::Commit.new(git, reference_id)
|
84
|
+
end
|
85
|
+
|
86
|
+
def human_files_size
|
87
|
+
::Filesize.from("#{commit.files_size} B").pretty
|
88
|
+
end
|
89
|
+
|
90
|
+
def bytes_size(size)
|
91
|
+
b = "#{size} B"
|
92
|
+
"#{::Filesize.from(b).pretty} (#{b})"
|
93
|
+
end
|
94
|
+
|
95
|
+
def show_size?
|
96
|
+
parsed.size?
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/scms/git'
|
4
|
+
require 'eac_config/node'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class Deploy
|
11
|
+
DEFAULT_REFERENCE = 'HEAD'
|
12
|
+
|
13
|
+
runner_with :help do
|
14
|
+
desc 'Deploy a Git revision to a location (Local or remote).'
|
15
|
+
arg_opt '-a', '--append-dirs', 'Append directories to deploy (List separated by ":").'
|
16
|
+
arg_opt '-i', '--instance', 'Read entries from instance with id=<instance-id>.'
|
17
|
+
arg_opt '-r', '--reference', "Reference (default: #{DEFAULT_REFERENCE})."
|
18
|
+
pos_arg :target_url, optional: true
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
input_banner
|
23
|
+
validate
|
24
|
+
main_info_banner
|
25
|
+
deploy
|
26
|
+
success 'Done'
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def input_banner
|
32
|
+
infov 'Repository', git
|
33
|
+
infov 'Reference', reference
|
34
|
+
infov 'Instance ID', instance_id.if_present('- BLANK -')
|
35
|
+
infov 'Appended directories', appended_directories
|
36
|
+
infov 'Target URL', target_url
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate
|
40
|
+
if reference_sha1.blank?
|
41
|
+
fatal_error "Object ID not found for reference \"#{reference}\""
|
42
|
+
end
|
43
|
+
fatal_error 'Nor <target-url> nor --instance was setted' if target_url.blank?
|
44
|
+
end
|
45
|
+
|
46
|
+
def main_info_banner
|
47
|
+
infov 'Reference SHA1', reference_sha1
|
48
|
+
end
|
49
|
+
|
50
|
+
def reference_sha1_uncached
|
51
|
+
git.git_repo.rev_parse(reference)
|
52
|
+
end
|
53
|
+
|
54
|
+
def reference
|
55
|
+
parsed.reference || DEFAULT_REFERENCE
|
56
|
+
end
|
57
|
+
|
58
|
+
def git_uncached
|
59
|
+
::Avm::Git::Scms::Git.new(git_repository_path)
|
60
|
+
end
|
61
|
+
|
62
|
+
def git_repository_path
|
63
|
+
if runner_context.call(:repository_path) || dev_instance_fs_path.blank?
|
64
|
+
return runner_context.call(:repository_path)
|
65
|
+
end
|
66
|
+
|
67
|
+
dev_instance_fs_path
|
68
|
+
end
|
69
|
+
|
70
|
+
def dev_instance_fs_path
|
71
|
+
instance.if_present do |v|
|
72
|
+
v.application.instance('dev').read_entry_optional(
|
73
|
+
::Avm::Instances::EntryKeys::INSTALL_PATH
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def deploy
|
79
|
+
git.commit(reference_sha1)
|
80
|
+
.deploy_to_url(target_url)
|
81
|
+
.append_templatized_directories(appended_directories)
|
82
|
+
.variables_source_set(variables_source)
|
83
|
+
.run
|
84
|
+
end
|
85
|
+
|
86
|
+
def target_url
|
87
|
+
parsed.target_url.if_present { |v| return v }
|
88
|
+
instance.if_present { |v| return v.install_url }
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
92
|
+
def variables_source
|
93
|
+
instance || ::EacConfig::Node.context.current
|
94
|
+
end
|
95
|
+
|
96
|
+
def instance_uncached
|
97
|
+
instance_id.if_present { |v| ::Avm::Instances::Base.by_id(v) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def instance_id
|
101
|
+
parsed.instance
|
102
|
+
end
|
103
|
+
|
104
|
+
def appended_directories
|
105
|
+
parsed.append_dirs.to_s.split(':')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module Runners
|
8
|
+
class Base
|
9
|
+
class DirtyFiles
|
10
|
+
DEFAULT_FORMAT = '%p'
|
11
|
+
FIELDS = {
|
12
|
+
i: :index, w: :worktree, p: :path, a: :absolute_path
|
13
|
+
}.transform_keys { |k| "%#{k}" }
|
14
|
+
|
15
|
+
runner_with :help do
|
16
|
+
desc 'Lists dirty files in Git repository.'
|
17
|
+
arg_opt '-f', '--format',
|
18
|
+
"Format of each line (See \"Format fields\") [default: #{DEFAULT_FORMAT}]."
|
19
|
+
end
|
20
|
+
|
21
|
+
def help_extra_text
|
22
|
+
"Format fields:\n" + FIELDS.map { |k, v| " #{k} => #{v}" }.join("\n") # rubocop:disable Style/StringConcatenation
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
runner_context.call(:git).dirty_files.each do |file|
|
27
|
+
out("#{format_file(file)}\n")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def format
|
34
|
+
parsed.format || DEFAULT_FORMAT
|
35
|
+
end
|
36
|
+
|
37
|
+
def format_file(file)
|
38
|
+
FIELDS.inject(format) { |a, e| a.gsub(e.first, file.send(e.last)) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/git/organize/repository'
|
4
|
+
require 'eac_cli/default_runner'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class Organize
|
11
|
+
runner_with :help do
|
12
|
+
desc 'Organize branches.'
|
13
|
+
bool_opt '-a', '--all', 'Run all organizations.'
|
14
|
+
bool_opt '-n', '--no', 'Do not run operations.'
|
15
|
+
bool_opt '-o', '--originals', 'Remove refs/original branches.'
|
16
|
+
bool_opt '-s', '--subrepos', 'Remove git-subrepo branches.'
|
17
|
+
bool_opt '-y', '--yes', 'Run operations without confirmation.'
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
start_banner
|
22
|
+
collect_references
|
23
|
+
after_collect_banner
|
24
|
+
run_operations
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def after_collect_banner
|
30
|
+
infov 'Collected references', repository.collected_references.count
|
31
|
+
repository.collected_references.each do |ru|
|
32
|
+
infov " * #{ru.reference}", ru.operation
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def collect?(type)
|
37
|
+
parsed.fetch(type) || parsed.all?
|
38
|
+
end
|
39
|
+
|
40
|
+
def collect_references
|
41
|
+
%w[subrepos originals].each do |type|
|
42
|
+
repository.send("collect_#{type}") if collect?(type)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_operations
|
47
|
+
return warn('No operations to run (Run with --help to see options)') if
|
48
|
+
repository.collected_references.empty?
|
49
|
+
return unless run_operations?
|
50
|
+
|
51
|
+
repository.collected_references.each do |ru|
|
52
|
+
info "Doing operation #{ru}..."
|
53
|
+
ru.run_operation
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_operations?
|
58
|
+
return true if parsed.yes?
|
59
|
+
return false if parsed.no?
|
60
|
+
|
61
|
+
input('Confirm operations?', bool: true)
|
62
|
+
end
|
63
|
+
|
64
|
+
def repository_uncached
|
65
|
+
::Avm::Git::Organize::Repository.new(runner_context.call(:git).eac_git)
|
66
|
+
end
|
67
|
+
|
68
|
+
def start_banner
|
69
|
+
infov 'Repository', repository
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'avm/git/revision_test'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class RevisionsTest
|
11
|
+
runner_with :help do
|
12
|
+
desc 'Test multiple revisions until a error is found.'
|
13
|
+
arg_opt '-c', '--command', 'Command to test instance.'
|
14
|
+
bool_opt '-n', '--no-cache', 'Does not use cache.'
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
fatal_error('Repository is dirty') if runner_context.call(:git).dirty?
|
19
|
+
|
20
|
+
return_to_branch_on_end do
|
21
|
+
infov 'Revisions found', revisions.count
|
22
|
+
if revision_with_error
|
23
|
+
warn("First revision with error: #{revision_with_error}")
|
24
|
+
else
|
25
|
+
success('No error found in revisions')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def return_to_branch_on_end
|
33
|
+
current_branch = runner_context.call(:git).current_branch
|
34
|
+
yield
|
35
|
+
ensure
|
36
|
+
infom "Returning to original branch \"#{current_branch}\""
|
37
|
+
runner_context.call(:git).execute!('checkout', current_branch)
|
38
|
+
end
|
39
|
+
|
40
|
+
def revision_with_error_uncached
|
41
|
+
revision_with_error = nil
|
42
|
+
revisions.each do |revision|
|
43
|
+
revision.banner
|
44
|
+
unless revision.successful?
|
45
|
+
revision_with_error = revision
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
revision_with_error
|
50
|
+
end
|
51
|
+
|
52
|
+
def revisions_uncached
|
53
|
+
runner_context.call(:git).execute!('log', '--pretty=format:%H', 'origin/master..HEAD')
|
54
|
+
.each_line.map(&:strip).reverse.map do |sha1|
|
55
|
+
::Avm::Git::RevisionTest.new(runner_context.call(:git), sha1, test_revision_options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_revision_options
|
60
|
+
{ test_command: parsed.command, no_cache: parsed.no_cache? }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_git/local'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class Subrepo
|
11
|
+
class Check
|
12
|
+
runner_with :help do
|
13
|
+
desc 'Check status of subrepos.'
|
14
|
+
bool_opt '-a', '--all', 'Select all subrepos.'
|
15
|
+
bool_opt '-f', '--fix-parent', 'Fix parent SHA1.'
|
16
|
+
bool_opt '-n', '--no-error', 'Do not exit with error if check fails.'
|
17
|
+
bool_opt '-r', '--remote', 'Check subrepos remote.'
|
18
|
+
pos_arg :subrepos, repeat: true, optional: true
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
subrepo_checks.show_result
|
23
|
+
return if parsed.no_error?
|
24
|
+
return unless subrepo_checks.result.error?
|
25
|
+
|
26
|
+
fatal_error 'Failed'
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def subrepo_checks_uncached
|
32
|
+
r = ::Avm::Git::SubrepoChecks.new(local_repos)
|
33
|
+
r.check_remote = parsed.remote?
|
34
|
+
r.fix_parent = parsed.fix_parent?
|
35
|
+
r.add_all_subrepos if parsed.all?
|
36
|
+
r.add_subrepos(*parsed.subrepos)
|
37
|
+
r
|
38
|
+
end
|
39
|
+
|
40
|
+
def local_repos_uncached
|
41
|
+
::EacGit::Local.new(runner_context.call(:git))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_git/local'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class Subrepo
|
11
|
+
class Clone
|
12
|
+
runner_with :help do
|
13
|
+
desc 'Clone git-subrepo repositories.'
|
14
|
+
arg_opt '-b', '--branch', 'Branch.'
|
15
|
+
arg_opt '-d', '--parent-dir', 'Target path\'s parent directory.'
|
16
|
+
pos_arg :url
|
17
|
+
pos_arg :target_path, optional: true
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
start_banner
|
22
|
+
clean
|
23
|
+
clone
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def start_banner
|
29
|
+
infov 'URL', url
|
30
|
+
infov 'Subpath', target_path
|
31
|
+
infov 'Branch', branch
|
32
|
+
end
|
33
|
+
|
34
|
+
def clean
|
35
|
+
infom 'Cleaning...'
|
36
|
+
git.command('subrepo', 'clean', '--all', '--force').system!
|
37
|
+
end
|
38
|
+
|
39
|
+
def clone
|
40
|
+
infom 'Cloning...'
|
41
|
+
infov 'Clone arguments', clone_args
|
42
|
+
git.command(*clone_args).system!
|
43
|
+
end
|
44
|
+
|
45
|
+
delegate :branch, :url, to: :parsed
|
46
|
+
|
47
|
+
def git_uncached
|
48
|
+
::EacGit::Local.new('.')
|
49
|
+
end
|
50
|
+
|
51
|
+
def clone_args
|
52
|
+
['subrepo'] + branch.if_present([]) { |v| ['--branch', v] } +
|
53
|
+
if ::File.exist?(target_path)
|
54
|
+
['init', target_path, '--remote', url]
|
55
|
+
else
|
56
|
+
['clone', url, target_path, '--message', clone_message, '--force']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def clone_message
|
61
|
+
"Subrepo \"#{target_path}\" (#{url})."
|
62
|
+
end
|
63
|
+
|
64
|
+
def repos_name_from_url
|
65
|
+
%r{/([^/]+)\z}.if_match(url, false) { |m| m[1].gsub(/\.git\z/, '') }
|
66
|
+
end
|
67
|
+
|
68
|
+
def target_path
|
69
|
+
parsed.target_path || target_path_from_parent_dir ||
|
70
|
+
fatal_error('No target path specified')
|
71
|
+
end
|
72
|
+
|
73
|
+
def target_path_from_parent_dir
|
74
|
+
return nil unless parsed.parent_dir && repos_name_from_url
|
75
|
+
|
76
|
+
::File.join(parsed.parent_dir, repos_name_from_url)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'avm/git/scms/git'
|
5
|
+
require 'avm/git/subrepo_checks'
|
6
|
+
require 'avm/scms/auto_commit/rules/unique'
|
7
|
+
require 'avm/scms/auto_commit/for_file'
|
8
|
+
require 'eac_git/local'
|
9
|
+
|
10
|
+
module Avm
|
11
|
+
module Git
|
12
|
+
module Runners
|
13
|
+
class Base
|
14
|
+
class Subrepo
|
15
|
+
class Fix
|
16
|
+
runner_with :help do
|
17
|
+
desc 'Fix git-subrepos\' parent property.'
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
loop do
|
22
|
+
break if fix
|
23
|
+
|
24
|
+
amend_each
|
25
|
+
rebase_fixup
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def amend_each
|
32
|
+
infov 'Dirty files', local_repos.dirty_files.count
|
33
|
+
local_repos.dirty_files.each do |file|
|
34
|
+
infov ' * Ammending', file.path
|
35
|
+
::Avm::Scms::AutoCommit::ForFile.new(
|
36
|
+
git_scm, file.path,
|
37
|
+
[::Avm::Scms::AutoCommit::Rules::Unique.new]
|
38
|
+
).run
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def fix
|
43
|
+
infom 'Checking/fixing...'
|
44
|
+
c = new_check(true)
|
45
|
+
c.show_result
|
46
|
+
!c.result.error?
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Avm::Git::Scms::Git]
|
50
|
+
def git_scm_uncached
|
51
|
+
::Avm::Git::Scms::Git.new(runner_context.call(:git).root_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_check(fix_parent = false) # rubocop:disable Style/OptionalBooleanParameter
|
55
|
+
r = ::Avm::Git::SubrepoChecks.new(local_repos).add_all_subrepos
|
56
|
+
r.fix_parent = fix_parent
|
57
|
+
r
|
58
|
+
end
|
59
|
+
|
60
|
+
def local_repos_uncached
|
61
|
+
::EacGit::Local.new(runner_context.call(:git))
|
62
|
+
end
|
63
|
+
|
64
|
+
def rebase_fixup
|
65
|
+
local_repos.command('rebase', '-i', 'origin/master', '--autosquash').envvar(
|
66
|
+
'GIT_SEQUENCE_EDITOR', 'true'
|
67
|
+
).or(
|
68
|
+
local_repos.command('rebase', '--continue').envvar('GIT_SEQUENCE_EDITOR', 'true')
|
69
|
+
).system!
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Git
|
7
|
+
module Runners
|
8
|
+
class Base
|
9
|
+
class Subrepo
|
10
|
+
require_sub __FILE__
|
11
|
+
runner_with :help, :subcommands do
|
12
|
+
desc 'Git-subrepo (https://github.com/ingydotnet/git-subrepo) utilities.'
|
13
|
+
subcommands
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'avm/git/launcher/base'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Git
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
require_sub __FILE__
|
11
|
+
runner_with :help, :subcommands do
|
12
|
+
desc 'Git utilities for AVM.'
|
13
|
+
arg_opt '-C', '--path', 'Path to Git repository.'
|
14
|
+
subcommands
|
15
|
+
end
|
16
|
+
|
17
|
+
COMMAND_ARGUMENT = 'git'
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
def self.command_argument
|
21
|
+
COMMAND_ARGUMENT
|
22
|
+
end
|
23
|
+
|
24
|
+
def repository_path
|
25
|
+
repository_path? ? parsed.path : '.'
|
26
|
+
end
|
27
|
+
|
28
|
+
def repository_path?
|
29
|
+
parsed.path.present?
|
30
|
+
end
|
31
|
+
|
32
|
+
def git
|
33
|
+
@git ||= ::Avm::Git::Launcher::Base.by_root(repository_path)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [[EacGit::Local]]
|
37
|
+
def git_repo
|
38
|
+
git.eac_git
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/avm/git/scms/git.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/git/issue/complete'
|
3
4
|
require 'avm/git/scms/git_subrepo'
|
4
5
|
require 'avm/scms/base'
|
5
6
|
require 'eac_ruby_utils/core_ext'
|
@@ -17,6 +18,12 @@ module Avm
|
|
17
18
|
git_repo <=> other.git_repo
|
18
19
|
end
|
19
20
|
|
21
|
+
# @param options [Hash<Symbol, Object>]
|
22
|
+
# @return [Avm::Git::Issues::Complete]
|
23
|
+
def completer(options = {})
|
24
|
+
::Avm::Git::Issue::Complete.new(self, options)
|
25
|
+
end
|
26
|
+
|
20
27
|
def git_repo
|
21
28
|
@git_repo ||= ::EacGit::Local.new(path)
|
22
29
|
end
|
data/lib/avm/git/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.86'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.86.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
29
|
+
version: '0.86'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.86.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: avm-files
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +92,40 @@ dependencies:
|
|
86
92
|
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
94
|
version: 1.19.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: avm-eac_ubuntu_base0
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.5'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.5'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: avm-tools
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0.160'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.160.2
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.160'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.160.2
|
89
129
|
- !ruby/object:Gem::Dependency
|
90
130
|
name: eac_ruby_gem_support
|
91
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +196,17 @@ files:
|
|
156
196
|
- lib/avm/git/organize/reference_update.rb
|
157
197
|
- lib/avm/git/organize/repository.rb
|
158
198
|
- lib/avm/git/revision_test.rb
|
199
|
+
- lib/avm/git/runners.rb
|
200
|
+
- lib/avm/git/runners/base.rb
|
201
|
+
- lib/avm/git/runners/base/commit.rb
|
202
|
+
- lib/avm/git/runners/base/deploy.rb
|
203
|
+
- lib/avm/git/runners/base/dirty_files.rb
|
204
|
+
- lib/avm/git/runners/base/organize.rb
|
205
|
+
- lib/avm/git/runners/base/revisions_test.rb
|
206
|
+
- lib/avm/git/runners/base/subrepo.rb
|
207
|
+
- lib/avm/git/runners/base/subrepo/check.rb
|
208
|
+
- lib/avm/git/runners/base/subrepo/clone.rb
|
209
|
+
- lib/avm/git/runners/base/subrepo/fix.rb
|
159
210
|
- lib/avm/git/scms.rb
|
160
211
|
- lib/avm/git/scms/git.rb
|
161
212
|
- lib/avm/git/scms/git/branch.rb
|