avm-tools 0.33.1 → 0.34.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f708f3072f93556dae56f82d2453331feabdb25b0862ece5db75fb69f62f0e8
4
- data.tar.gz: 6121ec8f21d98b1fa4f89e1f519455be06cf4f93446960336dfe86eac6de609c
3
+ metadata.gz: bc93a50b713fa65d2893cb05c7a38feab44295c625011c6597d5aeaaf866ccf9
4
+ data.tar.gz: 67ab9170e9c7e780bf839d0bdb1d5ebe4edb91e2d46b08af22a46c5bfb2c93c6
5
5
  SHA512:
6
- metadata.gz: 10c43268cb9404bee7d99afbaea5d0131ea2081b293d4b11df7a5837174e87095255cbfbb18a9359df316d5105c4479b675c055259a0b7d5e673a2c21b7262ec
7
- data.tar.gz: 53ef9178434c46af701bb101ee1979f54bf5b8f2de208a6dce4df33adb46345e2d8bc8f2e8c7b62b7f58b6504836a1ed928b549380f09186d782bb66c9ec5b85
6
+ metadata.gz: d6f5008949bde37c4f319aea45a7676b7acc314408154fabe3ace835206dd44f988cd6593e6b571291898bc659fcd013f3d43e49807f9046233f5c028f4894d6
7
+ data.tar.gz: d9db915b89d71139af123feab08e08e3a4743a866d3895c9fbedb5b61def92e64d0509c9e7bb7fffbc56f76fdf7239087ef26810d7b80cd6155513d25ea75a82
@@ -14,11 +14,12 @@ module Avm
14
14
  include ::EacRubyUtils::SimpleCache
15
15
  include ::EacRubyUtils::Console::Speaker
16
16
 
17
- attr_reader :no_validate_branch
17
+ attr_reader :skip_validations
18
18
 
19
19
  def initialize(options)
20
20
  consumer = ::EacRubyUtils::OptionsConsumer.new(options)
21
- dir, @no_validate_branch = consumer.consume_all(:dir, :no_validate_branch)
21
+ dir, @skip_validations = consumer.consume_all(:dir, :skip_validations)
22
+ validate_skip_validations
22
23
  consumer.validate
23
24
  @git = ::EacLauncher::Git::Base.new(dir)
24
25
  end
@@ -19,10 +19,7 @@ module Avm
19
19
  end
20
20
 
21
21
  def branch_name_result
22
- ::Avm::Result.success_or_error(
23
- branch_name,
24
- issue_id || no_validate_branch
25
- )
22
+ ::Avm::Result.success_or_error(branch_name, issue_id.present?)
26
23
  end
27
24
 
28
25
  def branch_hash_result
@@ -1,34 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/result'
4
+ require 'ostruct'
4
5
 
5
6
  module Avm
6
7
  module Git
7
8
  module Issue
8
9
  class Complete
9
10
  VALIDATIONS = {
11
+ clean_workspace: 'Clean workspace?',
10
12
  branch_name: 'Branch name',
11
13
  branch_hash: 'Branch hash',
12
14
  follow_master: 'Follow master?',
13
15
  commits: 'Commits?',
14
16
  bifurcations: 'Bifurcations?',
15
17
  dry_push: 'Dry push?'
16
- }.freeze
18
+ }.with_indifferent_access.freeze
17
19
 
18
20
  def valid?
19
- validations.values.none?(&:error?)
21
+ validations.map(&:result).none?(&:error?)
20
22
  end
21
23
 
22
24
  def validations_banner
23
- validations.each do |label, result|
24
- infov label, result.label
25
+ validations.each do |v|
26
+ infov "[#{v.key}] #{v.label}", v.result.label
25
27
  end
26
28
  end
27
29
 
28
30
  def validations
29
31
  VALIDATIONS.map do |key, label|
30
- [label, send("#{key}_result")]
31
- end.to_h
32
+ ::OpenStruct.new(key: key, label: label, result: validation_result(key))
33
+ end
34
+ end
35
+
36
+ def validation_result(key)
37
+ if skip_validations.include?(key)
38
+ ::Avm::Result.neutral('skipped')
39
+ else
40
+ send("#{key}_result")
41
+ end
42
+ end
43
+
44
+ def validate_skip_validations
45
+ skip_validations.each do |validation|
46
+ next if VALIDATIONS.keys.include?(validation)
47
+
48
+ raise "\"#{validation}\" is not a registered validation"
49
+ end
32
50
  end
33
51
  end
34
52
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Git
5
+ module Issue
6
+ class Complete
7
+ def clean_workspace_result
8
+ r = @git.dirty_files.none?
9
+ ::Avm::Result.success_or_error(r ? 'yes' : 'no', r)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -20,9 +20,13 @@ module Avm
20
20
  __PROGRAM__ -h | --help
21
21
 
22
22
  Options:
23
- -h --help Show this screen.
24
- -B --no-validate-branch Does not validate branch/tag name.
25
- -y --yes Does not ask for user confirmation.
23
+ -h --help Show this screen.
24
+ -s --skip-validations=<validations> Does not validate conditions on <validations>
25
+ (Comma separated value).
26
+ -y --yes Does not ask for user confirmation.
27
+
28
+ Validations:
29
+ %%VALIDATIONS%%
26
30
  DOCOPT
27
31
 
28
32
  def run
@@ -32,15 +36,26 @@ module Avm
32
36
  complete.run if confirm?
33
37
  end
34
38
 
39
+ def doc
40
+ DOC.gsub('%%VALIDATIONS%%', doc_validations_list)
41
+ end
42
+
35
43
  private
36
44
 
37
45
  def confirm?
38
46
  options.fetch('--yes') || request_input('Confirm issue completion?', bool: true)
39
47
  end
40
48
 
49
+ def skip_validations
50
+ options.fetch('--skip-validations').to_s.split(',').map(&:strip).reject(&:blank?)
51
+ end
52
+
41
53
  def git_complete_issue_options
42
- { dir: context(:repository_path),
43
- no_validate_branch: options.fetch('--no-validate-branch') }
54
+ { dir: context(:repository_path), skip_validations: skip_validations }
55
+ end
56
+
57
+ def doc_validations_list
58
+ ::Avm::Git::Issue::Complete::VALIDATIONS.keys.map { |k| " * #{k}" }.join("\n")
44
59
  end
45
60
  end
46
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.33.1'
5
+ VERSION = '0.34.0'
6
6
  end
7
7
  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.33.1
4
+ version: 0.34.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-02-22 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -210,6 +210,7 @@ files:
210
210
  - lib/avm/git/issue/complete/_remote.rb
211
211
  - lib/avm/git/issue/complete/_tracker.rb
212
212
  - lib/avm/git/issue/complete/_validations.rb
213
+ - lib/avm/git/issue/complete/_working_tree.rb
213
214
  - lib/avm/git/revision_test.rb
214
215
  - lib/avm/git/spec_helper.rb
215
216
  - lib/avm/instances.rb