avm-git 0.6.0 → 0.7.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: e686cce8a98220b2633e53cf617745991d691b3a60f0bd78a45ea5b476adff29
4
- data.tar.gz: e75397ee7ea44aa0c1dec4fbf3b9ec638e25312cb5288ac9627662f66d69bedb
3
+ metadata.gz: b1b4c7e2df892e08fd3acc46995c6c353476d2f278dbea6d7f4f6610f59c147d
4
+ data.tar.gz: abfc3a667d26edfd434b471314772e14df09a54fb3c5921cad56c51f2361d400
5
5
  SHA512:
6
- metadata.gz: b4a4dd2cf8276aa921df11aeb99cc9bfe92a63f0a29281b444b1a3e5eb1a3418bd49297b960451aa5777e27d68f2648b0ffac1f7e82dcb63a3b5d7dcfa05ae85
7
- data.tar.gz: 0cb57e3027c6f997360ae1b68ef573fbe356e0226c2f14968152497233bd0b136f3e04880242bff64c38185512a53aca68a8ca73ec667f0da69c2c34cc98c615
6
+ metadata.gz: df7fdde7ab8665aec13a8c1d89279de503a75dc034122c0cfd4b907056741631d834876745431c006ef474107e99075aaf3a3080e700a8d0526d5f4b3afaf110
7
+ data.tar.gz: a575f67380e389681bbbe28e7d1f738b43eda8d8b2a8578117ba52f2d14d215afe510e6edb4c3fd57f302c0ae5b247eff4cdb188518b8b4eea1c95d67cee6255
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/launcher/errors/base'
4
+
3
5
  module Avm
4
6
  module Git
5
7
  module Launcher
6
- class Error < StandardError
8
+ class Error < ::Avm::Launcher::Errors::Base
7
9
  def initialize(git_instance, message)
8
10
  super("#{message} (Repository: #{git_instance})")
9
11
  end
@@ -3,7 +3,7 @@
3
3
  require 'avm/git/launcher/mirror_update'
4
4
  require 'avm/launcher/instances/error'
5
5
  require 'avm/git/vendor/github'
6
- require 'avm/projects/stereotypes/git/publish'
6
+ require 'avm/git/launcher_stereotypes/git/publish'
7
7
 
8
8
  module Avm
9
9
  module Git
@@ -15,7 +15,7 @@ module Avm
15
15
  class WarpBase < ::Avm::Launcher::Paths::Real
16
16
  include ::EacRubyUtils::SimpleCache
17
17
 
18
- TARGET_REMOTE = ::Avm::Projects::Stereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
18
+ TARGET_REMOTE = ::Avm::Git::LauncherStereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
19
19
 
20
20
  def initialize(instance)
21
21
  @instance = instance
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/local'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ module LauncherStereotypes
9
+ class Git
10
+ module LocalProjectMixin
11
+ # @return [EacGit::Local]
12
+ def git_repo
13
+ @git_repo ||= ::EacGit::Local.new(path)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/publish_base'
4
+
5
+ module Avm
6
+ module Git
7
+ module LauncherStereotypes
8
+ class Git
9
+ class Publish < ::Avm::Git::Launcher::PublishBase
10
+ PUBLISH_GIT_REMOTE_NAME = 'publish'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/warp_base'
4
+
5
+ module Avm
6
+ module Git
7
+ module LauncherStereotypes
8
+ class Git
9
+ class Warp < ::Avm::Git::Launcher::WarpBase
10
+ private
11
+
12
+ def current_ref
13
+ 'HEAD'
14
+ end
15
+
16
+ def source_instance
17
+ instance
18
+ end
19
+
20
+ def source_remote_name
21
+ ::Avm::Git::LauncherStereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/stereotype'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Git
8
+ module LauncherStereotypes
9
+ class Git
10
+ require_sub __FILE__
11
+ include Avm::Launcher::Stereotype
12
+
13
+ class << self
14
+ def match?(path)
15
+ File.directory?(path.real.subpath('.git'))
16
+ end
17
+
18
+ def color
19
+ :white
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/publish_base'
4
+
5
+ module Avm
6
+ module Git
7
+ module LauncherStereotypes
8
+ class GitSubrepo
9
+ class Publish < ::Avm::Git::Launcher::PublishBase
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+ require 'avm/git/launcher/sub_warp_base'
5
+ require 'avm/launcher/errors/base'
6
+ require 'avm/launcher/paths/real'
7
+ require 'avm/git/vendor/github'
8
+
9
+ module Avm
10
+ module Git
11
+ module LauncherStereotypes
12
+ class GitSubrepo
13
+ class Warp < ::Avm::Launcher::Paths::Real
14
+ include ::Avm::Git::Launcher::SubWarpBase
15
+ include ::EacRubyUtils::SimpleCache
16
+
17
+ attr_reader :instance
18
+
19
+ def initialize(instance)
20
+ @instance = instance
21
+ check_parent
22
+ init_aux
23
+ push_to_aux
24
+ reset
25
+ assert_target_remote
26
+ super(warped_git)
27
+ end
28
+
29
+ private
30
+
31
+ def check_parent
32
+ return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
33
+ parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
34
+
35
+ raise Avm::Launcher::Errors::Base,
36
+ "Subrepo parent hash \"#{subrepo_parent_hash}\"" \
37
+ " not found in \"#{parent_git_warped}\""
38
+ end
39
+
40
+ def subrepo_parent_hash
41
+ data = parent_git_warped.subrepo_status(to_parent_git_path)
42
+ h = data['Pull Parent']
43
+ return h if h.present?
44
+
45
+ raise Avm::Launcher::Errors::Base, "Subrepo parent hash is blank: #{data}"
46
+ end
47
+
48
+ def init_aux
49
+ ::Avm::Git::Launcher::Base.new(aux_path).init_bare
50
+ end
51
+
52
+ def parent_git_warped_uncached
53
+ ::Avm::Git::Launcher::Base.new(parent_instance.warped)
54
+ end
55
+
56
+ def aux_path
57
+ instance.cache_path('subrepo_aux_git_repository')
58
+ end
59
+
60
+ def warped_git_uncached
61
+ ::Avm::Git::Launcher::Base.new(instance.cache_path('git_repository'))
62
+ end
63
+
64
+ def push_to_aux
65
+ parent_git_warped.execute!('subrepo', 'branch', to_parent_git_path, '-fF')
66
+ h = parent_git_warped.rev_parse("subrepo/#{to_parent_git_path}", true)
67
+ parent_git_warped.execute!('push', aux_path, "#{h}:refs/heads/master", '--force')
68
+ end
69
+
70
+ def reset
71
+ ::Avm::Git::Launcher::MirrorUpdate.new(warped_git, aux_path, 'master')
72
+ end
73
+
74
+ def assert_target_remote
75
+ warped_git.assert_remote_url(::Avm::Git::Launcher::WarpBase::TARGET_REMOTE,
76
+ target_remote_url)
77
+ end
78
+
79
+ def target_remote_url
80
+ ::Avm::Git::Vendor::Github.to_ssh_url(
81
+ parent_git_warped.subrepo_remote_url(to_parent_git_path)
82
+ )
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/error'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'avm/launcher/stereotype'
6
+
7
+ module Avm
8
+ module Git
9
+ module LauncherStereotypes
10
+ class GitSubrepo
11
+ require_sub __FILE__
12
+ include Avm::Launcher::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ File.exist?(path.real.subpath('.gitrepo')) && subrepo_url(path.real) != 'none'
17
+ end
18
+
19
+ def color
20
+ :light_cyan
21
+ end
22
+
23
+ def subrepo_url(path)
24
+ File.read(path.subpath('.gitrepo')).each_line do |l|
25
+ m = /remote\s*=\s(.+)/.match(l)
26
+ return m[1] if m
27
+ end
28
+ raise ::Avm::Git::Launcher::Error.new(path, '"remote = ... " not found')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/publish_base'
4
+
5
+ module Avm
6
+ module Git
7
+ module LauncherStereotypes
8
+ class GitSubtree
9
+ class Publish < ::Avm::Git::Launcher::PublishBase
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/warp_base'
4
+ require 'avm/git/launcher/sub_warp_base'
5
+
6
+ module Avm
7
+ module Git
8
+ module LauncherStereotypes
9
+ class GitSubtree
10
+ class Warp < ::Avm::Git::Launcher::WarpBase
11
+ include ::Avm::Git::Launcher::SubWarpBase
12
+
13
+ private
14
+
15
+ def current_ref
16
+ instance.cache_key("git_subtree.parent.#{cache_git.git.object('HEAD').sha}") do
17
+ cache_git.subtree_split(to_parent_git_path)
18
+ end
19
+ end
20
+
21
+ def source_instance
22
+ parent_instance
23
+ end
24
+
25
+ def source_remote_name
26
+ instance.project_name
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/stereotype'
4
+ require 'avm/git/launcher_stereotypes/git'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Git
9
+ module LauncherStereotypes
10
+ class GitSubtree
11
+ require_sub __FILE__
12
+ include Avm::Launcher::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ return false if other_git_stereotype?(path)
17
+ return false unless other_nogit_stereotype?(path)
18
+
19
+ parent = parent_git(path.parent_path)
20
+ return false unless parent
21
+
22
+ ::Git.open(parent.real).remote(path.real.basename).url ? true : false
23
+ end
24
+
25
+ def color
26
+ :green
27
+ end
28
+
29
+ def parent_git(parent_path)
30
+ return nil unless parent_path
31
+
32
+ if ::Avm::Git::LauncherStereotypes::Git.match?(parent_path)
33
+ parent_path
34
+ else
35
+ parent_git(parent_path.parent_path)
36
+ end
37
+ end
38
+
39
+ def other_git_stereotype?(path)
40
+ ::Avm::Git::LauncherStereotypes::Git.match?(path) ||
41
+ ::Avm::Git::LauncherStereotypes::GitSubrepo.match?(path)
42
+ end
43
+
44
+ def other_nogit_stereotype?(path)
45
+ Avm::Launcher::Stereotype.nogit_stereotypes.any? { |s| s.match?(path) }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher_stereotypes/git'
4
+ require 'avm/git/launcher_stereotypes/git_subrepo'
5
+ require 'avm/git/launcher_stereotypes/git_subtree'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module Git
10
+ module LauncherStereotypes
11
+ class Provider
12
+ STEREOTYPES = [::Avm::Git::LauncherStereotypes::Git,
13
+ ::Avm::Git::LauncherStereotypes::GitSubrepo,
14
+ ::Avm::Git::LauncherStereotypes::GitSubtree].freeze
15
+
16
+ def all
17
+ STEREOTYPES
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module LauncherStereotypes
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Git
5
- VERSION = '0.6.0'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-11 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.48'
19
+ version: '0.49'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.48'
26
+ version: '0.49'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-files
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +78,20 @@ dependencies:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0.104'
81
+ - !ruby/object:Gem::Dependency
82
+ name: git
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.12'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.12'
81
95
  - !ruby/object:Gem::Dependency
82
96
  name: aranha-parsers
83
97
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +177,18 @@ files:
163
177
  - lib/avm/git/launcher/remote.rb
164
178
  - lib/avm/git/launcher/sub_warp_base.rb
165
179
  - lib/avm/git/launcher/warp_base.rb
180
+ - lib/avm/git/launcher_stereotypes.rb
181
+ - lib/avm/git/launcher_stereotypes/git.rb
182
+ - lib/avm/git/launcher_stereotypes/git/local_project_mixin.rb
183
+ - lib/avm/git/launcher_stereotypes/git/publish.rb
184
+ - lib/avm/git/launcher_stereotypes/git/warp.rb
185
+ - lib/avm/git/launcher_stereotypes/git_subrepo.rb
186
+ - lib/avm/git/launcher_stereotypes/git_subrepo/publish.rb
187
+ - lib/avm/git/launcher_stereotypes/git_subrepo/warp.rb
188
+ - lib/avm/git/launcher_stereotypes/git_subtree.rb
189
+ - lib/avm/git/launcher_stereotypes/git_subtree/publish.rb
190
+ - lib/avm/git/launcher_stereotypes/git_subtree/warp.rb
191
+ - lib/avm/git/launcher_stereotypes/provider.rb
166
192
  - lib/avm/git/organize.rb
167
193
  - lib/avm/git/organize/reference_update.rb
168
194
  - lib/avm/git/organize/repository.rb