avm 0.58.0 → 0.59.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: a50b6491d183f2df1d7423338b915f2017ec2bf147e6857806c27cdde72ef10d
4
- data.tar.gz: 225020d14af638e08b723a00482794790715165b7cbe092e0833e301ba182993
3
+ metadata.gz: 2e515ae3c2a7c5ce6fa8d620589e359aeb2568edd75b554932adb0a666f0ff8f
4
+ data.tar.gz: 0ca8ac3456a4f99106d7e91d9429936365707b9ff68e20c0f8f36ba19074fc39
5
5
  SHA512:
6
- metadata.gz: e006a7a7a9be79a45abed6317db5de8c6097bd1f5269ec444dc43ad49852713e892c10685e1043f3eb93cfb40a0207739f025c16a758c47a3c3546a48014cc2e
7
- data.tar.gz: 28d138623589418cb34db4ba74d7f0e1b1ecf87695ab5e49e2c62c0420c5631e2b09525952815d1a0b6c837367b1b4ce9123f1d42833ab08f1822aec5a5e2ba2
6
+ metadata.gz: c3afecc85ab9c116a136758af1a0e8dbf889665eb09a6348f6be0c0e62da42bbd1073c64c19b4c3cece99bc57aae1d40faf645810c2f00fa9d2b9256ffc9d815
7
+ data.tar.gz: 9771384b7caf46ad06478e2dc6d3d6a1a1f525baf66fdef65fb4e49e22fa4be258bc786372208e9ed8b572bb978c33ad11b9a8f8ae605522c0dbc1deab194213
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ class FileResourceName
9
+ module Ruby
10
+ RUBY_CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z},
11
+ %r{app/[^/]+/(.+)\.rb\z}].freeze
12
+
13
+ def ruby_class_name
14
+ RUBY_CLASS_NAME_PATTERNS.each do |pattern|
15
+ pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
16
+ end
17
+ nil
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ class FileResourceName
9
+ require_sub __FILE__, include_modules: true
10
+ common_constructor :source_root, :path do
11
+ self.source_root = source_root.to_pathname
12
+ self.path = path.to_pathname
13
+ end
14
+
15
+ def class_name
16
+ ruby_class_name || relative_path.to_path
17
+ end
18
+
19
+ def commit_message
20
+ r = class_name
21
+ r += ': remove' unless path.file?
22
+ r + '.'
23
+ end
24
+
25
+ def relative_path
26
+ path.expand_path.relative_path_from(source_root.expand_path)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/commit_info'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Scms
8
+ module AutoCommit
9
+ class ForFile
10
+ enable_speaker
11
+ enable_simple_cache
12
+ enable_listable
13
+
14
+ common_constructor :scm, :path, :rules do
15
+ self.path = path.to_pathname.expand_path(scm.path)
16
+ end
17
+
18
+ COMMITS_SEARCH_INTERVAL = 'origin/master..HEAD'
19
+
20
+ def scm_relative_path
21
+ path.to_pathname.relative_path_from(scm.path)
22
+ end
23
+
24
+ def run
25
+ start_banner
26
+ run_commit || warn("No rule returned commit information for \"#{path}\"")
27
+ end
28
+
29
+ private
30
+
31
+ def commit_info_uncached
32
+ rules.lazy.map { |rule| rule.with_file(self).commit_info }.find(&:present?)
33
+ .if_present { |v| v.path(path) }
34
+ end
35
+
36
+ def start_banner
37
+ infov 'Path', path
38
+ infov ' Commits found', commits.count
39
+ end
40
+
41
+ def run_commit
42
+ return false if commit_info.blank?
43
+
44
+ infov ' Commit info', commit_info
45
+ scm.run_commit(commit_info)
46
+ success ' Commited'
47
+ true
48
+ end
49
+
50
+ def commits_uncached
51
+ scm.current_milestone_interval.commits
52
+ .select { |c| c.changed_files.include?(path.relative_path_from(scm.path)) }
53
+ .reject(&:fixup?).each_with_index
54
+ .map { |commit, index| CommitDelegator.new(commit, index) }
55
+ end
56
+
57
+ class CommitDelegator < ::SimpleDelegator
58
+ attr_reader :index
59
+
60
+ def initialize(commit, index)
61
+ super(commit)
62
+ @index = index
63
+ end
64
+
65
+ def position
66
+ index + 1
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/commit_info'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Scms
8
+ module AutoCommit
9
+ module Rules
10
+ class Base
11
+ class << self
12
+ def keys
13
+ [long_key, short_key]
14
+ end
15
+
16
+ def long_key
17
+ name.demodulize.variableize
18
+ end
19
+
20
+ def short_key
21
+ long_key[0, 1]
22
+ end
23
+ end
24
+
25
+ def with_file(file)
26
+ self.class.const_get('WithFile').new(self, file)
27
+ end
28
+
29
+ class WithFile
30
+ common_constructor :rule, :file
31
+
32
+ def new_commit_info
33
+ ::Avm::Scms::CommitInfo.new
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ module Rules
9
+ class Last < ::Avm::Scms::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Scms::AutoCommit::Rules::Base::WithFile
11
+ def commit_info
12
+ file.commits.last.if_present { |v| new_commit_info.fixup(v) }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ module Rules
9
+ class Manual < ::Avm::Scms::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Scms::AutoCommit::Rules::Base::WithFile
11
+ enable_speaker
12
+
13
+ SKIP_OPTION = 's'
14
+
15
+ def commit_info
16
+ return nil unless file.commits.any?
17
+
18
+ commits_banner
19
+ input('Which commit?', list: commits_by_position).if_present do |v|
20
+ new_commit_info.fixup(v)
21
+ end
22
+ end
23
+
24
+ def commits_banner
25
+ file.commits.each_with_index do |commit, _index|
26
+ infov " #{commit.position}", commit
27
+ end
28
+ infov " #{SKIP_OPTION}", 'skip'
29
+ end
30
+
31
+ def commits_by_position
32
+ (file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]])
33
+ .to_h
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/auto_commit/rules/base'
4
+ require 'avm/scms/auto_commit/file_resource_name'
5
+
6
+ module Avm
7
+ module Scms
8
+ module AutoCommit
9
+ module Rules
10
+ class New < ::Avm::Scms::AutoCommit::Rules::Base
11
+ class WithFile < ::Avm::Scms::AutoCommit::Rules::Base::WithFile
12
+ def auto_commit_path
13
+ ::Avm::Scms::AutoCommit::FileResourceName.new(file.scm.path, file.path)
14
+ end
15
+
16
+ def commit_info
17
+ new_commit_info.message(auto_commit_path.commit_message)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ module Rules
9
+ class Nth < ::Avm::Scms::AutoCommit::Rules::Base
10
+ SHORT_KEY = 't'
11
+
12
+ class << self
13
+ def short_key
14
+ SHORT_KEY
15
+ end
16
+ end
17
+
18
+ common_constructor :number do
19
+ self.number = number.to_i
20
+ end
21
+
22
+ class WithFile < ::Avm::Scms::AutoCommit::Rules::Base::WithFile
23
+ def commit_info
24
+ file.commits(number - 1).if_present { |v| new_commit_info.fixup(v) }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ module Rules
9
+ class Unique < ::Avm::Scms::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Scms::AutoCommit::Rules::Base::WithFile
11
+ def commit_info
12
+ return nil unless file.commits.count == 1
13
+
14
+ new_commit_info.fixup(file.commits.first)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ ::EacRubyUtils.require_sub __FILE__
6
+
7
+ module Avm
8
+ module Scms
9
+ module AutoCommit
10
+ module Rules
11
+ RULES_CLASSES = %w[last manual new nth unique]
12
+ .map { |key| ::Avm::Scms::AutoCommit::Rules.const_get(key.camelcase) }
13
+
14
+ class << self
15
+ # @return [Array<Avm::Scms::AutoCommit::Rules>]
16
+ def all
17
+ RULES_CLASSES
18
+ end
19
+
20
+ def parse(string)
21
+ parts = string.split(':')
22
+
23
+ klass = rule_class_by_key(parts.shift)
24
+ klass.new(*parts)
25
+ end
26
+
27
+ def rule_class_by_key(key)
28
+ RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
29
+ raise("Rule not find with key \"#{key}\" (Available: " +
30
+ RULES_CLASSES.flat_map(&:keys).join(', ') + ')')
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ module AutoCommit
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ class Base
8
+ module Commits
9
+ # @return [Avm::Scms::Commit,NilClass]
10
+ def commit_if_change(_message = nil)
11
+ raise_abstract_method __method__
12
+ end
13
+
14
+ # @return [Avm::Scms::Commit]
15
+ def head_commit
16
+ raise_abstract_method __method__
17
+ end
18
+
19
+ # @param commit_info [Avm::Scms::CommitInfo]
20
+ # @return [Avm::Scms::Commit]
21
+ def run_commit(_commit_info)
22
+ raise_abstract_method __method__
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ class Base
8
+ module Milestones
9
+ # @return [Avm::Scms::Interval]
10
+ def current_milestone_interval
11
+ interval(current_milestone_base_commit, head_commit)
12
+ end
13
+
14
+ # @return [Avm::Scms::Commit]
15
+ def current_milestone_base_commit
16
+ raise_abstract_method __method__
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/avm/scms/base.rb CHANGED
@@ -6,6 +6,7 @@ require 'eac_ruby_utils/core_ext'
6
6
  module Avm
7
7
  module Scms
8
8
  class Base
9
+ require_sub __FILE__, include_modules: true
9
10
  enable_abstract_methods
10
11
  enable_simple_cache
11
12
  include ::Avm::With::ApplicationStereotype
@@ -14,8 +15,13 @@ module Avm
14
15
  self.path = path.to_pathname
15
16
  end
16
17
 
17
- # @return [Avm::Scms::Commit,NilClass]
18
- def commit_if_change(_message = nil)
18
+ # @return [Avm::Scms::ChangedFile]
19
+ def changed_files
20
+ raise_abstract_method __method__
21
+ end
22
+
23
+ # @return [Avm::Scms::Interval]
24
+ def interval(_from, _to)
19
25
  raise_abstract_method __method__
20
26
  end
21
27
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ class ChangedFile
8
+ enable_abstract_methods
9
+
10
+ # @return [Pathname]
11
+ def absolute_path
12
+ path.expand_path(scm.path)
13
+ end
14
+
15
+ # @return [Pathname]
16
+ def path
17
+ raise_abstract_method __method__
18
+ end
19
+
20
+ # @return [Avm::Scms::Base]
21
+ def scm
22
+ raise_abstract_method __method__
23
+ end
24
+ end
25
+ end
26
+ end
@@ -16,6 +16,11 @@ module Avm
16
16
  raise_abstract_method __method__
17
17
  end
18
18
 
19
+ # @return [Boolean]
20
+ def fixup?
21
+ raise_abstract_method __method__
22
+ end
23
+
19
24
  def id
20
25
  raise_abstract_method __method__
21
26
  end
@@ -46,6 +51,16 @@ module Avm
46
51
  def scm_file?(_path)
47
52
  raise_abstract_method __method__
48
53
  end
54
+
55
+ # @return [String]
56
+ def subject
57
+ raise_abstract_method __method__
58
+ end
59
+
60
+ # @return [String]
61
+ def to_s
62
+ "#{subject} [#{id}]"
63
+ end
49
64
  end
50
65
  end
51
66
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ class CommitInfo
8
+ enable_immutable
9
+
10
+ immutable_accessor :fixup, :message
11
+ immutable_accessor :path, type: :array
12
+
13
+ def to_s
14
+ self.class.name.demodulize + '[' +
15
+ %w[fixup message].map { |m| [m, send(m)] }.reject { |m| m[1].blank? }
16
+ .map { |m| m.join(': ') }.join(',') + ']'
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ class Interval
8
+ enable_abstract_methods
9
+
10
+ common_constructor :scm, :from, :to
11
+
12
+ # @return [Array<Avm::Scms::Commit>]
13
+ def commits
14
+ raise_abstract_method __method__
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/avm/scms.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Scms
7
+ require_sub __FILE__
8
+ end
9
+ end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.58.0'
4
+ VERSION = '0.59.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.58.0
4
+ version: 0.59.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-24 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -106,20 +106,20 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.109'
109
+ version: '0.110'
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 0.109.1
112
+ version: 0.110.1
113
113
  type: :runtime
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0.109'
119
+ version: '0.110'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 0.109.1
122
+ version: 0.110.1
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: eac_templates
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -375,9 +375,26 @@ files:
375
375
  - lib/avm/rspec/shared_examples/in_avm_registry.rb
376
376
  - lib/avm/rspec/shared_examples/not_in_avm_registry.rb
377
377
  - lib/avm/runners/base.rb
378
+ - lib/avm/scms.rb
379
+ - lib/avm/scms/auto_commit.rb
380
+ - lib/avm/scms/auto_commit/file_resource_name.rb
381
+ - lib/avm/scms/auto_commit/file_resource_name/ruby.rb
382
+ - lib/avm/scms/auto_commit/for_file.rb
383
+ - lib/avm/scms/auto_commit/rules.rb
384
+ - lib/avm/scms/auto_commit/rules/base.rb
385
+ - lib/avm/scms/auto_commit/rules/last.rb
386
+ - lib/avm/scms/auto_commit/rules/manual.rb
387
+ - lib/avm/scms/auto_commit/rules/new.rb
388
+ - lib/avm/scms/auto_commit/rules/nth.rb
389
+ - lib/avm/scms/auto_commit/rules/unique.rb
378
390
  - lib/avm/scms/base.rb
391
+ - lib/avm/scms/base/commits.rb
392
+ - lib/avm/scms/base/milestones.rb
393
+ - lib/avm/scms/changed_file.rb
379
394
  - lib/avm/scms/commit.rb
395
+ - lib/avm/scms/commit_info.rb
380
396
  - lib/avm/scms/inflector.rb
397
+ - lib/avm/scms/interval.rb
381
398
  - lib/avm/scms/null.rb
382
399
  - lib/avm/self/docker_image.rb
383
400
  - lib/avm/self/instance.rb