eac_tools 0.34.0 → 0.35.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 +4 -4
- data/Gemfile.lock +24 -18
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +1 -1
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_collector.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_discovery.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager/cached_instance.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager/cached_instances.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/instance_manager.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context/settings.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/context.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/instances/base/cache.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/instances/base.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/instances/error.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/instances/runner_helper.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/instances/settings.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/paths/logical.rb +0 -0
- data/sub/{avm-tools → avm}/lib/avm/launcher/publish/base.rb +2 -5
- data/sub/avm/lib/avm/registry.rb +0 -2
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +1 -1
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_host.rb +2 -1
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
- data/sub/avm-git/Gemfile +8 -0
- data/sub/avm-git/avm-git.gemspec +22 -0
- data/sub/avm-git/lib/avm/git/auto_commit/commit_info.rb +23 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/base.rb +39 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/last.rb +19 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/manual.rb +45 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/new.rb +24 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/nth.rb +31 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules/unique.rb +21 -0
- data/sub/avm-git/lib/avm/git/auto_commit/rules.rb +31 -0
- data/sub/avm-git/lib/avm/git/auto_commit_path/ruby.rb +20 -0
- data/sub/avm-git/lib/avm/git/auto_commit_path.rb +28 -0
- data/sub/avm-git/lib/avm/git/commit/class_methods.rb +31 -0
- data/sub/avm-git/lib/avm/git/commit/deploy.rb +38 -0
- data/sub/avm-git/lib/avm/git/commit/deploy_methods.rb +19 -0
- data/sub/avm-git/lib/avm/git/commit/diff_tree_line.rb +32 -0
- data/sub/avm-git/lib/avm/git/commit/file.rb +46 -0
- data/sub/avm-git/lib/avm/git/commit.rb +59 -0
- data/sub/avm-git/lib/avm/git/file_auto_fixup.rb +83 -0
- data/sub/avm-git/lib/avm/git/issue/complete/commits.rb +42 -0
- data/sub/avm-git/lib/avm/git/issue/complete/git_subrepos.rb +23 -0
- data/sub/avm-git/lib/avm/git/issue/complete/local_branch.rb +61 -0
- data/sub/avm-git/lib/avm/git/issue/complete/local_tag.rb +39 -0
- data/sub/avm-git/lib/avm/git/issue/complete/push.rb +60 -0
- data/sub/avm-git/lib/avm/git/issue/complete/remote.rb +33 -0
- data/sub/avm-git/lib/avm/git/issue/complete/test.rb +40 -0
- data/sub/avm-git/lib/avm/git/issue/complete/tracker.rb +28 -0
- data/sub/avm-git/lib/avm/git/issue/complete/validation.rb +39 -0
- data/sub/avm-git/lib/avm/git/issue/complete/validations.rb +53 -0
- data/sub/avm-git/lib/avm/git/issue/complete/working_tree.rb +19 -0
- data/sub/avm-git/lib/avm/git/issue/complete.rb +66 -0
- data/sub/avm-git/lib/avm/git/issue/deliver.rb +56 -0
- data/sub/avm-git/lib/avm/git/issue.rb +11 -0
- data/sub/avm-git/lib/avm/git/organize/reference_update.rb +34 -0
- data/sub/avm-git/lib/avm/git/organize/repository.rb +76 -0
- data/sub/avm-git/lib/avm/git/organize.rb +11 -0
- data/sub/avm-git/lib/avm/git/revision_test.rb +105 -0
- data/sub/avm-git/lib/avm/git/scms/git/change_tracker.rb +35 -0
- data/sub/avm-git/lib/avm/git/scms/git/commit.rb +55 -0
- data/sub/avm-git/lib/avm/git/scms/git.rb +73 -0
- data/sub/avm-git/lib/avm/git/scms/git_subrepo.rb +39 -0
- data/sub/avm-git/lib/avm/git/scms/provider.rb +19 -0
- data/sub/avm-git/lib/avm/git/scms.rb +11 -0
- data/sub/avm-git/lib/avm/git/subrepo_check/parent.rb +51 -0
- data/sub/avm-git/lib/avm/git/subrepo_check/remote.rb +89 -0
- data/sub/avm-git/lib/avm/git/subrepo_check/show_result.rb +32 -0
- data/sub/avm-git/lib/avm/git/subrepo_check.rb +38 -0
- data/sub/avm-git/lib/avm/git/subrepo_checks.rb +59 -0
- data/sub/{avm-tools/lib/avm/launcher → avm-git/lib/avm/git}/vendor/github.rb +1 -1
- data/sub/avm-git/lib/avm/git/vendor.rb +11 -0
- data/sub/avm-git/lib/avm/git/version.rb +7 -0
- data/sub/avm-git/lib/avm/git.rb +11 -0
- data/sub/avm-git/spec/lib/avm/git/auto_commit_path_spec.rb +21 -0
- data/sub/avm-git/spec/lib/avm/git/commit/deploy_spec.rb +93 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec.rb +13 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/add.source.out +1 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/modify.source.out +1 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/remove.source.out +1 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename.source.out +2 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
- data/sub/avm-git/spec/lib/avm/git/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
- data/sub/avm-git/spec/lib/avm/git/commit_spec.rb +56 -0
- data/sub/avm-git/spec/lib/avm/git/scms/git_spec.rb +8 -0
- data/sub/avm-git/spec/lib/avm/git/scms/git_subrepo_spec.rb +8 -0
- data/sub/{avm-tools/spec/lib/avm/launcher → avm-git/spec/lib/avm/git}/vendor/github_spec.rb +4 -4
- data/sub/avm-git/spec/rubocop_spec.rb +3 -0
- data/sub/avm-git/spec/spec_helper.rb +4 -0
- data/sub/avm-tools/avm-tools.gemspec +2 -2
- data/sub/avm-tools/lib/avm/launcher/git/warp_base.rb +2 -2
- data/sub/avm-tools/lib/avm/projects/stereotypes/git_subrepo/warp.rb +2 -2
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_docker/eac_docker.gemspec +2 -2
- data/sub/eac_docker/lib/eac_docker/images/templatized.rb +7 -1
- data/sub/eac_docker/lib/eac_docker/version.rb +1 -1
- metadata +97 -23
- data/sub/avm-tools/lib/avm/launcher/vendor.rb +0 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/tools/core_ext'
|
|
4
|
+
require 'eac_git/local'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module Git
|
|
8
|
+
module Issue
|
|
9
|
+
class Complete
|
|
10
|
+
require_sub __FILE__, include_modules: true
|
|
11
|
+
enable_simple_cache
|
|
12
|
+
enable_speaker
|
|
13
|
+
|
|
14
|
+
BRANCH_NAME_ISSUE_ID_PATTERN =
|
|
15
|
+
|
|
16
|
+
attr_reader :dir, :skip_validations
|
|
17
|
+
|
|
18
|
+
def initialize(options)
|
|
19
|
+
consumer = ::EacRubyUtils::OptionsConsumer.new(options)
|
|
20
|
+
@dir, @skip_validations = consumer.consume_all(:dir, :skip_validations)
|
|
21
|
+
validate_skip_validations
|
|
22
|
+
consumer.validate
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def start_banner
|
|
26
|
+
validations_banner
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def run
|
|
30
|
+
return false unless valid?
|
|
31
|
+
|
|
32
|
+
assert_tag
|
|
33
|
+
push
|
|
34
|
+
remove_local_branch
|
|
35
|
+
clipboard_copy_tracker_message
|
|
36
|
+
true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def issue_id
|
|
40
|
+
branch ? issue_id_parser.parse(branch_name) : nil
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [EacRubyUtils::RegexpParser]
|
|
44
|
+
def issue_id_parser
|
|
45
|
+
/\A#{Regexp.quote('issue_')}(\d+)\z/.to_parser { |m| m[1].to_i }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
# @return [EacGit::Local]
|
|
51
|
+
def eac_git_uncached
|
|
52
|
+
::EacGit::Local.new(dir)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def git_execute(args, exit_outputs = {})
|
|
56
|
+
r = launcher_git.execute!(args, exit_outputs: exit_outputs)
|
|
57
|
+
r.is_a?(String) ? r.strip : r
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def launcher_git_uncached
|
|
61
|
+
::Avm::Launcher::Git::Base.new(dir)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/tools/core_ext'
|
|
4
|
+
require 'clipboard'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module Git
|
|
8
|
+
module Issue
|
|
9
|
+
class Deliver
|
|
10
|
+
enable_simple_cache
|
|
11
|
+
enable_speaker
|
|
12
|
+
|
|
13
|
+
common_constructor :git_repo
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
push
|
|
17
|
+
clipboard_copy_tracker_message
|
|
18
|
+
true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def start_banner
|
|
22
|
+
infov 'Branch name', branch_name
|
|
23
|
+
infov 'Commit ID', branch_commit_id
|
|
24
|
+
infov 'Push arguments', ::Shellwords.join(push_args)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def branch_commit_id
|
|
30
|
+
git_repo.rev_parse(branch_name)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def branch_name_uncached
|
|
34
|
+
git_repo.command('rev-parse', '--abbrev-ref', 'HEAD').execute!.strip
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def clipboard_copy_tracker_message
|
|
38
|
+
::Clipboard.copy(textile_tracker_message)
|
|
39
|
+
infov 'Copied to clipboard', textile_tracker_message
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def push
|
|
43
|
+
git_repo.command(*push_args).system!
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def push_args
|
|
47
|
+
%w[push origin --force] + ["#{branch_name}:refs/heads/#{branch_name}"]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def textile_tracker_message
|
|
51
|
+
"#{branch_name}: commit:#{branch_commit_id}."
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
|
|
5
|
+
module Avm
|
|
6
|
+
module Git
|
|
7
|
+
module Organize
|
|
8
|
+
class ReferenceUpdate
|
|
9
|
+
enable_listable
|
|
10
|
+
lists.add_symbol :operation, :remove
|
|
11
|
+
|
|
12
|
+
common_constructor :repository, :reference, :operation
|
|
13
|
+
|
|
14
|
+
def run_operation
|
|
15
|
+
send("run_operation_#{operation}")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_s
|
|
19
|
+
"#{reference} [#{operation}]"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def reference_pathname
|
|
25
|
+
repository.refs_root.join(reference)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def run_operation_remove
|
|
29
|
+
reference_pathname.unlink
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
|
|
5
|
+
module Avm
|
|
6
|
+
module Git
|
|
7
|
+
module Organize
|
|
8
|
+
class Repository
|
|
9
|
+
enable_simple_cache
|
|
10
|
+
common_constructor :eac_git_local
|
|
11
|
+
|
|
12
|
+
def collected_references
|
|
13
|
+
@collected_references || []
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def collect_subrepos
|
|
17
|
+
collect_references_with_pattern(
|
|
18
|
+
%r{\Asubrepo/},
|
|
19
|
+
::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
|
|
20
|
+
)
|
|
21
|
+
collect_references_with_pattern(
|
|
22
|
+
%r{\Aheads/subrepo/},
|
|
23
|
+
::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def collect_originals
|
|
28
|
+
collect_references_with_pattern(
|
|
29
|
+
%r{\Aoriginal/},
|
|
30
|
+
::Avm::Git::Organize::ReferenceUpdate::OPERATION_REMOVE
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def all_branches
|
|
35
|
+
eac_git_local.execute!
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
delegate :to_s, to: :eac_git_local
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def all_references
|
|
43
|
+
::Pathname.glob("#{refs_root}/**/*").select(&:file?)
|
|
44
|
+
.map { |p| p.relative_path_from(refs_root).to_path }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def reference_update_by_ref(reference)
|
|
48
|
+
collected_references.find { |ru| ru.reference == reference }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def collect_reference(reference, operation)
|
|
52
|
+
new_ru = ::Avm::Git::Organize::ReferenceUpdate.new(self, reference, operation)
|
|
53
|
+
reference_update_by_ref(new_ru.reference).if_present do |ru_found|
|
|
54
|
+
raise "Reference #{new_ru} already added (#{ru_found})"
|
|
55
|
+
end
|
|
56
|
+
@collected_references ||= []
|
|
57
|
+
@collected_references << new_ru
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def collect_references_with_pattern(pattern, operation)
|
|
61
|
+
references_with_pattern(pattern).each do |reference|
|
|
62
|
+
collect_reference(reference, operation)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def references_with_pattern(pattern)
|
|
67
|
+
all_references.select { |reference| pattern.if_match(reference, false) }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def refs_root_uncached
|
|
71
|
+
eac_git_local.root_path / '.git' / 'refs'
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
require 'eac_ruby_utils/ruby'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module Git
|
|
8
|
+
class RevisionTest
|
|
9
|
+
enable_simple_cache
|
|
10
|
+
enable_speaker
|
|
11
|
+
common_constructor :git, :sha1, :options
|
|
12
|
+
|
|
13
|
+
def banner
|
|
14
|
+
infov 'Revision to test', sha1
|
|
15
|
+
::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' ')) do
|
|
16
|
+
revision_banner
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def successful_label
|
|
21
|
+
successful?.to_s.send((successful? ? :green : :red))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_s
|
|
25
|
+
sha1
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def successful?
|
|
29
|
+
successful
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def checkout_revision
|
|
35
|
+
infom 'Checking out revision...'
|
|
36
|
+
git.execute!('checkout', sha1)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def commit_uncached
|
|
40
|
+
::Avm::Git::Commit.new(git, sha1)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def git_absolute_path
|
|
44
|
+
::File.expand_path(git.to_s)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def revision_banner
|
|
48
|
+
infov '* Subject', commit.subject
|
|
49
|
+
infov '* Success?', successful_label
|
|
50
|
+
infov '* STDOUT', stdout_cache.content_path
|
|
51
|
+
infov '* STDERR', stderr_cache.content_path
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def root_cache
|
|
55
|
+
fs_cache.child(git_absolute_path.parameterize, sha1,
|
|
56
|
+
options.fetch(:test_command).to_s.parameterize)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def run_test
|
|
60
|
+
infom "Running test command \"#{::Shellwords.join(test_command_args)}\"" \
|
|
61
|
+
" on \"#{git_absolute_path}\"..."
|
|
62
|
+
result = ::EacRubyUtils::Ruby.on_clean_environment { test_command.execute }
|
|
63
|
+
infom 'Test done'
|
|
64
|
+
write_result_cache(result)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def stdout_cache
|
|
68
|
+
root_cache.child('stdout')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def stderr_cache
|
|
72
|
+
root_cache.child('stderr')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def successful_cache
|
|
76
|
+
root_cache.child('successful')
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def successful_uncached
|
|
80
|
+
if options.fetch(:no_cache) || !successful_cache.stored?
|
|
81
|
+
checkout_revision
|
|
82
|
+
run_test
|
|
83
|
+
end
|
|
84
|
+
successful_cache.read == 'true'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_command
|
|
88
|
+
::EacRubyUtils::Envs.local.command(*test_command_args).chdir(git.to_s)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_command_args
|
|
92
|
+
r = ::Shellwords.split(options.fetch(:test_command).to_s)
|
|
93
|
+
return r if r.any?
|
|
94
|
+
|
|
95
|
+
raise 'No command found'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def write_result_cache(result)
|
|
99
|
+
stdout_cache.write(result[:stdout])
|
|
100
|
+
stderr_cache.write(result[:stderr])
|
|
101
|
+
successful_cache.write(result[:exit_code].zero? ? 'true' : 'false')
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
|
|
5
|
+
module Avm
|
|
6
|
+
module Git
|
|
7
|
+
module Scms
|
|
8
|
+
class Git < ::Avm::Scms::Base
|
|
9
|
+
class ChangeTracker
|
|
10
|
+
common_constructor :git_scm, :message
|
|
11
|
+
attr_reader :starting_commit
|
|
12
|
+
delegate :git_repo, to: :git_scm
|
|
13
|
+
|
|
14
|
+
def start
|
|
15
|
+
raise 'Repository is dirty' if git_repo.dirty?
|
|
16
|
+
|
|
17
|
+
self.starting_commit = git_repo.head
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Avm::Git::Scms::Git::Commit, nil]
|
|
21
|
+
def stop
|
|
22
|
+
git_scm.commit_dirty
|
|
23
|
+
return nil if starting_commit == git_repo.head
|
|
24
|
+
|
|
25
|
+
git_scm.reset_and_commit(starting_commit, message)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_writer :starting_commit
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/scms/commit'
|
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module Git
|
|
8
|
+
module Scms
|
|
9
|
+
class Git < ::Avm::Scms::Base
|
|
10
|
+
class Commit < ::Avm::Scms::Commit
|
|
11
|
+
common_constructor :git_scm, :git_commit do
|
|
12
|
+
git_commit.assert_argument(::EacGit::Local::Commit, 'git_commit')
|
|
13
|
+
end
|
|
14
|
+
delegate :git_repo, to: :git_scm
|
|
15
|
+
|
|
16
|
+
# @return [Array<Pathname>]
|
|
17
|
+
def changed_files
|
|
18
|
+
git_commit.changed_files.map { |cf| cf.path.to_pathname }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @param other [Avm::Git::Scms::Git::Commit]
|
|
22
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
|
23
|
+
def merge_with(other)
|
|
24
|
+
validate_clean_and_head
|
|
25
|
+
raise 'Implemented for only if other is parent' unless
|
|
26
|
+
other.git_commit == git_commit.parent
|
|
27
|
+
|
|
28
|
+
git_scm.reset_and_commit(other.git_commit.parent, other.git_commit.raw_body)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def reword(new_message)
|
|
32
|
+
validate_clean_and_head
|
|
33
|
+
|
|
34
|
+
git_repo.command('commit', '--amend', '-m', new_message).execute!
|
|
35
|
+
self.class.new(git_scm, git_repo.head)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @param path [Pathname]
|
|
39
|
+
# @return [TrueClass,FalseClass]
|
|
40
|
+
def scm_file?(path)
|
|
41
|
+
%w[.gitrepo .gitmodules].any? { |file| file.include?(path.basename.to_path) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def validate_clean_and_head
|
|
47
|
+
raise 'Implemented for only if repository is no dirty' if git_repo.dirty?
|
|
48
|
+
raise 'Implemented for only if self is HEAD' unless
|
|
49
|
+
git_commit == git_repo.head
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/git/scms/git_subrepo'
|
|
4
|
+
require 'avm/scms/base'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module Git
|
|
9
|
+
module Scms
|
|
10
|
+
class Git < ::Avm::Scms::Base
|
|
11
|
+
require_sub __FILE__
|
|
12
|
+
include ::Comparable
|
|
13
|
+
|
|
14
|
+
COMMIT_DIRTY_DEFAULT_MESSAGE = 'Dirty files.'
|
|
15
|
+
|
|
16
|
+
def <=>(other)
|
|
17
|
+
git_repo <=> other.git_repo
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
|
21
|
+
def commitize(source)
|
|
22
|
+
if source.is_a?(::Avm::Git::Scms::Git::Commit)
|
|
23
|
+
return source if source.git_repo == self
|
|
24
|
+
|
|
25
|
+
raise 'Not same Git repository'
|
|
26
|
+
end
|
|
27
|
+
git_repo.commitize(source).if_present do |v|
|
|
28
|
+
::Avm::Git::Scms::Git::Commit.new(self, v)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
|
33
|
+
def commit_dirty(message = nil)
|
|
34
|
+
return nil unless git_repo.dirty?
|
|
35
|
+
|
|
36
|
+
git_repo.command('add', '.').execute!
|
|
37
|
+
git_repo.command('commit', '-m',
|
|
38
|
+
message.call_if_proc.if_present(COMMIT_DIRTY_DEFAULT_MESSAGE)).execute!
|
|
39
|
+
commitize(git_repo.head)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @return [Avm::Git::Scms::Git::Commit,nil]
|
|
43
|
+
def commit_if_change(message = nil)
|
|
44
|
+
tracker = ::Avm::Git::Scms::Git::ChangeTracker.new(self, message)
|
|
45
|
+
tracker.start
|
|
46
|
+
yield
|
|
47
|
+
tracker.stop
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def git_repo
|
|
51
|
+
@git_repo ||= ::EacGit::Local.new(path)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# @return [Avm::Git::Scms::Git::Commit]
|
|
55
|
+
def reset_and_commit(commit_to_reset, message)
|
|
56
|
+
git_repo.command('reset', '--soft', commitize(commit_to_reset).git_commit.id).execute!
|
|
57
|
+
commit_dirty(message)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Enumerable<Avm::Git::Scms::GitSubrepo>]
|
|
61
|
+
def subs
|
|
62
|
+
git_repo.subrepos.map do |subrepo|
|
|
63
|
+
::Avm::Git::Scms::GitSubrepo.new(subrepo.subpath.expand_path(path))
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def valid?
|
|
68
|
+
path.join('.git').exist?
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/scms/base'
|
|
4
|
+
require 'eac_git/local'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module Git
|
|
9
|
+
module Scms
|
|
10
|
+
class GitSubrepo < ::Avm::Scms::Base
|
|
11
|
+
delegate :commit_if_change, to: :parent_scm
|
|
12
|
+
|
|
13
|
+
def update
|
|
14
|
+
git_subrepo.command('clean').execute!
|
|
15
|
+
git_subrepo.command('pull').execute!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [EacGit::Local]
|
|
19
|
+
def git_repo
|
|
20
|
+
@git_repo ||= ::EacGit::Local.find(path)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [EacGit::Local::Subrepo]
|
|
24
|
+
def git_subrepo
|
|
25
|
+
@git_subrepo ||= git_repo.subrepo(subpath)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [Pathname]
|
|
29
|
+
def subpath
|
|
30
|
+
path.expand_path.relative_path_from(git_repo.root_path.expand_path)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def valid?
|
|
34
|
+
path.join('.gitrepo').file?
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/git/scms/git'
|
|
4
|
+
require 'avm/git/scms/git_subrepo'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module Git
|
|
9
|
+
module Scms
|
|
10
|
+
class Provider
|
|
11
|
+
SCMS = [::Avm::Git::Scms::Git, ::Avm::Git::Scms::GitSubrepo].freeze
|
|
12
|
+
|
|
13
|
+
def all
|
|
14
|
+
SCMS
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/result'
|
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module Git
|
|
8
|
+
class SubrepoCheck
|
|
9
|
+
module Parent
|
|
10
|
+
def fix_parent
|
|
11
|
+
return if parent_result.success?
|
|
12
|
+
|
|
13
|
+
info(' Fixing...')
|
|
14
|
+
self.parent_hash = expected_parent_hash
|
|
15
|
+
info_banner
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def expected_parent_hash_uncached
|
|
21
|
+
subrepo.local.rev_parse("#{last_file_change_rev}^")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def last_file_change_rev
|
|
25
|
+
subrepo.local.command('log', '-n', '1', '--pretty=format:%H', '--',
|
|
26
|
+
subrepo.config_relative_path.to_path).execute!.strip
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def parent_hash
|
|
30
|
+
subrepo.parent_commit_id
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def parent_hash=(new_hash)
|
|
34
|
+
subrepo.config.parent_commit_id = new_hash
|
|
35
|
+
subrepo.write_config
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def parent_hash_ok?
|
|
39
|
+
return false if expected_parent_hash.blank? || parent_hash.blank?
|
|
40
|
+
|
|
41
|
+
expected_parent_hash == parent_hash
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def parent_result_uncached
|
|
45
|
+
::Avm::Result.success_or_error(parent_hash_ok?,
|
|
46
|
+
parent_hash.presence || blank_text)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|