avmtrf1-tools 0.32.1 → 0.33.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avmtrf1/active_directory/user.rb +3 -3
  3. data/lib/avmtrf1/core_ext.rb +4 -0
  4. data/lib/avmtrf1/default_jira.rb +2 -2
  5. data/lib/avmtrf1/git/cached_repository.rb +2 -2
  6. data/lib/avmtrf1/git/issue_on_repository.rb +2 -2
  7. data/lib/avmtrf1/git/push_large.rb +4 -4
  8. data/lib/avmtrf1/git/push_large/lfs_commit.rb +5 -10
  9. data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +19 -0
  10. data/lib/avmtrf1/git/push_large/lfs_commit/checkout_previous_revision.rb +35 -0
  11. data/lib/avmtrf1/git/push_large/lfs_commit/commit_changes.rb +48 -0
  12. data/lib/avmtrf1/git/push_large/lfs_commit/helpers.rb +29 -0
  13. data/lib/avmtrf1/git/push_large/lfs_commit/pick_source_revision.rb +103 -0
  14. data/lib/avmtrf1/git/push_large/lfs_commit/push.rb +90 -0
  15. data/lib/avmtrf1/git/push_large/lfs_commit/track_large_files.rb +53 -0
  16. data/lib/avmtrf1/git/push_large/source_commit.rb +4 -7
  17. data/lib/avmtrf1/git/push_large/source_commit/push.rb +42 -0
  18. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +1 -1
  19. data/lib/avmtrf1/openvpn/config/builder.rb +59 -0
  20. data/lib/avmtrf1/openvpn/config/parser.rb +20 -0
  21. data/lib/avmtrf1/openvpn/config/parser/builder.rb +62 -0
  22. data/lib/avmtrf1/openvpn/config/parser/line.rb +47 -0
  23. data/lib/avmtrf1/openvpn/config/parser/simple.rb +27 -0
  24. data/lib/avmtrf1/openvpn/config/parser/tag.rb +39 -0
  25. data/lib/avmtrf1/patches.rb +3 -0
  26. data/lib/avmtrf1/patches/avm.rb +4 -0
  27. data/lib/avmtrf1/patches/avm/git.rb +4 -0
  28. data/lib/avmtrf1/patches/avm/git/issue.rb +4 -0
  29. data/lib/avmtrf1/patches/avm/launcher.rb +4 -0
  30. data/lib/avmtrf1/patches/avm/launcher/git.rb +4 -0
  31. data/lib/avmtrf1/patches/avm/launcher/git/base.rb +46 -0
  32. data/lib/avmtrf1/red/helper.rb +2 -2
  33. data/lib/avmtrf1/template.rb +2 -2
  34. data/lib/avmtrf1/tools/runner.rb +5 -2
  35. data/lib/avmtrf1/tools/runner/check_point.rb +7 -13
  36. data/lib/avmtrf1/tools/runner/check_point/login.rb +6 -19
  37. data/lib/avmtrf1/tools/runner/esosti.rb +8 -20
  38. data/lib/avmtrf1/tools/runner/esosti/changed.rb +9 -22
  39. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +9 -22
  40. data/lib/avmtrf1/tools/runner/esosti/request.rb +17 -29
  41. data/lib/avmtrf1/tools/runner/forponto.rb +13 -23
  42. data/lib/avmtrf1/tools/runner/forponto/espelho.rb +11 -21
  43. data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +7 -18
  44. data/lib/avmtrf1/tools/runner/forponto/resumos.rb +7 -19
  45. data/lib/avmtrf1/tools/runner/forponto/saldo.rb +10 -21
  46. data/lib/avmtrf1/tools/runner/git.rb +2 -4
  47. data/lib/avmtrf1/tools/runner/git/issues_check.rb +7 -18
  48. data/lib/avmtrf1/tools/runner/git/push_large.rb +27 -18
  49. data/lib/avmtrf1/tools/runner/openvpn.rb +57 -4
  50. data/lib/avmtrf1/tools/runner/oracle.rb +15 -22
  51. data/lib/avmtrf1/tools/runner/oracle/query.rb +9 -13
  52. data/lib/avmtrf1/tools/runner/oracle/source_get.rb +17 -18
  53. data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +7 -15
  54. data/lib/avmtrf1/tools/runner/php/docker.rb +5 -5
  55. data/lib/avmtrf1/tools/runner/red.rb +21 -25
  56. data/lib/avmtrf1/tools/runner/trf1_dspace_base0.rb +9 -18
  57. data/lib/avmtrf1/tools/runner/trf1_dspace_base0/deploy.rb +1 -1
  58. data/lib/avmtrf1/tools/version.rb +1 -1
  59. metadata +26 -97
  60. data/lib/avmtrf1/configs.rb +0 -24
  61. data/lib/avmtrf1/git/push_large/lfs_commit/_00_checkout_previous_revision.rb +0 -33
  62. data/lib/avmtrf1/git/push_large/lfs_commit/_01_cherry_pick_source_revision.rb +0 -89
  63. data/lib/avmtrf1/git/push_large/lfs_commit/_02_track_large_files.rb +0 -51
  64. data/lib/avmtrf1/git/push_large/lfs_commit/_03_commit_changes.rb +0 -46
  65. data/lib/avmtrf1/git/push_large/lfs_commit/_04_push.rb +0 -88
  66. data/lib/avmtrf1/git/push_large/lfs_commit/_cache.rb +0 -17
  67. data/lib/avmtrf1/git/push_large/lfs_commit/_helpers.rb +0 -27
  68. data/lib/avmtrf1/git/push_large/source_commit/_push.rb +0 -40
  69. data/lib/avmtrf1/patches/eac_launcher/git/base.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: defb31ef2f0bf05b7d4b7494fe52de69ebd8c185960b424a9e45a47940dd6dda
4
- data.tar.gz: 26106fc3e212633ee736cf5a3eddff3c7b88d7ff4f2ffc4e01e4b8a1ac6fcac6
3
+ metadata.gz: 55b03fc11cc828e37128763a828a3821861c3e16f97fbde31974c167be47749b
4
+ data.tar.gz: 8bddf62bd92b51245ceca1a5ae64ad26d80002e13e68c4a1ee3701ec4fa74bbf
5
5
  SHA512:
6
- metadata.gz: e86b04b4630700d28300c943e34d85ec3df34ebbcf1f044412ae451ce82b53e9934f035509dd9a937b9668fd67aa4b7b96b76d4cba3a189deceb78d651d849e5
7
- data.tar.gz: baa89a45439b8a116fb77df244a16eaf8e73146a2733f95f073db3e5a30d389ad7bbc8717c2ce8614983c51eecae121672fd6877cba91d3dd2ae8c042f00f694
6
+ metadata.gz: 1c85df1801f0a65cd4a663b379a4f2a6ae026fa85cf18cab13239f0ac8bbfee5bca6c789c661b681238a16acaa72f51982e797b58e13f1622d082d8252b9e89e
7
+ data.tar.gz: 564e6cc7069fb91ec8bcf3f5f6901a8e7baa13baad7f1102e12e09dd785af93d646e415dc5dac5f87dc49de38cc09f4bdc0dc089900804472dfaea8ff45c9866
@@ -6,9 +6,9 @@ module Avmtrf1
6
6
  class << self
7
7
  def by_configs(path_prefix)
8
8
  new(
9
- ::Avmtrf1.configs.read_entry("#{path_prefix}.domain"),
10
- ::Avmtrf1.configs.read_entry("#{path_prefix}.username"),
11
- ::Avmtrf1.configs.read_password("#{path_prefix}.password")
9
+ ::Avm::Apps::Config.current.entry("#{path_prefix}.domain").value,
10
+ ::Avm::Apps::Config.current.entry("#{path_prefix}.username").value,
11
+ ::Avm::Apps::Config.current.entry("#{path_prefix}.password", noecho: true).value
12
12
  )
13
13
  end
14
14
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/tools/core_ext'
4
+ require 'avmtrf1/patches'
@@ -9,8 +9,8 @@ module Avmtrf1
9
9
  def default_jira
10
10
  @default_jira ||= ::Avmtrf1::Jira::Instance.new(
11
11
  'https://jira.engesoftware.com.br',
12
- ::Avmtrf1.configs.read_entry("#{DEFAULT_JIRA_PATH_PREFIX}.username"),
13
- ::Avmtrf1.configs.read_password("#{DEFAULT_JIRA_PATH_PREFIX}.password")
12
+ ::Avm::Apps::Config.current.entry("#{DEFAULT_JIRA_PATH_PREFIX}.username").value,
13
+ ::Avm::Apps::Config.current.entry("#{DEFAULT_JIRA_PATH_PREFIX}.password", noecho: true).value
14
14
  )
15
15
  end
16
16
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher/git/base'
3
+ require 'avm/launcher/git/base'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
7
- class CachedRepository < ::EacLauncher::Git::Base
7
+ class CachedRepository < ::Avm::Launcher::Git::Base
8
8
  attr_reader :url
9
9
 
10
10
  def initialize(url)
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/speaker'
3
+ require 'eac_ruby_utils/patches/module/speaker'
4
4
  require 'eac_ruby_utils/simple_cache'
5
5
  require 'avmtrf1/result'
6
6
 
7
7
  module Avmtrf1
8
8
  module Git
9
9
  class IssueOnRepository
10
- include ::EacRubyUtils::Console::Speaker
10
+ enable_speaker
11
11
  include ::EacRubyUtils::SimpleCache
12
12
 
13
13
  CHECKS = %w[no_branch_nor_tag branch_and_tag issue_not_found issue_closed_git_open
@@ -2,23 +2,23 @@
2
2
 
3
3
  require 'ostruct'
4
4
 
5
- require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_ruby_utils/patches/module/speaker'
6
6
  require 'eac_ruby_utils/require_sub'
7
7
  require 'eac_ruby_utils/simple_cache'
8
- require 'avmtrf1/patches/eac_launcher/git/base'
8
+ require 'avmtrf1/patches/avm/launcher/git/base'
9
9
 
10
10
  module Avmtrf1
11
11
  module Git
12
12
  class PushLarge
13
13
  include ::EacRubyUtils::SimpleCache
14
- include ::EacRubyUtils::Console::Speaker
14
+ enable_speaker
15
15
 
16
16
  ::EacRubyUtils.require_sub(__FILE__)
17
17
 
18
18
  attr_reader :git, :remote_name, :source_ref, :target_ref, :last_pushed_revision
19
19
 
20
20
  def initialize(git_local_path, remote_name, source_ref, target_ref)
21
- @git = ::EacLauncher::Git::Base.new(git_local_path)
21
+ @git = ::Avm::Launcher::Git::Base.new(git_local_path)
22
22
  @remote_name = remote_name
23
23
  @source_ref = source_ref
24
24
  @target_ref = target_ref
@@ -1,21 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/require_sub'
3
+ require 'avmtrf1/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
7
7
  class PushLarge
8
8
  class LfsCommit
9
- include ::EacRubyUtils::Console::Speaker
10
- include ::EacRubyUtils::SimpleCache
9
+ require_sub __FILE__, include_modules: true
10
+ enable_simple_cache
11
+ enable_speaker
11
12
 
12
- ::EacRubyUtils.require_sub(__FILE__)
13
-
14
- attr_reader :source_commit, :lfs_file_min_size, :tracked_files
15
-
16
- def initialize(source_commit, lfs_file_min_size)
17
- @source_commit = source_commit
18
- @lfs_file_min_size = lfs_file_min_size
13
+ common_constructor :source_commit, :lfs_file_min_size do
19
14
  @tracked_files = 0
20
15
  @commit = nil
21
16
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module Cache
8
+ def fs_cache_uncached
9
+ source_commit.fs_cache.child(lfs_file_min_size.present? ? lfs_file_min_size : 'nil')
10
+ end
11
+
12
+ %w[sha1 files_size push_pack_error].each do |attr|
13
+ define_method("#{attr}_cache_uncached") { fs_cache.child(attr) }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module CheckoutPreviousRevision
8
+ private
9
+
10
+ def checkout_base_uncached
11
+ if previous_revision.blank?
12
+ checkout_orphan
13
+ else
14
+ checkout_previous_revision
15
+ end
16
+ end
17
+
18
+ def checkout_orphan
19
+ infom message('Checkout orphan')
20
+ git.execute!('reset', '--hard')
21
+ git.execute!('clean', '-df')
22
+ git.execute!('checkout', source_commit.sha1)
23
+ end
24
+
25
+ def checkout_previous_revision
26
+ infom message("Checkout previous revision #{previous_revision}")
27
+ git.execute!('reset', '--hard')
28
+ git.execute!('clean', '-df')
29
+ git.execute!('checkout', previous_revision)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module CommitChanges
8
+ # @return [Avm::Git::Commit]
9
+ def commit
10
+ commit_changes
11
+ @commit
12
+ end
13
+
14
+ private
15
+
16
+ def commit_changes_uncached
17
+ if sha1_cache.read.present?
18
+ @commit = ::Avm::Git::Commit.new(git, sha1_cache.read)
19
+ return
20
+ end
21
+ track_large_files
22
+ add_files
23
+ commit_amend
24
+ store_commit
25
+ end
26
+
27
+ def add_files
28
+ infom ' * Adding files'
29
+ git.system!('add', '.')
30
+ end
31
+
32
+ def commit_amend
33
+ infom message('Commiting')
34
+ git.command('commit', '--amend', '--allow-empty', '--allow-empty-message')
35
+ .envvar('GIT_EDITOR', true).execute!
36
+ end
37
+
38
+ def store_commit
39
+ @commit = ::Avm::Git::Commit.new(git, git.rev_parse('HEAD'))
40
+ infov message('Commited (SHA1)'), @commit.sha1
41
+ sha1_cache.write(@commit.sha1)
42
+ files_size_cache.write(@commit.files_size)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module Helpers
8
+ private
9
+
10
+ def message(suffix, padding = 0)
11
+ "#{(' ' * (padding + 2))}* #{suffix}"
12
+ end
13
+
14
+ def git
15
+ source_commit.git
16
+ end
17
+
18
+ def push_large
19
+ source_commit.push_large
20
+ end
21
+
22
+ def previous_revision
23
+ push_large.last_pushed_revision
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module PickSourceRevision
8
+ private
9
+
10
+ def add_cacheinfo_fail?(result)
11
+ !result.fetch(:exit_code).zero? && result.fetch(:stderr).include?('add_cacheinfo')
12
+ end
13
+
14
+ def cherry_pick_source_revision_uncached
15
+ checkout_base
16
+ return unless previous_revision.present?
17
+
18
+ infom message("Cherry pick #{source_commit.sha1}")
19
+ result = git.execute('cherry-pick', '--allow-empty', '--allow-empty-message',
20
+ '-Xtheirs', source_commit.sha1)
21
+ check_cherry_pick_result(result)
22
+ end
23
+
24
+ def check_cherry_pick_result(result)
25
+ return if result.fetch(:exit_code).zero?
26
+ return on_cherry_pick_conflict if cherry_pick_conflict?
27
+ return on_add_cacheinfo_fail if add_cacheinfo_fail?(result)
28
+
29
+ raise "Cherry pick failed: #{result}"
30
+ end
31
+
32
+ def cherry_pick_conflict?
33
+ ::File.exist?(::File.join(git, '.git', 'CHERRY_PICK_HEAD'))
34
+ end
35
+
36
+ def on_add_cacheinfo_fail
37
+ warn message('"add_cacheinfo" fail')
38
+ end
39
+
40
+ def on_cherry_pick_conflict
41
+ warn message('Cherry pick failed with conflict')
42
+ resolve_cherry_pick_conflicts
43
+
44
+ check_dirty_files
45
+ check_cherry_continue
46
+ end
47
+
48
+ def resolve_cherry_pick_conflicts
49
+ git.status_files.each do |scf|
50
+ if scf.dirty == 'D'
51
+ remove_file(scf.path)
52
+ elsif scf.dirty.present?
53
+ add_file(scf.path)
54
+ end
55
+ end
56
+ end
57
+
58
+ def remove_file(path)
59
+ infov message('Removing file'), path
60
+ git.execute!('rm', path)
61
+ end
62
+
63
+ def add_file(path)
64
+ infov message('Adding file'), path
65
+ git.execute!('add', path)
66
+ end
67
+
68
+ def check_dirty_files
69
+ infom message('Checking dirty files...')
70
+ df = dirty_files
71
+ infov message('Dirty files?'), df.any?
72
+ return unless df.any?
73
+
74
+ df.each do |f|
75
+ infov message(f.path, 1), "|#{f.stage}|#{f.dirty}|"
76
+ end
77
+ raise 'There are dirty files'
78
+ end
79
+
80
+ def dirty_files
81
+ git.status_files.select { |scf| scf.dirty.present? }
82
+ end
83
+
84
+ def check_cherry_continue
85
+ infom message('Continuing cherry pick')
86
+ git.execute!('-c', "core.editor=#{bash_editor}", 'cherry-pick', '--continue')
87
+ raise 'Still in cherry-pick conflict' if cherry_pick_conflict?
88
+
89
+ infom message('Cherry pick continue successful')
90
+ end
91
+
92
+ def bash_editor
93
+ if source_commit.subject.present?
94
+ 'true'
95
+ else
96
+ 'bash -c "printf \\"Mensagem original em branco.\\n\\" > $1"'
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Git
5
+ class PushLarge
6
+ class LfsCommit
7
+ module Push
8
+ private
9
+
10
+ PACK_ERROR_MESSAGE = 'pack exceeds maximum allowed size'
11
+ PACK_ERROR_TRUE = 'true'
12
+ PACK_ERROR_FALSE = 'false'
13
+
14
+ def push_ok_uncached
15
+ commit
16
+ fresh_push if push_pack_error_cache.read.blank?
17
+ after_push_banner
18
+ push_pack_error_cache.read != PACK_ERROR_TRUE
19
+ end
20
+
21
+ def after_push_banner
22
+ infov message('Commit SHA1'), commit.sha1
23
+ raise 'Cache of files size not found' if files_size_cache.read.blank?
24
+
25
+ infov message('Files size'), PushLarge.bytes_size(files_size_cache.read)
26
+ end
27
+
28
+ def fresh_push
29
+ fresh_push_banner
30
+ check_push_result(
31
+ git.execute(
32
+ 'push', push_large.remote_name, '--force',
33
+ "#{commit.sha1}:#{push_reference}"
34
+ )
35
+ )
36
+ end
37
+
38
+ def fresh_push_banner
39
+ infom message('Pushing...')
40
+ fresh_push_commit_banner
41
+ fresh_push_remote_banner
42
+ end
43
+
44
+ def fresh_push_commit_banner
45
+ infov message('SHA1', 1), commit.sha1
46
+ infov message('Files size', 1), PushLarge.bytes_size(commit.files_size)
47
+ end
48
+
49
+ def fresh_push_remote_banner
50
+ infov message('Remote', 1), push_large.remote_name
51
+ infov message('Reference', 1), push_reference
52
+ end
53
+
54
+ def push_reference
55
+ "refs/heads/#{push_large.target_ref}"
56
+ end
57
+
58
+ def check_push_result(result)
59
+ if result.fetch(:exit_code).zero?
60
+ on_push_result_ok
61
+ elsif result.fetch(:stderr).include?(PACK_ERROR_MESSAGE)
62
+ on_push_result_pack_error
63
+ else
64
+ on_push_result_arbitrary_error(result)
65
+ end
66
+ end
67
+
68
+ def on_push_result_ok
69
+ push_pack_error_cache.write(PACK_ERROR_FALSE)
70
+ success(push_message('successful'))
71
+ end
72
+
73
+ def on_push_result_pack_error
74
+ push_pack_error_cache.write(PACK_ERROR_TRUE)
75
+ warn(push_message("failed with message \"#{PACK_ERROR_MESSAGE}\""))
76
+ end
77
+
78
+ def on_push_result_arbitrary_error(result)
79
+ raise result.pretty_inspect.to_s
80
+ end
81
+
82
+ def push_message(suffix)
83
+ message("Push of #{commit.sha1} (Size: #{commit.files_size}, " \
84
+ "Files: #{commit.files.count}): #{suffix}.")
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end