avm-tools 0.92.0 → 0.94.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/eac_asciidoctor_base0/apache_path.rb +10 -0
- data/lib/avm/eac_rails_base0/apache_path.rb +6 -38
- data/lib/avm/eac_webapp_base0/apache_host.rb +7 -31
- data/lib/avm/eac_webapp_base0/apache_path.rb +51 -0
- data/lib/avm/eac_webapp_base0/deploy.rb +12 -30
- data/lib/avm/eac_webapp_base0/instance.rb +5 -2
- data/lib/avm/eac_webapp_base0/instance/subcommand_parent.rb +24 -0
- data/lib/avm/eac_webapp_base0/runner/apache_host.rb +7 -10
- data/lib/avm/eac_webapp_base0/runner/apache_path.rb +40 -0
- data/lib/avm/eac_webapp_base0/runner/data.rb +7 -15
- data/lib/avm/eac_webapp_base0/runner/data/dump.rb +18 -24
- data/lib/avm/eac_webapp_base0/runner/data/load.rb +12 -23
- data/lib/avm/git/auto_commit/commit_info.rb +2 -1
- data/lib/avm/git/auto_commit/rules.rb +4 -4
- data/lib/avm/git/auto_commit/rules/new.rb +24 -0
- data/lib/avm/git/auto_commit/rules/nth.rb +8 -0
- data/lib/avm/git/auto_commit_path.rb +0 -21
- data/lib/avm/git/file_auto_fixup.rb +19 -3
- data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +7 -11
- data/lib/avm/tools/runner/git/auto_commit.rb +28 -28
- data/lib/avm/tools/runner/git/subrepo/fix.rb +1 -1
- data/lib/avm/tools/runner/local_project/ruby.rb +3 -7
- data/lib/avm/tools/runner/local_project/ruby/bundler.rb +4 -8
- data/lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb +11 -14
- data/lib/avm/tools/runner/ruby.rb +6 -14
- data/lib/avm/tools/runner/ruby/gems.rb +4 -7
- data/lib/avm/tools/runner/ruby/gems/generate.rb +12 -23
- data/lib/avm/tools/runner/ruby/rubocop.rb +1 -1
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_rails_base0/apache_path/extra_content.conf +5 -0
- data/template/avm/eac_webapp_base0/apache_path/default.conf +9 -0
- data/vendor/avm-apps/Gemfile +5 -0
- data/vendor/avm-apps/avm-apps.gemspec +18 -0
- data/vendor/avm-apps/lib/avm/apps.rb +9 -0
- data/vendor/avm-apps/lib/avm/apps/jobs.rb +11 -0
- data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +64 -0
- data/vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb +24 -0
- data/vendor/avm-apps/lib/avm/apps/version.rb +7 -0
- data/vendor/avm-apps/spec/rubocop_spec.rb +7 -0
- data/vendor/avm-apps/spec/spec_helper.rb +100 -0
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +4 -7
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +20 -9
- data/vendor/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb +47 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +15 -1
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +4 -2
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +8 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +4 -0
- data/vendor/eac_git/eac_git.gemspec +1 -0
- data/vendor/eac_git/lib/eac_git/local.rb +4 -0
- data/vendor/eac_git/lib/eac_git/local/commit.rb +53 -0
- data/vendor/eac_git/lib/eac_git/local/commit/changed_file.rb +46 -0
- data/vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb +32 -0
- data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +2 -3
- data/vendor/eac_git/lib/eac_git/rspec.rb +6 -1
- data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb} +16 -13
- data/vendor/eac_git/lib/eac_git/version.rb +1 -1
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out +2 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb +58 -0
- data/vendor/eac_git/spec/spec_helper.rb +1 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +36 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +42 -0
- data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +7 -10
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +9 -2
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +8 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
- metadata +55 -9
- data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +0 -38
- data/lib/avm/tools/runner/git/auto_fixup.rb +0 -53
- data/template/avm/eac_rails_base0/apache_path/default.conf +0 -13
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class Definition
|
5
|
+
class BaseOption
|
6
|
+
class InitializeArgsParser
|
7
|
+
PROPERTIES = %i[short long description options].freeze
|
8
|
+
attr_reader(*PROPERTIES)
|
9
|
+
|
10
|
+
def initialize(args)
|
11
|
+
self.options = args.extract_options!.freeze
|
12
|
+
args.each { |arg| absorb_arg(arg) }
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_writer(*PROPERTIES)
|
18
|
+
|
19
|
+
def absorb_arg(arg)
|
20
|
+
arg_ext = ArgumentParser.new(arg)
|
21
|
+
send("#{arg_ext.type}=", arg_ext.value)
|
22
|
+
end
|
23
|
+
|
24
|
+
class ArgumentParser
|
25
|
+
TYPES = %i[short long description].freeze
|
26
|
+
common_constructor :value
|
27
|
+
|
28
|
+
def type
|
29
|
+
TYPES.find { |type| send("#{type}?") } || raise("Unknown type for \"#{value}\"")
|
30
|
+
end
|
31
|
+
|
32
|
+
def short?
|
33
|
+
value.start_with?('-') && !long?
|
34
|
+
end
|
35
|
+
|
36
|
+
def long?
|
37
|
+
value.start_with?('--')
|
38
|
+
end
|
39
|
+
|
40
|
+
def description?
|
41
|
+
!short? || !long?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -19,10 +19,24 @@ module EacCli
|
|
19
19
|
b += '=<value>' if option.argument?
|
20
20
|
b
|
21
21
|
end
|
22
|
+
|
23
|
+
def option_short(option)
|
24
|
+
b = option.short
|
25
|
+
b += '=<value>' if option.argument?
|
26
|
+
b
|
27
|
+
end
|
28
|
+
|
29
|
+
def option_usage_full(option)
|
30
|
+
if option.long.present?
|
31
|
+
[option.short, option_long(option)].reject(&:blank?).join(SEP)
|
32
|
+
else
|
33
|
+
option_short(option)
|
34
|
+
end
|
35
|
+
end
|
22
36
|
end
|
23
37
|
|
24
38
|
def option_definition(option)
|
25
|
-
|
39
|
+
self.class.option_usage_full(option) + OPTION_DESC_SEP + option.description
|
26
40
|
end
|
27
41
|
|
28
42
|
def section(header, include_header = true)
|
@@ -14,7 +14,9 @@ module EacCli
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def find_short_option(char)
|
17
|
-
alternative.options.find
|
17
|
+
alternative.options.find do |option|
|
18
|
+
short_without_prefix(option.short).if_present(false) { |v| v == char }
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def short_option_collect_argv_value
|
@@ -37,7 +39,7 @@ module EacCli
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def short_without_prefix(short)
|
40
|
-
short.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
|
42
|
+
short.to_s.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
require 'eac_cli/runner'
|
5
5
|
require 'eac_cli/runner_with'
|
6
|
+
require 'eac_cli/runner_with_set'
|
6
7
|
|
7
8
|
class Object
|
8
9
|
def runner_with(*runners, &block)
|
@@ -10,7 +11,7 @@ class Object
|
|
10
11
|
enable_simple_cache
|
11
12
|
enable_console_speaker
|
12
13
|
runners.each do |runner|
|
13
|
-
include
|
14
|
+
include ::EacCli::RunnerWithSet.default.item_to_module(runner)
|
14
15
|
end
|
15
16
|
runner_definition(&block) if block
|
16
17
|
end
|
@@ -27,8 +27,9 @@ module EacCli
|
|
27
27
|
|
28
28
|
def parent_call(method_name, *args)
|
29
29
|
return parent.context(method_name, *args) if parent.respond_to?(:context)
|
30
|
+
return parent.runner_context.call(method_name, *args) if parent.respond_to?(:runner_context)
|
30
31
|
|
31
|
-
parent.runner_context
|
32
|
+
raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -3,15 +3,22 @@
|
|
3
3
|
module EacCli
|
4
4
|
module Runner
|
5
5
|
module InstanceMethods
|
6
|
+
PARSER_ERROR_EXIT_CODE = 1
|
7
|
+
|
6
8
|
def run_run
|
7
9
|
parsed
|
8
10
|
run_callbacks(:run) { run }
|
9
11
|
rescue ::EacCli::Parser::Error => e
|
10
|
-
|
12
|
+
run_parser_error(e)
|
11
13
|
rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
|
12
14
|
# Do nothing
|
13
15
|
end
|
14
16
|
|
17
|
+
def run_parser_error(error)
|
18
|
+
$stderr.write("#{error}\n")
|
19
|
+
::Kernel.exit(PARSER_ERROR_EXIT_CODE)
|
20
|
+
end
|
21
|
+
|
15
22
|
def runner_context
|
16
23
|
return @runner_context if @runner_context
|
17
24
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class RunnerWithSet
|
5
|
+
class << self
|
6
|
+
def default
|
7
|
+
@default ||= new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_namespace(namespace)
|
12
|
+
namespace = sanitize_namespace(namespace)
|
13
|
+
raise "\"#{namespace}\" already was included" if namespace_set.include?(namespace)
|
14
|
+
|
15
|
+
namespace_set << namespace
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def item_to_module(item)
|
20
|
+
item.is_a?(::Module) ? item : key_to_module(item)
|
21
|
+
end
|
22
|
+
|
23
|
+
def namespaces
|
24
|
+
namespace_set.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def namespace_set
|
30
|
+
@namespace_set ||= ::Array.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def key_to_module(key)
|
34
|
+
namespace_set.lazy
|
35
|
+
.map { |namespace| key_to_module_in_namespace(namespace, key) }
|
36
|
+
.find(&:present?) ||
|
37
|
+
raise("Not module found with key \"#{key}\" (Namespaces: #{namespace_set})")
|
38
|
+
end
|
39
|
+
|
40
|
+
def key_to_module_in_namespace(namespace, key)
|
41
|
+
namespace.const_get(key.to_s.camelize)
|
42
|
+
rescue ::NameError
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def sanitize_namespace(source)
|
47
|
+
source.is_a?(::Module) ? source : source.to_s.constantize
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -7,6 +7,10 @@ RSpec.describe ::EacCli::Definition::Alternative do
|
|
7
7
|
|
8
8
|
it { expect { instance.arg_opt '-a', '--opt2', 'A argument option' }.not_to raise_error }
|
9
9
|
it { expect { instance.bool_opt '-b', '--opt1', 'A boolean option' }.not_to raise_error }
|
10
|
+
it { expect { instance.bool_opt '-b', '--no-description' }.not_to raise_error }
|
11
|
+
it { expect { instance.bool_opt '--opt1', 'A option without short' }.not_to raise_error }
|
12
|
+
it { expect { instance.bool_opt '-b', 'A option without long' }.not_to raise_error }
|
13
|
+
it { expect { instance.bool_opt 'A option without selectors' }.to raise_error(::StandardError) }
|
10
14
|
it { expect { instance.options_argument(true) }.not_to raise_error }
|
11
15
|
it { expect { instance.pos_arg :pos1 }.not_to raise_error }
|
12
16
|
it { expect { instance.pos_arg :pos2, optional: true, repeat: true }.not_to raise_error }
|
@@ -15,5 +15,6 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency 'eac_ruby_utils', '~> 0.37'
|
16
16
|
s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
|
17
17
|
|
18
|
+
s.add_development_dependency 'aranha-parsers', '~> 0.7'
|
18
19
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
|
19
20
|
end
|
@@ -12,6 +12,10 @@ module EacGit
|
|
12
12
|
self.root_path = root_path.to_pathname
|
13
13
|
end
|
14
14
|
|
15
|
+
def commit(ref, required = false)
|
16
|
+
rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
|
17
|
+
end
|
18
|
+
|
15
19
|
def descendant?(descendant, ancestor)
|
16
20
|
base = merge_base(descendant, ancestor)
|
17
21
|
return false if base.blank?
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacGit
|
6
|
+
class Local
|
7
|
+
class Commit
|
8
|
+
require_sub __FILE__, include_modules: true
|
9
|
+
enable_simple_cache
|
10
|
+
|
11
|
+
FIELDS = {
|
12
|
+
author_name: '%an', author_email: '%ae', author_date: '%ai',
|
13
|
+
subject: '%s',
|
14
|
+
author_all: '%an <%ae>, %ai',
|
15
|
+
commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
|
16
|
+
commiter_all: '%cn <%ce>, %ci'
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
common_constructor :repo, :hash
|
20
|
+
|
21
|
+
def format(format)
|
22
|
+
repo.command('--no-pager', 'log', '-1', "--pretty=format:#{format}", hash).execute!.strip
|
23
|
+
end
|
24
|
+
|
25
|
+
FIELDS.each do |field, format|
|
26
|
+
define_method(field) { format(format) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def changed_files_uncached
|
30
|
+
diff_tree_execute.each_line.map do |line|
|
31
|
+
::EacGit::Local::Commit::ChangedFile.new(self, line)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def changed_files_size_uncached
|
36
|
+
changed_files.inject(0) { |a, e| a + e.dst_size }
|
37
|
+
end
|
38
|
+
|
39
|
+
def root_child?
|
40
|
+
format('%P').blank?
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def diff_tree_execute
|
46
|
+
args = []
|
47
|
+
args << '--root' if root_child?
|
48
|
+
args << hash
|
49
|
+
repo.command(*::EacGit::Local::Commit::DiffTreeLine::GIT_COMMAND_ARGS, *args).execute!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_git/local/commit/diff_tree_line'
|
5
|
+
|
6
|
+
module EacGit
|
7
|
+
class Local
|
8
|
+
class Commit
|
9
|
+
class ChangedFile
|
10
|
+
enable_simple_cache
|
11
|
+
|
12
|
+
attr_reader :commit, :diff_tree
|
13
|
+
|
14
|
+
# @param commit [EacGit::Local::Commit]
|
15
|
+
# @param diff_tree_line [String] A line from command "repo diff-tree --no-commit-id -r
|
16
|
+
# --full-index"'s output.
|
17
|
+
def initialize(commit, diff_tree_line)
|
18
|
+
@commit = commit
|
19
|
+
@diff_tree = ::EacGit::Local::Commit::DiffTreeLine.new(diff_tree_line)
|
20
|
+
end
|
21
|
+
|
22
|
+
delegate(*::EacGit::Local::Commit::DiffTreeLine::FIELDS, to: :diff_tree)
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"#{path}|#{status}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def src_size_uncached
|
29
|
+
size(src_sha1)
|
30
|
+
end
|
31
|
+
|
32
|
+
def dst_size_uncached
|
33
|
+
size(dst_sha1)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def size(id)
|
39
|
+
return 0 if /\A0+\z/.match(id)
|
40
|
+
|
41
|
+
commit.repo.command('cat-file', '-s', id).execute!.strip.to_i
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacGit
|
4
|
+
class Local
|
5
|
+
class Commit
|
6
|
+
class DiffTreeLine
|
7
|
+
DIFF_TREE_PATTERN = /\A:(\d{6}) (\d{6}) (\S+) (\S+) (\S+)\t(\S.*)\z/.freeze
|
8
|
+
FIELDS = %w[src_mode dst_mode src_sha1 dst_sha1 status path].freeze
|
9
|
+
GIT_COMMAND_ARGS = %w[-c core.quotepath=off diff-tree --no-commit-id -r --full-index].freeze
|
10
|
+
|
11
|
+
attr_reader(*FIELDS)
|
12
|
+
|
13
|
+
# line: a line of command "git [GIT_COMMAND_ARGS]"'s output.
|
14
|
+
# Reference: https://git-scm.com/docs/git-diff-tree
|
15
|
+
def initialize(line)
|
16
|
+
m = DIFF_TREE_PATTERN.match(line.strip)
|
17
|
+
raise "\"#{line}\" did not match pattern" unless m
|
18
|
+
|
19
|
+
FIELDS.count.times { |i| send("#{FIELDS[i]}=", m[i + 1]) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def fields
|
23
|
+
FIELDS.map { |field| [field, send(field)] }.to_h
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_writer(*FIELDS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -20,9 +20,8 @@ module EacGit
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def dirty_files
|
23
|
-
command('status', '--porcelain', '--untracked-files')
|
24
|
-
parse_status_line(line.gsub(/\n\z/, ''))
|
25
|
-
end
|
23
|
+
command('status', '--porcelain=v1', '--untracked-files', '--no-renames')
|
24
|
+
.execute!.each_line.map { |line| parse_status_line(line.gsub(/\n\z/, '')) }
|
26
25
|
end
|
27
26
|
|
28
27
|
private
|
@@ -5,12 +5,17 @@ require 'eac_git/executables'
|
|
5
5
|
|
6
6
|
module EacGit
|
7
7
|
module Rspec
|
8
|
+
require_sub __FILE__
|
9
|
+
|
8
10
|
class << self
|
9
11
|
def configure
|
10
12
|
::EacRubyUtils::Rspec::Conditional.default.add(:git) do
|
11
13
|
::EacGit::Executables.git.validate
|
12
14
|
end
|
13
|
-
RSpec.configure
|
15
|
+
RSpec.configure do |config|
|
16
|
+
::EacRubyUtils::Rspec::Conditional.default.configure(config)
|
17
|
+
config.include ::EacGit::Rspec::StubbedGitLocalRepo
|
18
|
+
end
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb}
RENAMED
@@ -1,28 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_git/local'
|
3
4
|
require 'eac_ruby_utils/envs'
|
4
|
-
require 'eac_launcher/git/base'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'tmpdir'
|
7
7
|
|
8
|
-
module
|
9
|
-
module
|
10
|
-
module
|
11
|
-
def
|
8
|
+
module EacGit
|
9
|
+
module Rspec
|
10
|
+
module StubbedGitLocalRepo
|
11
|
+
def stubbed_git_local_repo(bare = false)
|
12
12
|
path = ::Dir.mktmpdir
|
13
|
-
::EacRubyUtils::Envs.local.command(
|
14
|
-
StubbedGitRepository.new(path)
|
13
|
+
::EacRubyUtils::Envs.local.command(stubbed_git_local_repo_args(path, bare)).execute!
|
14
|
+
repo = StubbedGitRepository.new(path)
|
15
|
+
repo.command('config', 'user.email', 'theuser@example.net').execute!
|
16
|
+
repo.command('config', 'user.name', 'The User').execute!
|
17
|
+
repo
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
21
|
|
19
|
-
def
|
22
|
+
def stubbed_git_local_repo_args(path, bare)
|
20
23
|
r = %w[git init]
|
21
24
|
r << '--bare' if bare
|
22
25
|
r + [path]
|
23
26
|
end
|
24
27
|
|
25
|
-
class StubbedGitRepository < ::
|
28
|
+
class StubbedGitRepository < ::EacGit::Local
|
26
29
|
def file(*subpath)
|
27
30
|
StubbedGitRepositoryFile.new(self, subpath)
|
28
31
|
end
|
@@ -37,19 +40,19 @@ module Avm
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def path
|
40
|
-
|
43
|
+
git.root_path.join(*subpath)
|
41
44
|
end
|
42
45
|
|
43
46
|
def touch
|
44
|
-
::FileUtils.touch(path)
|
47
|
+
::FileUtils.touch(path.to_path)
|
45
48
|
end
|
46
49
|
|
47
50
|
def delete
|
48
|
-
|
51
|
+
path.unlink
|
49
52
|
end
|
50
53
|
|
51
54
|
def write(content)
|
52
|
-
|
55
|
+
path.write(content)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|