avm-tools 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm.rb +1 -0
- data/lib/avm/executables.rb +17 -0
- data/lib/avm/git/commit/deploy.rb +81 -0
- data/lib/avm/git/spec_helper.rb +57 -0
- data/lib/avm/patches/eac_launcher_git_base.rb +5 -0
- data/lib/avm/tools/runner/git.rb +5 -0
- data/lib/avm/tools/runner/git/commit.rb +1 -2
- data/lib/avm/tools/runner/git/deploy.rb +73 -0
- data/lib/avm/tools/runner/git/issue/complete.rb +1 -2
- data/lib/avm/tools/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e397269b3172cef0af4f83f2c7276fb9dcb51c6d457f7278940701c473d41402
|
4
|
+
data.tar.gz: 20797859192beecaaafba3f3af1d6c70fb538248b836611d1a37425e43920c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8114b94bf8609107a002aaf93f99f70594f12ccdb92e009f8a86d28e2a41a1e3853f9adf877eca5e1fa2d120fb23e8ec8bb814123eae80770d62ecf0dfbd3a22
|
7
|
+
data.tar.gz: bac5f7db55ac67de51619596789953161386565bc19ceed6bc3537a6cb9f034e1ab365d7eff0c86eebf1a049bd5a55d281867977e622e539d4cbbd2df2f2e833
|
data/lib/avm.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/envs'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Executables
|
7
|
+
class << self
|
8
|
+
def env
|
9
|
+
::EacRubyUtils::Envs.local
|
10
|
+
end
|
11
|
+
|
12
|
+
def git
|
13
|
+
@git ||= env.executable('git', '--version')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'eac_ruby_utils/require_sub'
|
6
|
+
::EacRubyUtils.require_sub(__FILE__)
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module Git
|
10
|
+
class Commit
|
11
|
+
class << self
|
12
|
+
def target_url_to_env_path(target_url)
|
13
|
+
uri = ::Addressable::URI.parse(target_url)
|
14
|
+
uri.scheme = 'file' if uri.scheme.blank?
|
15
|
+
[uri_to_env(uri), uri.path]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def uri_to_env(uri)
|
21
|
+
case uri.scheme
|
22
|
+
when 'file' then ::EacRubyUtils::Envs.local
|
23
|
+
when 'ssh' then ::EacRubyUtils::Envs.ssh(uri.authority)
|
24
|
+
else "Invalid schema \"#{uri.schema}\" (URI: #{uri})"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def deploy_to_env_path(target_env, target_path)
|
30
|
+
Deploy.new(self, target_env, target_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def deploy_to_url(target_url)
|
34
|
+
Deploy.new(self, *self.class.target_url_to_env_path(target_url))
|
35
|
+
end
|
36
|
+
|
37
|
+
class Deploy
|
38
|
+
include ::EacRubyUtils::SimpleCache
|
39
|
+
|
40
|
+
attr_reader :commit, :target_env, :target_path
|
41
|
+
|
42
|
+
def initialize(commit, target_env, target_path)
|
43
|
+
@commit = commit
|
44
|
+
@target_env = target_env
|
45
|
+
@target_path = target_path
|
46
|
+
run
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def run
|
52
|
+
mkdir_target
|
53
|
+
clear_content
|
54
|
+
send_untar_package
|
55
|
+
end
|
56
|
+
|
57
|
+
def mkdir_target
|
58
|
+
target_env.command('mkdir', '-p', target_path).execute!
|
59
|
+
end
|
60
|
+
|
61
|
+
def clear_content
|
62
|
+
target_env.command(
|
63
|
+
'find', target_path, '-mindepth', 1, '-exec', 'rm', '-rf', '{}', ';'
|
64
|
+
).execute!
|
65
|
+
end
|
66
|
+
|
67
|
+
def send_untar_package
|
68
|
+
git_archive_command.pipe(untar_command).execute!
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_archive_command
|
72
|
+
commit.git.command('archive', '--format=tar', commit.sha1)
|
73
|
+
end
|
74
|
+
|
75
|
+
def untar_command
|
76
|
+
target_env.command('tar', '-xf', '-', '-C', target_path)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/envs'
|
4
|
+
require 'eac_launcher/git/base'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module Git
|
10
|
+
module SpecHelper
|
11
|
+
def stubbed_git_repository(bare = false)
|
12
|
+
path = ::Dir.mktmpdir
|
13
|
+
::EacRubyUtils::Envs.local.command(stubbed_git_repository_args(path, bare)).execute!
|
14
|
+
StubbedGitRepository.new(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def stubbed_git_repository_args(path, bare)
|
20
|
+
r = %w[git init]
|
21
|
+
r << '--bare' if bare
|
22
|
+
r + [path]
|
23
|
+
end
|
24
|
+
|
25
|
+
class StubbedGitRepository < ::EacLauncher::Git::Base
|
26
|
+
def file(*subpath)
|
27
|
+
StubbedGitRepositoryFile.new(self, subpath)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class StubbedGitRepositoryFile
|
32
|
+
attr_reader :git, :subpath
|
33
|
+
|
34
|
+
def initialize(git, subpath)
|
35
|
+
@git = git
|
36
|
+
@subpath = subpath
|
37
|
+
end
|
38
|
+
|
39
|
+
def path
|
40
|
+
::File.join(git, *subpath)
|
41
|
+
end
|
42
|
+
|
43
|
+
def touch
|
44
|
+
::FileUtils.touch(path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete
|
48
|
+
::File.unlink(path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def write(content)
|
52
|
+
::File.write(path, content)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/avm/tools/runner/git.rb
CHANGED
@@ -24,7 +24,6 @@ module Avm
|
|
24
24
|
|
25
25
|
Options:
|
26
26
|
-h --help Mostra esta ajuda.
|
27
|
-
-C <git-local> Caminho do repositório local [default: .].
|
28
27
|
-f --files Mostra os arquivos.
|
29
28
|
-s --size Mostra o tamanho de arquivos.
|
30
29
|
DOCOPT
|
@@ -87,7 +86,7 @@ module Avm
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def git_uncached
|
90
|
-
::EacLauncher::Git::Base.new(
|
89
|
+
::EacLauncher::Git::Base.new(context(:repository_path))
|
91
90
|
end
|
92
91
|
|
93
92
|
def commit_uncached
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
4
|
+
require 'eac_ruby_utils/console/speaker'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
require 'eac_launcher/git/base'
|
7
|
+
require 'avm/git/commit'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module Tools
|
11
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Git < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
class Deploy < ::EacRubyUtils::Console::DocoptRunner
|
14
|
+
include ::EacRubyUtils::SimpleCache
|
15
|
+
include ::EacRubyUtils::Console::Speaker
|
16
|
+
|
17
|
+
DOC = <<~DOCOPT
|
18
|
+
Deploy a Git revision to a location (Local or remote).
|
19
|
+
|
20
|
+
Usage:
|
21
|
+
__PROGRAM__ [options] <target-url>
|
22
|
+
__PROGRAM__ -h | --help
|
23
|
+
|
24
|
+
Options:
|
25
|
+
-h --help Mostra esta ajuda.
|
26
|
+
-r --reference=<reference> Reference [default: HEAD].
|
27
|
+
DOCOPT
|
28
|
+
|
29
|
+
def run
|
30
|
+
input_banner
|
31
|
+
validate
|
32
|
+
main_info_banner
|
33
|
+
deploy
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def input_banner
|
39
|
+
infov 'Repository', git
|
40
|
+
infov 'Reference', reference
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate
|
44
|
+
return if reference_sha1.present?
|
45
|
+
|
46
|
+
fatal_error "Object ID not found for reference \"#{reference}\""
|
47
|
+
end
|
48
|
+
|
49
|
+
def main_info_banner
|
50
|
+
infov 'Reference SHA1', reference_sha1
|
51
|
+
end
|
52
|
+
|
53
|
+
def reference_sha1_uncached
|
54
|
+
git.rev_parse(reference)
|
55
|
+
end
|
56
|
+
|
57
|
+
def reference
|
58
|
+
options.fetch('--reference')
|
59
|
+
end
|
60
|
+
|
61
|
+
def git_uncached
|
62
|
+
::EacLauncher::Git::Base.new(context(:repository_path))
|
63
|
+
end
|
64
|
+
|
65
|
+
def deploy
|
66
|
+
commit = ::Avm::Git::Commit.new(git, reference_sha1)
|
67
|
+
commit.deploy_to_url(options.fetch('<target-url>'))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -21,7 +21,6 @@ module Avm
|
|
21
21
|
|
22
22
|
Options:
|
23
23
|
-h --help Show this screen.
|
24
|
-
-C <path> Path to Git repository [default: .].
|
25
24
|
-B --no-validate-branch Does not validate branch/tag name.
|
26
25
|
-y --yes Does not ask for user confirmation.
|
27
26
|
DOCOPT
|
@@ -40,7 +39,7 @@ module Avm
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def git_complete_issue_options
|
43
|
-
{ dir:
|
42
|
+
{ dir: context(:repository_path),
|
44
43
|
no_validate_branch: options.fetch('--no-validate-branch') }
|
45
44
|
end
|
46
45
|
end
|
data/lib/avm/tools/version.rb
CHANGED
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.
|
4
|
+
version: 0.14.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: 2019-
|
11
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -76,14 +76,14 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '0.
|
79
|
+
version: '0.13'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '0.
|
86
|
+
version: '0.13'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: filesize
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,10 +179,12 @@ files:
|
|
179
179
|
- lib/avm/data/package/dump.rb
|
180
180
|
- lib/avm/data/package/load.rb
|
181
181
|
- lib/avm/data/unit.rb
|
182
|
+
- lib/avm/executables.rb
|
182
183
|
- lib/avm/files.rb
|
183
184
|
- lib/avm/files/rotate.rb
|
184
185
|
- lib/avm/git.rb
|
185
186
|
- lib/avm/git/commit.rb
|
187
|
+
- lib/avm/git/commit/deploy.rb
|
186
188
|
- lib/avm/git/commit/diff_tree_line.rb
|
187
189
|
- lib/avm/git/commit/file.rb
|
188
190
|
- lib/avm/git/issue.rb
|
@@ -194,6 +196,7 @@ files:
|
|
194
196
|
- lib/avm/git/issue/complete/_remote.rb
|
195
197
|
- lib/avm/git/issue/complete/_tracker.rb
|
196
198
|
- lib/avm/git/issue/complete/_validations.rb
|
199
|
+
- lib/avm/git/spec_helper.rb
|
197
200
|
- lib/avm/instances.rb
|
198
201
|
- lib/avm/instances/application.rb
|
199
202
|
- lib/avm/instances/base.rb
|
@@ -219,6 +222,7 @@ files:
|
|
219
222
|
- lib/avm/tools/runner/files/rotate.rb
|
220
223
|
- lib/avm/tools/runner/git.rb
|
221
224
|
- lib/avm/tools/runner/git/commit.rb
|
225
|
+
- lib/avm/tools/runner/git/deploy.rb
|
222
226
|
- lib/avm/tools/runner/git/issue.rb
|
223
227
|
- lib/avm/tools/runner/git/issue/complete.rb
|
224
228
|
- lib/avm/tools/version.rb
|