avm-git 0.1.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/git/issue/complete/commits.rb +3 -3
- data/lib/avm/git/issue/complete/git_subrepos.rb +1 -1
- data/lib/avm/git/issue/complete/local_branch.rb +13 -6
- data/lib/avm/git/issue/complete/local_tag.rb +3 -3
- data/lib/avm/git/issue/complete/push.rb +15 -9
- data/lib/avm/git/issue/complete/remote.rb +2 -2
- data/lib/avm/git/issue/complete/test.rb +15 -20
- data/lib/avm/git/issue/complete/tracker.rb +1 -1
- data/lib/avm/git/issue/complete/validation.rb +13 -5
- data/lib/avm/git/issue/complete/working_tree.rb +1 -1
- data/lib/avm/git/issue/complete.rb +22 -7
- data/lib/avm/git/revision_test.rb +1 -1
- data/lib/avm/git/scms/git.rb +8 -0
- data/lib/avm/git/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d460b71bec0badf0833da7e9d2f0fe66c943adf3962a5dc2b596bec89dc224c7
|
4
|
+
data.tar.gz: 69d2042b3b4dec08fc08695d78216121f0e5a4c5b85234d238e8dff549394418
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d4e10c843fc8bd92befea6a35ba9d6160fcdc681e7a8488ac2f6004ed7de7d1229f55f692106211cc2ede750db1b2635bd7bcd1773a42a6c4c7f43f659def7
|
7
|
+
data.tar.gz: cc56195fd73c5e6457ee1186d146b23138e0ec7e0d52271f4fca11f188480d23ee08158364040727a4acb2f5a2895346dd7013acb7871effb15478761b66c94b
|
@@ -15,7 +15,7 @@ module Avm
|
|
15
15
|
return [] unless branch_hash && follow_master?
|
16
16
|
|
17
17
|
interval = remote_master_hash ? "#{remote_master_hash}..#{branch_hash}" : branch_hash
|
18
|
-
|
18
|
+
launcher_git.execute!('rev-list', interval).each_line.map(&:strip)
|
19
19
|
end
|
20
20
|
|
21
21
|
def bifurcations_result
|
@@ -32,8 +32,8 @@ module Avm
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def commit_parents(commit)
|
35
|
-
|
36
|
-
|
35
|
+
launcher_git.execute!('log', '--pretty=%P', '-n', '1', commit).split(' ').map(&:strip)
|
36
|
+
.select(&:present?)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -12,7 +12,7 @@ module Avm
|
|
12
12
|
return ::Avm::Result.error('Unclean workspace') unless clean_workspace?
|
13
13
|
|
14
14
|
infom 'Checking Git subrepos...'
|
15
|
-
r = ::Avm::Git::SubrepoChecks.new(::EacGit::Local.new(
|
15
|
+
r = ::Avm::Git::SubrepoChecks.new(::EacGit::Local.new(launcher_git)).add_all_subrepos
|
16
16
|
r.check_remote = true
|
17
17
|
r.result
|
18
18
|
end
|
@@ -7,16 +7,21 @@ module Avm
|
|
7
7
|
module Issue
|
8
8
|
class Complete
|
9
9
|
module LocalBranch
|
10
|
+
NO_CURRENT_BRANCH_NAME = 'none'
|
11
|
+
|
12
|
+
# Retrieves the current local branch.
|
13
|
+
#
|
14
|
+
# @return [EacGit::Local::Branch, nil]
|
10
15
|
def branch_uncached
|
11
|
-
|
16
|
+
eac_git.current_branch
|
12
17
|
end
|
13
18
|
|
14
19
|
def branch_hash_uncached
|
15
|
-
|
20
|
+
branch.if_present(&:current_commit_id)
|
16
21
|
end
|
17
22
|
|
18
23
|
def branch_name
|
19
|
-
branch.
|
24
|
+
branch.if_present(NO_CURRENT_BRANCH_NAME, &:name)
|
20
25
|
end
|
21
26
|
|
22
27
|
def branch_name_result
|
@@ -38,14 +43,16 @@ module Avm
|
|
38
43
|
end
|
39
44
|
|
40
45
|
def follow_master?
|
41
|
-
remote_master_hash ?
|
46
|
+
remote_master_hash ? launcher_git.descendant?(branch_hash, remote_master_hash) : true
|
42
47
|
end
|
43
48
|
|
44
49
|
def remove_local_branch
|
50
|
+
return unless branch
|
51
|
+
|
45
52
|
info 'Removendo branch local...'
|
46
53
|
bn = branch_name
|
47
|
-
|
48
|
-
|
54
|
+
git_execute(['checkout', branch_hash])
|
55
|
+
git_execute(['branch', '-D', bn])
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
@@ -18,7 +18,7 @@ module Avm
|
|
18
18
|
|
19
19
|
def delete_tag
|
20
20
|
info 'Removendo tag...'
|
21
|
-
|
21
|
+
git_execute(['tag', '-d', branch_name])
|
22
22
|
end
|
23
23
|
|
24
24
|
def tag
|
@@ -26,11 +26,11 @@ module Avm
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def tag_hash
|
29
|
-
|
29
|
+
launcher_git.rev_parse(tag)
|
30
30
|
end
|
31
31
|
|
32
32
|
def create_tag
|
33
|
-
|
33
|
+
git_execute(['tag', branch_name, branch_hash])
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -12,13 +12,7 @@ module Avm
|
|
12
12
|
def dry_push_result
|
13
13
|
return ::Avm::Result.error('Nothing to push') if pushs.empty?
|
14
14
|
|
15
|
-
|
16
|
-
message = if r.fetch(:exit_code).zero?
|
17
|
-
'ok'
|
18
|
-
else
|
19
|
-
r.fetch(:stderr) + "\n#{::Shellwords.join(dry_push_args)}"
|
20
|
-
end
|
21
|
-
::Avm::Result.success_or_error(r.fetch(:exit_code).zero?, message)
|
15
|
+
dry_push_execution_result
|
22
16
|
end
|
23
17
|
|
24
18
|
def push
|
@@ -26,7 +20,7 @@ module Avm
|
|
26
20
|
info 'PUSH: Nada a enviar'
|
27
21
|
else
|
28
22
|
info "PUSH: enviando \"#{pushs}\"..."
|
29
|
-
|
23
|
+
git_execute(%w[push origin] + pushs)
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
@@ -39,7 +33,7 @@ module Avm
|
|
39
33
|
end
|
40
34
|
|
41
35
|
def remove_branch_push
|
42
|
-
remote_branch_hash ? ":refs/heads/#{branch}" : nil
|
36
|
+
remote_branch_hash ? ":refs/heads/#{branch.name}" : nil
|
43
37
|
end
|
44
38
|
|
45
39
|
def tag_push
|
@@ -47,6 +41,18 @@ module Avm
|
|
47
41
|
|
48
42
|
"#{branch_hash}:#{tag}"
|
49
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def dry_push_execution_result
|
48
|
+
r = launcher_git.execute(dry_push_args)
|
49
|
+
message = if r.fetch(:exit_code).zero?
|
50
|
+
'ok'
|
51
|
+
else
|
52
|
+
r.fetch(:stderr) + "\n#{::Shellwords.join(dry_push_args)}"
|
53
|
+
end
|
54
|
+
::Avm::Result.success_or_error(r.fetch(:exit_code).zero?, message)
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
@@ -10,7 +10,7 @@ module Avm
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def remote_branch_hash
|
13
|
-
remote_hashs["refs/heads/#{branch}"]
|
13
|
+
remote_hashs["refs/heads/#{branch.name}"]
|
14
14
|
end
|
15
15
|
|
16
16
|
def remote_tag_hash
|
@@ -24,7 +24,7 @@ module Avm
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def remote_hashs_uncached
|
27
|
-
|
27
|
+
launcher_git.remote_hashs(remote_name)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'avm/sources/configuration'
|
4
4
|
require 'avm/result'
|
5
|
+
require 'avm/sources/base'
|
6
|
+
require 'avm/sources/tests/builder'
|
5
7
|
require 'eac_ruby_utils/fs/temp'
|
6
8
|
|
7
9
|
module Avm
|
@@ -10,33 +12,26 @@ module Avm
|
|
10
12
|
class Complete
|
11
13
|
module Test
|
12
14
|
def test_result
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
infom "Running test command \"#{test_command}\"..."
|
17
|
-
result = test_command.execute
|
18
|
-
test_result_log(result)
|
19
|
-
if result.fetch(:exit_code).zero?
|
20
|
-
::Avm::Result.success('yes')
|
21
|
-
else
|
22
|
-
::Avm::Result.error('no')
|
15
|
+
infom 'Running tests...'
|
16
|
+
test_performer.units.each do |single|
|
17
|
+
return ::Avm::Result.error(test_failed_result_message(single)) if single.failed?
|
23
18
|
end
|
19
|
+
::Avm::Result.success('all passed')
|
24
20
|
end
|
25
21
|
|
26
22
|
private
|
27
23
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
stdout_file.write(result.fetch(:stdout))
|
32
|
-
stderr_file.write(result.fetch(:stderr))
|
33
|
-
infov ' * Exit code', result.fetch(:exit_code)
|
34
|
-
infov ' * STDOUT', stdout_file.to_path
|
35
|
-
infov ' * STDERR', stderr_file.to_path
|
24
|
+
def test_failed_result_message(single)
|
25
|
+
{ 'Source' => single, 'STDOUT' => single.logs[:stdout],
|
26
|
+
'STDERR' => single.logs[:stderr] }.map { |k, v| "#{k}: #{v}" }.join(', ')
|
36
27
|
end
|
37
28
|
|
38
|
-
def
|
39
|
-
::Avm::Sources::
|
29
|
+
def test_performer
|
30
|
+
::Avm::Sources::Tests::Builder
|
31
|
+
.new(::Avm::Registry.sources.detect(launcher_git))
|
32
|
+
.include_main(true)
|
33
|
+
.include_subs(true)
|
34
|
+
.performer
|
40
35
|
end
|
41
36
|
end
|
42
37
|
end
|
@@ -11,6 +11,8 @@ module Avm
|
|
11
11
|
enable_simple_cache
|
12
12
|
common_constructor :parent, :key, :label
|
13
13
|
|
14
|
+
SKIPPED_RESULT_MESSAGE = 'skipped'
|
15
|
+
|
14
16
|
def skip?
|
15
17
|
parent.skip_validations.include?(key)
|
16
18
|
end
|
@@ -18,11 +20,17 @@ module Avm
|
|
18
20
|
private
|
19
21
|
|
20
22
|
def result_uncached
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
skip? ? skipped_result : validation_result
|
24
|
+
end
|
25
|
+
|
26
|
+
def skipped_result
|
27
|
+
::Avm::Result.neutral(SKIPPED_RESULT_MESSAGE)
|
28
|
+
end
|
29
|
+
|
30
|
+
def validation_result
|
31
|
+
parent.send("#{key}_result")
|
32
|
+
rescue ::RuntimeError => e
|
33
|
+
::Avm::Result.error("error raised: #{e.message}")
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'avm/tools/core_ext'
|
4
|
+
require 'eac_git/local'
|
4
5
|
|
5
6
|
module Avm
|
6
7
|
module Git
|
@@ -10,14 +11,15 @@ module Avm
|
|
10
11
|
enable_simple_cache
|
11
12
|
enable_speaker
|
12
13
|
|
13
|
-
|
14
|
+
BRANCH_NAME_ISSUE_ID_PATTERN =
|
15
|
+
|
16
|
+
attr_reader :dir, :skip_validations
|
14
17
|
|
15
18
|
def initialize(options)
|
16
19
|
consumer = ::EacRubyUtils::OptionsConsumer.new(options)
|
17
|
-
dir, @skip_validations = consumer.consume_all(:dir, :skip_validations)
|
20
|
+
@dir, @skip_validations = consumer.consume_all(:dir, :skip_validations)
|
18
21
|
validate_skip_validations
|
19
22
|
consumer.validate
|
20
|
-
@git = ::Avm::Launcher::Git::Base.new(dir)
|
21
23
|
end
|
22
24
|
|
23
25
|
def start_banner
|
@@ -35,16 +37,29 @@ module Avm
|
|
35
37
|
end
|
36
38
|
|
37
39
|
def issue_id
|
38
|
-
|
39
|
-
|
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 }
|
40
46
|
end
|
41
47
|
|
42
48
|
private
|
43
49
|
|
44
|
-
|
45
|
-
|
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)
|
46
57
|
r.is_a?(String) ? r.strip : r
|
47
58
|
end
|
59
|
+
|
60
|
+
def launcher_git_uncached
|
61
|
+
::Avm::Launcher::Git::Base.new(dir)
|
62
|
+
end
|
48
63
|
end
|
49
64
|
end
|
50
65
|
end
|
data/lib/avm/git/scms/git.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/git/scms/git_subrepo'
|
3
4
|
require 'avm/scms/base'
|
4
5
|
require 'eac_ruby_utils/core_ext'
|
5
6
|
|
@@ -56,6 +57,13 @@ module Avm
|
|
56
57
|
commit_dirty(message)
|
57
58
|
end
|
58
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
|
+
|
59
67
|
def valid?
|
60
68
|
path.join('.git').exist?
|
61
69
|
end
|
data/lib/avm/git/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.2
|
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:
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm-files
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: eac_ruby_utils
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|