diffend 0.2.36 → 0.2.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.github/workflows/ci.yml +34 -8
- data/.ruby-version +1 -1
- data/CHANGELOG.md +31 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +11 -7
- data/Rakefile +40 -0
- data/lib/diffend/build_bundler_definition.rb +4 -4
- data/lib/diffend/bundle_secure.rb +23 -0
- data/lib/diffend/commands.rb +2 -0
- data/lib/diffend/config.rb +34 -7
- data/lib/diffend/configs/error_messages.rb +38 -0
- data/lib/diffend/configs/fetcher.rb +11 -28
- data/lib/diffend/configs/validator.rb +4 -34
- data/lib/diffend/enabled.rb +22 -0
- data/lib/diffend/errors.rb +2 -0
- data/lib/diffend/execute.rb +4 -4
- data/lib/diffend/handle_errors/report.rb +4 -4
- data/lib/diffend/integration_repository.rb +92 -0
- data/lib/diffend/local_context.rb +1 -1
- data/lib/diffend/local_context/host.rb +0 -12
- data/lib/diffend/local_context/packages.rb +36 -32
- data/lib/diffend/local_context/platform.rb +1 -1
- data/lib/diffend/logger.rb +9 -9
- data/lib/diffend/monitor.rb +32 -10
- data/lib/diffend/plugin.rb +12 -15
- data/lib/diffend/repository.rb +109 -0
- data/lib/diffend/request.rb +0 -1
- data/lib/diffend/request_object.rb +1 -1
- data/lib/diffend/request_verdict.rb +9 -9
- data/lib/diffend/shell.rb +44 -0
- data/lib/diffend/track.rb +4 -4
- data/lib/diffend/version.rb +1 -1
- data/plugins.rb +1 -0
- data/repositories/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock/Gemfile.lock +22 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_added_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_added_gem/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_added_gem/Gemfile.lock +16 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_changed_gem_version/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_changed_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_changed_gem_version/Gemfile.lock +18 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_changed_gem_version/README.md +1 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_locked_gem_version/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_locked_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_locked_gem_version/Gemfile.lock +19 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_removed_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_removed_gem/Gemfile +5 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_removed_gem/Gemfile.lock +43 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_platforms/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_platforms/.ruby-version +1 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_platforms/Gemfile +10 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_platforms/Gemfile.lock +32 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_platforms/gem-with-two-platforms.gemspec +16 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_primary_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_primary_sources/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_primary_sources/Gemfile.lock +17 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_sources/Gemfile +6 -0
- data/repositories/bundler_2_1_4/install_with_gemfile_lock_with_two_sources/Gemfile.lock +19 -0
- data/repositories/bundler_2_1_4/install_without_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/install_without_gemfile_lock/Gemfile +5 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock/Gemfile +5 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock/Gemfile.lock +16 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock/README.md +1 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_added_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_added_gem/Gemfile +6 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_added_gem/Gemfile.lock +16 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_added_gem/README.md +1 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_removed_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_removed_gem/Gemfile +5 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_removed_gem/Gemfile.lock +43 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_removed_gem/README.md +1 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_primary_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_primary_sources/Gemfile +6 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_primary_sources/Gemfile.lock +17 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_primary_sources/README.md +1 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_sources/Gemfile +6 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_sources/Gemfile.lock +44 -0
- data/repositories/bundler_2_1_4/update_with_gemfile_lock_with_two_sources/README.md +1 -0
- data/repositories/bundler_2_1_4/update_without_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_1_4/update_without_gemfile_lock/Gemfile +5 -0
- data/repositories/bundler_2_1_4/update_without_gemfile_lock/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock/Gemfile.lock +21 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_added_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_added_gem/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_added_gem/Gemfile.lock +16 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_added_gem/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_changed_gem_version/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_changed_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_changed_gem_version/Gemfile.lock +18 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_changed_gem_version/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_locked_gem_version/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_locked_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_locked_gem_version/Gemfile.lock +18 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_locked_gem_version/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_removed_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_removed_gem/Gemfile +5 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_removed_gem/Gemfile.lock +41 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_removed_gem/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_platforms/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_platforms/Gemfile +10 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_platforms/Gemfile.lock +30 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_platforms/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_platforms/gem-with-two-platforms.gemspec +16 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_primary_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_primary_sources/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_primary_sources/Gemfile.lock +17 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_primary_sources/README.md +1 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_sources/Gemfile +6 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_sources/Gemfile.lock +19 -0
- data/repositories/bundler_2_2_7/install_with_gemfile_lock_with_two_sources/README.md +1 -0
- data/repositories/bundler_2_2_7/install_without_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/install_without_gemfile_lock/Gemfile +5 -0
- data/repositories/bundler_2_2_7/install_without_gemfile_lock/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock/Gemfile +5 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock/Gemfile.lock +16 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_added_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_added_gem/Gemfile +6 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_added_gem/Gemfile.lock +16 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_added_gem/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_changed_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_changed_gem_version/Gemfile.lock +18 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_changed_gem_version/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_locked_gem_version/Gemfile +6 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_locked_gem_version/Gemfile.lock +18 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_locked_gem_version/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_removed_gem/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_removed_gem/Gemfile +5 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_removed_gem/Gemfile.lock +41 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_primary_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_primary_sources/Gemfile +6 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_primary_sources/Gemfile.lock +17 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_primary_sources/README.md +1 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_sources/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_sources/Gemfile +6 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_sources/Gemfile.lock +42 -0
- data/repositories/bundler_2_2_7/update_with_gemfile_lock_with_two_sources/README.md +1 -0
- data/repositories/bundler_2_2_7/update_without_gemfile_lock/.diffend.yml +3 -0
- data/repositories/bundler_2_2_7/update_without_gemfile_lock/Gemfile +5 -0
- data/repositories/diffend.json +9 -0
- metadata +127 -3
- metadata.gz.sig +0 -0
data/lib/diffend/logger.rb
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
module Diffend
|
4
4
|
# Diffend logging
|
5
5
|
class Logger
|
6
|
-
# Low-level information, mostly for developers
|
6
|
+
# Low-level information, mostly for developers
|
7
7
|
DEBUG = 0
|
8
|
-
# Generic (useful) information about system operation
|
8
|
+
# Generic (useful) information about system operation
|
9
9
|
INFO = 1
|
10
|
-
# A warning
|
10
|
+
# A warning
|
11
11
|
WARN = 2
|
12
|
-
# A handleable error condition
|
12
|
+
# A handleable error condition
|
13
13
|
ERROR = 3
|
14
|
-
# An
|
14
|
+
# An error that we are unable to handle that results in a program crash
|
15
15
|
FATAL = 4
|
16
|
-
# An unknown message that should always be logged
|
16
|
+
# An unknown message that should always be logged
|
17
17
|
UNKNOWN = 5
|
18
18
|
|
19
19
|
# @param level [Integer] logging severity threshold
|
@@ -55,11 +55,11 @@ module Diffend
|
|
55
55
|
|
56
56
|
case severity
|
57
57
|
when INFO
|
58
|
-
Bundler.ui.confirm(message)
|
58
|
+
::Bundler.ui.confirm(message)
|
59
59
|
when WARN
|
60
|
-
Bundler.ui.warn(message)
|
60
|
+
::Bundler.ui.warn(message)
|
61
61
|
when ERROR, FATAL
|
62
|
-
Bundler.ui.error(message)
|
62
|
+
::Bundler.ui.error(message)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/diffend/monitor.rb
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
errors
|
7
7
|
build_bundler_definition
|
8
8
|
commands
|
9
|
+
configs/error_messages
|
9
10
|
config
|
10
11
|
configs/fetcher
|
11
12
|
configs/validator
|
@@ -25,19 +26,40 @@
|
|
25
26
|
track
|
26
27
|
].each { |file| require "diffend/#{file}" }
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return
|
29
|
+
# Calculate exponential backoff
|
30
|
+
#
|
31
|
+
# @param retry_count [Integer]
|
32
|
+
#
|
33
|
+
# @return [Float] backoff value
|
34
|
+
def exponential_backoff(retry_count)
|
35
|
+
(0.25 * 1.5**retry_count.to_f).round(2)
|
36
36
|
end
|
37
37
|
|
38
|
-
return if %w[development test].include?(config.env)
|
39
|
-
|
40
38
|
Thread.new do
|
39
|
+
config = nil
|
40
|
+
retry_count = 0
|
41
|
+
|
42
|
+
# There is an issue if we start to fast and there are gems that require things,
|
43
|
+
# it may break the execution. That's why we want to give the application time to boot.
|
44
|
+
sleep(0.5)
|
45
|
+
|
46
|
+
loop do
|
47
|
+
config = Diffend::Config.new(
|
48
|
+
command: Diffend::Commands::EXEC,
|
49
|
+
severity: Diffend::Logger::FATAL
|
50
|
+
)
|
51
|
+
|
52
|
+
break if config.valid?
|
53
|
+
break if retry_count == 12
|
54
|
+
|
55
|
+
sleep(exponential_backoff(retry_count))
|
56
|
+
|
57
|
+
retry_count += 1
|
58
|
+
end
|
59
|
+
|
60
|
+
Thread.exit unless config.valid?
|
61
|
+
Thread.exit unless config.deployment?
|
62
|
+
|
41
63
|
track = Diffend::Track.new(config)
|
42
64
|
track.start
|
43
65
|
end
|
data/lib/diffend/plugin.rb
CHANGED
@@ -7,10 +7,12 @@
|
|
7
7
|
%w[
|
8
8
|
version
|
9
9
|
logger
|
10
|
+
enabled
|
10
11
|
latest_version
|
11
12
|
errors
|
12
13
|
build_bundler_definition
|
13
14
|
commands
|
15
|
+
configs/error_messages
|
14
16
|
config
|
15
17
|
configs/fetcher
|
16
18
|
configs/validator
|
@@ -28,6 +30,9 @@
|
|
28
30
|
request_verdict
|
29
31
|
execute
|
30
32
|
track
|
33
|
+
shell
|
34
|
+
repository
|
35
|
+
integration_repository
|
31
36
|
].each { |file| require "diffend/#{file}" }
|
32
37
|
|
33
38
|
module Diffend
|
@@ -42,10 +47,16 @@ module Diffend
|
|
42
47
|
|
43
48
|
# Execute diffend plugin
|
44
49
|
def execute
|
45
|
-
return unless
|
50
|
+
return unless Diffend::Enabled.call
|
46
51
|
|
47
52
|
config = Diffend::Config.new(severity: Diffend::Logger::INFO)
|
48
53
|
|
54
|
+
unless config.valid?
|
55
|
+
config.print_errors
|
56
|
+
|
57
|
+
exit 255
|
58
|
+
end
|
59
|
+
|
49
60
|
Diffend::LatestVersion.call(config)
|
50
61
|
|
51
62
|
Diffend::Execute.call(config)
|
@@ -67,20 +78,6 @@ module Diffend
|
|
67
78
|
|
68
79
|
exit 255
|
69
80
|
end
|
70
|
-
|
71
|
-
# Checks if plugin is enabled
|
72
|
-
#
|
73
|
-
# @return [Boolean] true if enabled, false otherwise
|
74
|
-
def enabled?
|
75
|
-
::Bundler
|
76
|
-
.default_gemfile
|
77
|
-
.read
|
78
|
-
.split("\n")
|
79
|
-
.reject(&:empty?)
|
80
|
-
.map(&:strip)
|
81
|
-
.select { |line| line.start_with?('plugin') }
|
82
|
-
.any? { |line| line.include?('diffend') }
|
83
|
-
end
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
%w[
|
4
|
+
tmpdir
|
5
|
+
securerandom
|
6
|
+
].each(&method(:require))
|
7
|
+
|
8
|
+
module Diffend
|
9
|
+
# Repository for specs
|
10
|
+
class Repository
|
11
|
+
# Repositories path
|
12
|
+
REPOSITORIES_PATH = File.join(
|
13
|
+
File.expand_path('..', Bundler.bin_path),
|
14
|
+
'repositories'
|
15
|
+
).freeze
|
16
|
+
# List of supported repositories split by command
|
17
|
+
SUPPORTED = {
|
18
|
+
'install' => %w[
|
19
|
+
with_gemfile_lock
|
20
|
+
with_gemfile_lock_with_added_gem
|
21
|
+
with_gemfile_lock_with_changed_gem_version
|
22
|
+
with_gemfile_lock_with_locked_gem_version
|
23
|
+
with_gemfile_lock_with_removed_gem
|
24
|
+
with_gemfile_lock_with_two_platforms
|
25
|
+
with_gemfile_lock_with_two_primary_sources
|
26
|
+
with_gemfile_lock_with_two_sources
|
27
|
+
without_gemfile_lock
|
28
|
+
].freeze,
|
29
|
+
'update' => %w[
|
30
|
+
with_gemfile_lock
|
31
|
+
with_gemfile_lock_with_added_gem
|
32
|
+
with_gemfile_lock_with_removed_gem
|
33
|
+
with_gemfile_lock_with_two_primary_sources
|
34
|
+
with_gemfile_lock_with_two_sources
|
35
|
+
without_gemfile_lock
|
36
|
+
].freeze
|
37
|
+
}.freeze
|
38
|
+
|
39
|
+
attr_reader :name, :path
|
40
|
+
|
41
|
+
# @param command [String] command executed via bundler
|
42
|
+
# @param name [String] repository name
|
43
|
+
def initialize(command, name)
|
44
|
+
@command = command
|
45
|
+
@name = name
|
46
|
+
@path = File.join(Dir.tmpdir, SecureRandom.uuid)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Build repository path
|
50
|
+
#
|
51
|
+
# @return [String]
|
52
|
+
def orig_path
|
53
|
+
@orig_path ||= global_file_path(
|
54
|
+
File.join(
|
55
|
+
bundler_version_string,
|
56
|
+
"#{@command}_#{name}"
|
57
|
+
)
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Setup an isolated instance of a repository
|
62
|
+
def setup
|
63
|
+
FileUtils.cp_r(orig_path, path)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Clean isolated instance of a repository
|
67
|
+
def clean
|
68
|
+
FileUtils.rm_rf(path)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Execute tasks in an isolated instance of a repository
|
72
|
+
def isolate
|
73
|
+
setup
|
74
|
+
yield(path)
|
75
|
+
clean
|
76
|
+
end
|
77
|
+
|
78
|
+
# Build the path to a specified file within the repository
|
79
|
+
#
|
80
|
+
# @param file_name [String]
|
81
|
+
#
|
82
|
+
# @return [String]
|
83
|
+
def file_path(file_name)
|
84
|
+
File.join(
|
85
|
+
path,
|
86
|
+
file_name
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Build global path
|
91
|
+
#
|
92
|
+
# @param file_name [String]
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
def global_file_path(file_name)
|
96
|
+
File.join(
|
97
|
+
REPOSITORIES_PATH,
|
98
|
+
file_name
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Build bundler version string
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
def bundler_version_string
|
106
|
+
@bundler_version_string ||= "bundler_#{Bundler::VERSION.tr('.', '_')}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/diffend/request.rb
CHANGED
@@ -7,15 +7,15 @@ module Diffend
|
|
7
7
|
module RequestVerdict
|
8
8
|
# Exceptions that we handle when there is a resolve issue
|
9
9
|
RESOLVE_EXCEPTIONS = [
|
10
|
-
Bundler::GemNotFound,
|
11
|
-
Bundler::GitError,
|
12
|
-
Bundler::PermissionError,
|
13
|
-
Bundler::VersionConflict
|
10
|
+
::Bundler::GemNotFound,
|
11
|
+
::Bundler::GitError,
|
12
|
+
::Bundler::PermissionError,
|
13
|
+
::Bundler::VersionConflict
|
14
14
|
].freeze
|
15
15
|
|
16
16
|
class << self
|
17
17
|
# @param config [Diffend::Config]
|
18
|
-
# @param definition [Bundler::Definition] definition for your source
|
18
|
+
# @param definition [::Bundler::Definition] definition for your source
|
19
19
|
def call(config, definition)
|
20
20
|
payload = Diffend::LocalContext.call(config, definition)
|
21
21
|
|
@@ -42,10 +42,10 @@ module Diffend
|
|
42
42
|
# @return [Diffend::RequestObject]
|
43
43
|
def build_request_object(config, payload)
|
44
44
|
Diffend::RequestObject.new(
|
45
|
-
config
|
46
|
-
|
47
|
-
payload
|
48
|
-
|
45
|
+
config,
|
46
|
+
config.commands_url,
|
47
|
+
payload,
|
48
|
+
:post
|
49
49
|
)
|
50
50
|
end
|
51
51
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
# Helper commands for running Linux shell commands
|
6
|
+
module Diffend
|
7
|
+
module Shell
|
8
|
+
class << self
|
9
|
+
# Allows to execute shell commands and handle errors, etc later
|
10
|
+
# (won't raise any errors but instead will catch all things)
|
11
|
+
# @param command_with_options [String] command that should be executed with
|
12
|
+
# all the arguments and options
|
13
|
+
# @param raise_on_invalid_exit [Boolean] raise exception when exit code is not 0
|
14
|
+
# @return [Hash] hash with 3 keys describing output
|
15
|
+
# (stdout, stderr, exit_code)
|
16
|
+
# @example Run ls
|
17
|
+
# SupportEngine::Shell.('ls') =>
|
18
|
+
# { stdout: "test.rb\n", stderr: '', exit_code: 0}
|
19
|
+
def call(command_with_options, raise_on_invalid_exit: true)
|
20
|
+
stdout_str, stderr_str, status = Open3.capture3(command_with_options)
|
21
|
+
|
22
|
+
result = {
|
23
|
+
stdout: stdout_str,
|
24
|
+
stderr: stderr_str,
|
25
|
+
exit_code: status.exitstatus
|
26
|
+
}
|
27
|
+
|
28
|
+
raise Diffend::Errors::FailedShellCommand, result.values.join(': ') \
|
29
|
+
if raise_on_invalid_exit && result[:exit_code] != 0
|
30
|
+
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param path [String, Pathname] to a place where git repo is
|
35
|
+
# @param command [String] that we want to execute in path context
|
36
|
+
# @param raise_on_invalid_exit [Boolean] raise exception when exit code is not 0
|
37
|
+
# @return [Hash] hash with 3 keys describing output (stdout, stderr, exit_code)
|
38
|
+
def call_in_path(path, command, raise_on_invalid_exit: true)
|
39
|
+
command = ['cd', path.to_s, '&&', command]
|
40
|
+
call(command.join(' '), raise_on_invalid_exit: raise_on_invalid_exit)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/diffend/track.rb
CHANGED
@@ -62,10 +62,10 @@ module Diffend
|
|
62
62
|
# @return [Diffend::RequestObject]
|
63
63
|
def build_request_object(request_id)
|
64
64
|
Diffend::RequestObject.new(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
@config,
|
66
|
+
@config.track_url(request_id),
|
67
|
+
{ id: request_id }.freeze,
|
68
|
+
:put
|
69
69
|
).freeze
|
70
70
|
end
|
71
71
|
end
|
data/lib/diffend/version.rb
CHANGED
data/plugins.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
concurrent-ruby (1.0.5)
|
5
|
+
concurrent-ruby (1.0.5-java)
|
6
|
+
dry-core (0.4.7)
|
7
|
+
concurrent-ruby (~> 1.0)
|
8
|
+
mini_portile2 (2.4.0)
|
9
|
+
nokogiri (1.10.10)
|
10
|
+
mini_portile2 (~> 2.4.0)
|
11
|
+
nokogiri (1.10.10-java)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
java
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
dry-core
|
19
|
+
nokogiri
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
2.1.4
|