avm-tools 0.85.1 → 0.86.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: 43d475cc5c1bf70580258451dfada46e601167d1b4304f102fd334b21862a922
4
- data.tar.gz: 0b2230eb8368b7315e437d7218144bbeaffe735887fa86fd6dec6647c545bd4a
3
+ metadata.gz: 3d94c38f057d3459362f2f15eba68de92e72a7141f03a5c029e920db648eb34b
4
+ data.tar.gz: 2719a55cb7b994c496349331e4b5a40a11307e4fe92d889914d3005836d68398
5
5
  SHA512:
6
- metadata.gz: 3d45fbfd1797ba0e24a1c44cec1a260c1a12b457f486991f55befde788de312959084d78717fedb7ef593731399aa9be9534512e3e9af1c71c7ac706cde3b262
7
- data.tar.gz: 5d539d2be00bfc34491192fe927b98ec977af4f474790afaf03eda326b5db8749cbfa8e97ef98981c5663a444f3a703c6189a5b7688582b95cef44458648d7e1
6
+ metadata.gz: 54d1c5271e6d30791bbc6a9cd6084f21ef2e171f3b64e21c315aa41f4bf2f289ae4c8725f74280a0f008d4a6fb32ce85f71fcf3f5e83d46a5ef14d48dc7a6174
7
+ data.tar.gz: 2c717894f623ab3bfd4b8b489c01adf8cc564a638c374fa1f7dbc5f9be715461ae4b1f8847b22d48a383e51775754eac408d8f6273260ff32dd1837acd5b30dd
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/patches/class/i18n'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class Git
10
+ class Update
11
+ require_sub __FILE__
12
+ enable_simple_cache
13
+ enable_console_speaker
14
+ common_constructor :instance
15
+
16
+ delegate :git_repo, to: :instance
17
+
18
+ def run
19
+ clean_all
20
+ selected_subrepos.map do |f|
21
+ infov 'Subrepo', f
22
+ on_speaker_node do |node|
23
+ node.stderr_line_prefix = ' '
24
+ ::Avm::Projects::Stereotypes::Git::Update::Subrepo.new(self, f).run
25
+ end
26
+ end
27
+ end
28
+
29
+ def selected_subrepos_uncached
30
+ git_repo.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
31
+ .select(&:present?).map(&:to_pathname)
32
+ end
33
+
34
+ def clean_all
35
+ infom 'Cleaning'
36
+ git_repo.command('subrepo', 'clean', '--all').execute!
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/base'
4
+ require 'avm/git/commit'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class Git
10
+ class Update
11
+ class Subrepo
12
+ TRANSLATE_CLASS = self
13
+
14
+ require_sub __FILE__, include_modules: true
15
+ enable_simple_cache
16
+ enable_console_speaker
17
+ common_constructor :parent_update, :subpath do
18
+ self.subpath = subpath.to_pathname
19
+ end
20
+
21
+ delegate :git_repo, :instance, to: :parent_update
22
+
23
+ def run
24
+ run_banner
25
+ if base_commit.sha1 == pull_commit.sha1
26
+ infom 'No new commit (No changes)'
27
+ elsif fix_message.present?
28
+ on_fix_message_present
29
+ else
30
+ warn 'No fix message found'
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def base_commit_uncached
37
+ ::Avm::Git::Commit.new(git_repo, git_repo.rev_parse('HEAD'))
38
+ end
39
+
40
+ def on_fix_message_present
41
+ infom 'Fixing message...'
42
+ infov 'Message', fix_message
43
+ git_repo.command('commit', '--amend', '-m', fix_message).execute!
44
+ end
45
+
46
+ def pull_commit_uncached
47
+ base_commit
48
+ infom 'Pulling subrepo...'
49
+ git_repo.command('subrepo', 'pull', '--force', subpath).execute!
50
+ ::Avm::Git::Commit.new(
51
+ ::EacLauncher::Git::Base.new(git_repo.root_path.to_path),
52
+ git_repo.rev_parse('HEAD')
53
+ )
54
+ end
55
+
56
+ def run_banner
57
+ infov 'Base SHA1', base_commit.sha1
58
+ infov 'Pull SHA1', pull_commit.sha1
59
+ end
60
+
61
+ def fix_message
62
+ TRANSLATE_CLASS.translate(
63
+ fix_message_translate_key, subpath: subpath, name: subpath.basename,
64
+ __locale: instance.locale
65
+ )
66
+ end
67
+
68
+ def fix_message_translate_key
69
+ if gitrepo_only_changed?
70
+ :gitrepo_only_changed_fix_message
71
+ else
72
+ :content_updated_fix_message
73
+ end
74
+ end
75
+
76
+ def gitrepo_only_changed?
77
+ pull_commit.files.count == 1 &&
78
+ ::File.basename(pull_commit.files.first.path) == '.gitrepo'
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.85.1'
5
+ VERSION = '0.86.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.85.1
4
+ version: 0.86.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -460,6 +460,8 @@ files:
460
460
  - lib/avm/projects/stereotypes/git.rb
461
461
  - lib/avm/projects/stereotypes/git/local_project_mixin.rb
462
462
  - lib/avm/projects/stereotypes/git/publish.rb
463
+ - lib/avm/projects/stereotypes/git/update.rb
464
+ - lib/avm/projects/stereotypes/git/update/subrepo.rb
463
465
  - lib/avm/projects/stereotypes/git/warp.rb
464
466
  - lib/avm/projects/stereotypes/git_subrepo.rb
465
467
  - lib/avm/projects/stereotypes/git_subrepo/publish.rb