avm-tools 0.62.4 → 0.63.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: 38f999acefb3965e6b892798012b79d38fe80aed211c008efbb4f0e7d0d1de11
4
- data.tar.gz: 6bb113d722f19ce336368e675d3785aee55ee1f63e2e67cc3ff3b681c9de5811
3
+ metadata.gz: 855b0d8610e334378c5f061444ae6c414739fa383b9d09d64229ef8014feba53
4
+ data.tar.gz: '09008022bebd8de5a6c3104406c7b5f415f94b1c0f2d84700e92a2b29d4fa530'
5
5
  SHA512:
6
- metadata.gz: 979ca70b0e402b50b7b5a92340d1da20312937e4d9fa7df4bb1dd358e08f68f63a9e973109abb3d5568e5d7e0e4ebef672ed03dbd74d8dc1e992069e1e90bcc1
7
- data.tar.gz: 990a1f70e3317c05ac0764b4dfe0d28183eae7723f1b599cfaf2bf7ac192226f45a370f9b6ef29e9bfe367427f67fb3a57cec5764d48d4773601856a2cc9bbfa
6
+ metadata.gz: c4f2e3cb91702b6b93963c1478c38498c0774617538b75a8401ce96b00b505156aeb5d6554c595d5837c678a6f245b86352a57f86056c6599a40f5fbefae3cd7
7
+ data.tar.gz: a577468f0221af04fb6fc08a5f6ada465dc9e64228b4be577ac0b6cbdaed4cd995108ca0f88f713226cadacf4152b1243b18986f3d9212d20742b75a84e651ff
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ class ReferenceUpdate
9
+ enable_listable
10
+ lists.add_symbol :operation, :remove
11
+
12
+ common_constructor :repository, :reference, :operation
13
+
14
+ def run_operation
15
+ send("run_operation_#{operation}")
16
+ end
17
+
18
+ def to_s
19
+ "#{reference} [#{operation}]"
20
+ end
21
+
22
+ private
23
+
24
+ def reference_pathname
25
+ repository.refs_root.join(reference)
26
+ end
27
+
28
+ def run_operation_remove
29
+ reference_pathname.unlink
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module Organize
8
+ class Repository
9
+ enable_simple_cache
10
+ common_constructor :eac_git_local
11
+
12
+ def collected_references
13
+ @collected_references || []
14
+ end
15
+
16
+ def collect_subrepos
17
+ collect_references_with_pattern(
18
+ %r{\Asubrepo/},
19
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
20
+ )
21
+ collect_references_with_pattern(
22
+ %r{\Aheads/subrepo/},
23
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
24
+ )
25
+ end
26
+
27
+ def collect_originals
28
+ collect_references_with_pattern(
29
+ %r{\Aoriginal/},
30
+ ::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
31
+ )
32
+ end
33
+
34
+ def all_branches
35
+ eac_git_local.execute!
36
+ end
37
+
38
+ delegate :to_s, to: :eac_git_local
39
+
40
+ private
41
+
42
+ def all_references
43
+ ::Pathname.glob("#{refs_root}/**/*").select(&:file?)
44
+ .map { |p| p.relative_path_from(refs_root).to_path }
45
+ end
46
+
47
+ def reference_update_by_ref(reference)
48
+ collected_references.find { |ru| ru.reference == reference }
49
+ end
50
+
51
+ def collect_reference(reference, operation)
52
+ new_ru = ::Avm::Git::Organize::ReferenceUpdate.new(self, reference, operation)
53
+ reference_update_by_ref(new_ru.reference).if_present do |ru_found|
54
+ raise "Reference #{new_ru} already added (#{ru_found})"
55
+ end
56
+ @collected_references ||= []
57
+ @collected_references << new_ru
58
+ end
59
+
60
+ def collect_references_with_pattern(pattern, operation)
61
+ references_with_pattern(pattern).each do |reference|
62
+ collect_reference(reference, operation)
63
+ end
64
+ end
65
+
66
+ def references_with_pattern(pattern)
67
+ all_references.select { |reference| pattern.if_match(reference, false) }
68
+ end
69
+
70
+ def refs_root_uncached
71
+ eac_git_local.root_path / '.git' / 'refs'
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/configuration'
3
4
  require 'eac_ruby_gems_utils/gem'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/organize/repository'
4
+ require 'eac_cli/default_runner'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Git < ::EacRubyUtils::Console::DocoptRunner
11
+ class Organize < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacCli::DefaultRunner
13
+
14
+ runner_definition do
15
+ desc 'Organize branches.'
16
+ bool_opt '-a', '--all', 'Run all organizations.'
17
+ bool_opt '-n', '--no', 'Do not run operations.'
18
+ bool_opt '-o', '--originals', 'Remove refs/original branches.'
19
+ bool_opt '-s', '--subrepos', 'Remove git-subrepo branches.'
20
+ bool_opt '-y', '--yes', 'Run operations without confirmation.'
21
+ end
22
+
23
+ def run
24
+ start_banner
25
+ collect_references
26
+ after_collect_banner
27
+ run_operations
28
+ end
29
+
30
+ private
31
+
32
+ def after_collect_banner
33
+ infov 'Collected references', repository.collected_references.count
34
+ repository.collected_references.each do |ru|
35
+ infov " * #{ru.reference}", ru.operation
36
+ end
37
+ end
38
+
39
+ def collect?(type)
40
+ options.fetch("--#{type}") || options.fetch('--all')
41
+ end
42
+
43
+ def collect_references
44
+ %w[subrepos originals].each do |type|
45
+ repository.send("collect_#{type}") if collect?(type)
46
+ end
47
+ end
48
+
49
+ def run_operations
50
+ return warn('No operations to run (Run with --help to see options)') if
51
+ repository.collected_references.empty?
52
+ return unless run_operations?
53
+
54
+ repository.collected_references.each do |ru|
55
+ info "Doing operation #{ru}..."
56
+ ru.run_operation
57
+ end
58
+ end
59
+
60
+ def run_operations?
61
+ return true if options.fetch('--yes')
62
+ return false if options.fetch('--no')
63
+
64
+ request_input('Confirm operations?', bool: true)
65
+ end
66
+
67
+ def repository_uncached
68
+ ::Avm::Git::Organize::Repository.new(context(:git).eac_git)
69
+ end
70
+
71
+ def start_banner
72
+ infov 'Repository', repository
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.62.4'
5
+ VERSION = '0.63.0'
6
6
  end
7
7
  end
@@ -48,6 +48,10 @@ module EacGit
48
48
  ::EacGit::Local::Subrepo.new(self, subpath)
49
49
  end
50
50
 
51
+ def to_s
52
+ "#{self.class}[#{root_path}]"
53
+ end
54
+
51
55
  private
52
56
 
53
57
  def merge_base_pair(commit1, commit2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.62.4
4
+ version: 0.63.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: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -336,6 +336,9 @@ files:
336
336
  - lib/avm/git/issue/complete/_validations.rb
337
337
  - lib/avm/git/issue/complete/_working_tree.rb
338
338
  - lib/avm/git/issue/complete/validation.rb
339
+ - lib/avm/git/organize.rb
340
+ - lib/avm/git/organize/reference_update.rb
341
+ - lib/avm/git/organize/repository.rb
339
342
  - lib/avm/git/revision_test.rb
340
343
  - lib/avm/git/spec_helper.rb
341
344
  - lib/avm/git/subrepo_check.rb
@@ -475,6 +478,7 @@ files:
475
478
  - lib/avm/tools/runner/git/deploy.rb
476
479
  - lib/avm/tools/runner/git/dirty_files.rb
477
480
  - lib/avm/tools/runner/git/issue.rb
481
+ - lib/avm/tools/runner/git/organize.rb
478
482
  - lib/avm/tools/runner/git/revisions_test.rb
479
483
  - lib/avm/tools/runner/git/subrepo.rb
480
484
  - lib/avm/tools/runner/git/subrepo/check.rb