avm-tools 0.160.2 → 0.161.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1b154f50057111e84c1d82da312b7112d9ab8bb5e0edfd5e30d978e6c131d5c
4
- data.tar.gz: 98d34402b51f7e4067f47474c6a1871d94b03b54aaea7b527bf2891696467892
3
+ metadata.gz: 18e8fb1811160fff4ea550cd00d4dc07df7b6dfc04a479ada4fde54262b05525
4
+ data.tar.gz: a0f392810689ed69690988ad4335041cb5db89debea91df60534f98a49603d93
5
5
  SHA512:
6
- metadata.gz: '092a678bd40b041317079126e5a5522c79e31b78019974f0e44b16700bb700ba91a8198d0e94814e66037750ec970a52724a010d215a043e69b3303451c53cdc'
7
- data.tar.gz: eaa62db1a42bca9180b09ce0c8ba08c5c591cbbe2e55a1d86ae1cfd44d7f6b0fae35eb36ac2007c235329f60526c4cde94b8020c630accae5bc5414847bc20ff
6
+ metadata.gz: 63b61dc16475acf7604a8f171b4965171826e530f2a6faab121ef4e868e34cd3810ced5548c75f05d382596f4cec9a26b219f202633924c80fd060a559658254
7
+ data.tar.gz: 6b094b1d1c838f1514b33855e7000d6ca201747c6996d91148bbe20abf4e98ada529ea26692767652bd0be72714b59644cf87991a6ada50986187d9df749ce1c
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/file_formats/search_formatter'
4
+ require 'avm/registry'
4
5
  require 'eac_cli/core_ext'
5
- require 'avm/git/launcher/base'
6
6
 
7
7
  module Avm
8
8
  module Tools
@@ -14,7 +14,7 @@ module Avm
14
14
  bool_opt '-a', '--apply', 'Confirm changes.'
15
15
  bool_opt '-n', '--no-recursive', 'No recursive.'
16
16
  bool_opt '-v', '--verbose', 'Verbose'
17
- bool_opt '-d', '--git-dirty', 'Select Git dirty files to format.'
17
+ bool_opt '-d', '--dirty', 'Select modified files to format.'
18
18
  pos_arg :paths, repeat: true, optional: true
19
19
  end
20
20
 
@@ -28,17 +28,17 @@ module Avm
28
28
  ::Avm::FileFormats::SearchFormatter::OPTION_VERBOSE => parsed.verbose? }
29
29
  end
30
30
 
31
- def git
32
- @git ||= ::Avm::Git::Launcher::Base.new('.')
31
+ def scm
32
+ @scm ||= ::Avm::Registry.scms.detect('.')
33
33
  end
34
34
 
35
- def git_dirty_files
36
- git.dirty_files.map { |f| git.root_path.join(f.path) }.select(&:exist?).map(&:to_s)
35
+ def dirty_files
36
+ scm.dirty_files.map { |f| scm.root_path.join(f.path) }.select(&:exist?).map(&:to_s)
37
37
  end
38
38
 
39
39
  def source_paths
40
- if parsed.git_dirty?
41
- parsed.paths + git_dirty_files
40
+ if parsed.dirty?
41
+ parsed.paths + dirty_files
42
42
  else
43
43
  parsed.paths.if_present(%w[.])
44
44
  end
@@ -9,7 +9,7 @@ module Avm
9
9
  class Issue
10
10
  require_sub __FILE__
11
11
  runner_with :help, :subcommands do
12
- desc 'Issue operations within Git.'
12
+ desc 'Issue operations within source.'
13
13
  subcommands
14
14
  end
15
15
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.160.2'
5
+ VERSION = '0.161.0'
6
6
  end
7
7
  end
data/lib/avm/tools.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/require_sub'
4
+
3
5
  module Avm
4
6
  module Tools
5
- require 'avm/tools/version'
6
- require 'avm/tools/git'
7
+ ::EacRubyUtils.require_sub(__FILE__)
7
8
  end
8
9
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.160.2
4
+ version: 0.161.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: aranha-parsers
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.22'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.22'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: avm
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -31,75 +17,19 @@ dependencies:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0.86'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.86'
41
- - !ruby/object:Gem::Dependency
42
- name: avm-eac_ruby_base1
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.33'
48
20
  - - ">="
49
21
  - !ruby/object:Gem::Version
50
- version: 0.33.1
22
+ version: 0.86.1
51
23
  type: :runtime
52
24
  prerelease: false
53
25
  version_requirements: !ruby/object:Gem::Requirement
54
26
  requirements:
55
27
  - - "~>"
56
28
  - !ruby/object:Gem::Version
57
- version: '0.33'
29
+ version: '0.86'
58
30
  - - ">="
59
31
  - !ruby/object:Gem::Version
60
- version: 0.33.1
61
- - !ruby/object:Gem::Dependency
62
- name: avm-eac_ubuntu_base0
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0.5'
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0.5'
75
- - !ruby/object:Gem::Dependency
76
- name: avm-files
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.7'
82
- type: :runtime
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.7'
89
- - !ruby/object:Gem::Dependency
90
- name: avm-git
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '0.16'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '0.16'
32
+ version: 0.86.1
103
33
  - !ruby/object:Gem::Dependency
104
34
  name: clipboard
105
35
  requirement: !ruby/object:Gem::Requirement
@@ -120,40 +50,6 @@ dependencies:
120
50
  - - ">="
121
51
  - !ruby/object:Gem::Version
122
52
  version: 1.3.6
123
- - !ruby/object:Gem::Dependency
124
- name: curb
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '0.9'
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: 0.9.11
133
- type: :runtime
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - "~>"
138
- - !ruby/object:Gem::Version
139
- version: '0.9'
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: 0.9.11
143
- - !ruby/object:Gem::Dependency
144
- name: eac_git
145
- requirement: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '0.16'
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '0.16'
157
53
  - !ruby/object:Gem::Dependency
158
54
  name: eac_ruby_base0
159
55
  requirement: !ruby/object:Gem::Requirement
@@ -169,59 +65,19 @@ dependencies:
169
65
  - !ruby/object:Gem::Version
170
66
  version: '0.19'
171
67
  - !ruby/object:Gem::Dependency
172
- name: eac_templates
173
- requirement: !ruby/object:Gem::Requirement
174
- requirements:
175
- - - "~>"
176
- - !ruby/object:Gem::Version
177
- version: '0.5'
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: 0.5.1
181
- type: :runtime
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '0.5'
188
- - - ">="
189
- - !ruby/object:Gem::Version
190
- version: 0.5.1
191
- - !ruby/object:Gem::Dependency
192
- name: git
193
- requirement: !ruby/object:Gem::Requirement
194
- requirements:
195
- - - "~>"
196
- - !ruby/object:Gem::Version
197
- version: '1.19'
198
- - - ">="
199
- - !ruby/object:Gem::Version
200
- version: 1.19.1
201
- type: :runtime
202
- prerelease: false
203
- version_requirements: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - "~>"
206
- - !ruby/object:Gem::Version
207
- version: '1.19'
208
- - - ">="
209
- - !ruby/object:Gem::Version
210
- version: 1.19.1
211
- - !ruby/object:Gem::Dependency
212
- name: ruby-progressbar
68
+ name: avm-git
213
69
  requirement: !ruby/object:Gem::Requirement
214
70
  requirements:
215
71
  - - "~>"
216
72
  - !ruby/object:Gem::Version
217
- version: '1.13'
218
- type: :runtime
73
+ version: '0.17'
74
+ type: :development
219
75
  prerelease: false
220
76
  version_requirements: !ruby/object:Gem::Requirement
221
77
  requirements:
222
78
  - - "~>"
223
79
  - !ruby/object:Gem::Version
224
- version: '1.13'
80
+ version: '0.17'
225
81
  - !ruby/object:Gem::Dependency
226
82
  name: eac_ruby_gem_support
227
83
  requirement: !ruby/object:Gem::Requirement
@@ -264,16 +120,6 @@ files:
264
120
  - lib/avm/tools/runner/files.rb
265
121
  - lib/avm/tools/runner/files/format.rb
266
122
  - lib/avm/tools/runner/files/rotate.rb
267
- - lib/avm/tools/runner/git.rb
268
- - lib/avm/tools/runner/git/commit.rb
269
- - lib/avm/tools/runner/git/deploy.rb
270
- - lib/avm/tools/runner/git/dirty_files.rb
271
- - lib/avm/tools/runner/git/organize.rb
272
- - lib/avm/tools/runner/git/revisions_test.rb
273
- - lib/avm/tools/runner/git/subrepo.rb
274
- - lib/avm/tools/runner/git/subrepo/check.rb
275
- - lib/avm/tools/runner/git/subrepo/clone.rb
276
- - lib/avm/tools/runner/git/subrepo/fix.rb
277
123
  - lib/avm/tools/runner/instance.rb
278
124
  - lib/avm/tools/runner/instance/data.rb
279
125
  - lib/avm/tools/runner/instance/data/clear.rb
@@ -316,8 +162,6 @@ files:
316
162
  - lib/avm/tools/runner_with/instance_data_performer.rb
317
163
  - lib/avm/tools/self.rb
318
164
  - lib/avm/tools/version.rb
319
- - template/avm/self/docker_image/Dockerfile
320
- - template/avm/self/docker_image/entrypoint.sh
321
165
  homepage:
322
166
  licenses: []
323
167
  metadata: {}
@@ -1,102 +0,0 @@
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 Tools
11
- class Runner
12
- class Git
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
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/git/scms/git'
4
- require 'eac_config/node'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
-
5
- module Avm
6
- module Tools
7
- class Runner
8
- class Git
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
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/git/organize/repository'
4
- require 'eac_cli/default_runner'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
- require 'avm/git/revision_test'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
- require 'eac_git/local'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
- require 'eac_git/local'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/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 Tools
12
- class Runner
13
- class Git
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
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
-
5
- module Avm
6
- module Tools
7
- class Runner
8
- class Git
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
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/tools/core_ext'
4
- require 'avm/git/launcher/base'
5
-
6
- module Avm
7
- module Tools
8
- class Runner
9
- class Git
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
- def repository_path
18
- repository_path? ? parsed.path : '.'
19
- end
20
-
21
- def repository_path?
22
- parsed.path.present?
23
- end
24
-
25
- def git
26
- @git ||= ::Avm::Git::Launcher::Base.by_root(repository_path)
27
- end
28
-
29
- # @return [[EacGit::Local]]
30
- def git_repo
31
- git.eac_git
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- FROM ruby:2.5
2
- RUN gem install avm-tools
3
-
4
- RUN apt-get update && apt-get -y --no-install-recommends install \
5
- ca-certificates \
6
- curl
7
-
8
- RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
9
- RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture)" \
10
- && curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture).asc" \
11
- && gpg --verify /usr/local/bin/gosu.asc \
12
- && rm /usr/local/bin/gosu.asc \
13
- && chmod +x /usr/local/bin/gosu
14
- COPY entrypoint.sh /usr/local/bin/entrypoint.sh
15
- RUN chmod +x /usr/local/bin/entrypoint.sh
16
- ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
17
- CMD []
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Add local user
4
- # Either use the LOCAL_USER_ID if passed in at runtime or
5
- # fallback
6
-
7
- USER_ID=${LOCAL_USER_ID:-9001}
8
-
9
- echo "Starting with UID : $USER_ID"
10
- useradd --shell /bin/bash -u $USER_ID -o -c "" -m user
11
- export HOME=/home/user
12
- exec /usr/local/bin/gosu user avm "$@"