avm-tools 0.51.0 → 0.52.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: a30c179acc435486e3fe35ad34714133f582332ddcfb98fd00be1f75c1960df2
4
- data.tar.gz: 07d4c21e8c6dd98d2f7ce70a02f5caec1ba0660e9a59f5d15af0c8b6f711022a
3
+ metadata.gz: 3764f4ca13b2ddc71f8c85c48e0b5d60652083caf844402118dde252bbf556ac
4
+ data.tar.gz: '095d96b661591d076a37287c723ac69833a0b167474d4ac32c6157767662c60f'
5
5
  SHA512:
6
- metadata.gz: 9d3b21ec49fb39bad56c9d8de4538cf5261f452d57d8c0188e0cb501ae7a9584fa54d2e35a0a88c250956af6edc48eec0e91f2aa4c186fec038f67d148f911dc
7
- data.tar.gz: 761bad690d7493109e71c2fdb34efcf5a0f1737d6d5b52d1f23d16c4c597e18593a5bca169900484421ff8071f79a20560a8754409e4b529135b905c099cbade
6
+ metadata.gz: ed3c88ad9c85b8bb726f48f2a3dc08639bda36fdd71c28bc8b191e619956632ebaf3703a70f0bbf43eb4497f969aeca46b97e4e0e59da2c082acdaf2fa8971c7
7
+ data.tar.gz: 3e637c06cbe3a99a0b2b63f3d6fce68b5798e9e8d2bec94c92bcad2862d4322963073c7a15e05855b9604defcc6a6c84bb474f7934171c54276d674f4ea87211
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ class AutoCommitPath
8
+ enable_console_speaker
9
+ common_constructor :git, :path
10
+
11
+ CLASS_NAME_PATTERNS = [%r{lib/(.+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
12
+
13
+ def run
14
+ banner
15
+ commit
16
+ end
17
+
18
+ def banner
19
+ infom "Checking \"#{relative_path}\""
20
+ infov ' * Class name', class_name
21
+ infov ' * Commit message', commit_message
22
+ end
23
+
24
+ def commit
25
+ infom ' * Commiting...'
26
+ git.system!('reset', 'HEAD')
27
+ git.system!('add', '--', relative_path.to_path)
28
+ git.system!('commit', '-m', commit_message, '--', relative_path.to_path)
29
+ end
30
+
31
+ def class_name
32
+ CLASS_NAME_PATTERNS.each do |pattern|
33
+ pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
34
+ end
35
+ raise "No pattern matched \"#{relative_path}\""
36
+ end
37
+
38
+ def commit_message
39
+ r = class_name
40
+ r += ': remove' unless path.file?
41
+ r + '.'
42
+ end
43
+
44
+ def relative_path
45
+ path.relative_path_from(git.root_path)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit_path'
4
+ require 'eac_cli/default_runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Git < ::EacRubyUtils::Console::DocoptRunner
10
+ class AutoCommit < ::EacRubyUtils::Console::DocoptRunner
11
+ include ::EacCli::DefaultRunner
12
+
13
+ runner_definition do
14
+ desc 'Commit with message based in content commited.'
15
+ bool_opt '-d', '--dirty', 'Select dirty files.'
16
+ pos_arg 'paths', repeat: true, optional: true
17
+ end
18
+
19
+ def run
20
+ clear_stage
21
+ banner
22
+ run_paths
23
+ end
24
+
25
+ private
26
+
27
+ def banner
28
+ infov 'Paths', paths.count
29
+ end
30
+
31
+ def clear_stage
32
+ infom 'Clearing stage...'
33
+ context(:git).system!('reset', 'HEAD')
34
+ end
35
+
36
+ def dirty_paths
37
+ return [] unless options.fetch('--dirty')
38
+
39
+ context(:git).dirty_files.map { |d| context(:git).root_path.join / d.path }
40
+ end
41
+
42
+ def paths_uncached
43
+ (options.fetch('<paths>')
44
+ .map { |p| p.to_pathname.expand_path } + dirty_paths)
45
+ .reject(&:directory?)
46
+ .sort.uniq.map { |path| ::Avm::Git::AutoCommitPath.new(context(:git), path) }
47
+ end
48
+
49
+ def run_paths
50
+ paths.each(&:run)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.51.0'
5
+ VERSION = '0.52.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.51.0
4
+ version: 0.52.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-06-17 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -258,6 +258,7 @@ files:
258
258
  - lib/avm/files/rotate.rb
259
259
  - lib/avm/fs_cache.rb
260
260
  - lib/avm/git.rb
261
+ - lib/avm/git/auto_commit_path.rb
261
262
  - lib/avm/git/commit.rb
262
263
  - lib/avm/git/commit/deploy.rb
263
264
  - lib/avm/git/commit/diff_tree_line.rb
@@ -371,6 +372,7 @@ files:
371
372
  - lib/avm/tools/runner/files/format.rb
372
373
  - lib/avm/tools/runner/files/rotate.rb
373
374
  - lib/avm/tools/runner/git.rb
375
+ - lib/avm/tools/runner/git/auto_commit.rb
374
376
  - lib/avm/tools/runner/git/auto_fixup.rb
375
377
  - lib/avm/tools/runner/git/commit.rb
376
378
  - lib/avm/tools/runner/git/deploy.rb