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
@@ -5,6 +5,7 @@ module Diffend
|
|
5
5
|
module Configs
|
6
6
|
# Class responsible for validating the config from .diffend.yml
|
7
7
|
module Validator
|
8
|
+
# List of known config keys
|
8
9
|
KNOWN_KEYS = {
|
9
10
|
project_id: [String],
|
10
11
|
shareable_id: [String],
|
@@ -21,18 +22,11 @@ module Diffend
|
|
21
22
|
def call(config)
|
22
23
|
KNOWN_KEYS.each_key do |key|
|
23
24
|
if missing?(config, key)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
raise Diffend::Errors::HandledException
|
25
|
+
config.errors << ErrorMessages.missing_key(key)
|
26
|
+
next
|
28
27
|
end
|
29
28
|
|
30
|
-
if invalid?(config, key)
|
31
|
-
invalid_key_message(config, key)
|
32
|
-
.tap(&config.logger.method(:fatal))
|
33
|
-
|
34
|
-
raise Diffend::Errors::HandledException
|
35
|
-
end
|
29
|
+
config.errors << ErrorMessages.invalid_key(config, key) if invalid?(config, key)
|
36
30
|
end
|
37
31
|
end
|
38
32
|
|
@@ -55,30 +49,6 @@ module Diffend
|
|
55
49
|
def invalid?(config, key)
|
56
50
|
!KNOWN_KEYS[key].include?(config.public_send(key).class)
|
57
51
|
end
|
58
|
-
|
59
|
-
# Missing key message
|
60
|
-
#
|
61
|
-
# @param key [String] missing key
|
62
|
-
#
|
63
|
-
# @return [String]
|
64
|
-
def missing_key_message(key)
|
65
|
-
<<~MSG
|
66
|
-
\nDiffend configuration is missing #{key} key.\n
|
67
|
-
MSG
|
68
|
-
end
|
69
|
-
|
70
|
-
# Invalid key message
|
71
|
-
#
|
72
|
-
# @param hash [Hash] config hash
|
73
|
-
# @param key [String] invalid key
|
74
|
-
#
|
75
|
-
# @return [String]
|
76
|
-
def invalid_key_message(hash, key)
|
77
|
-
<<~MSG
|
78
|
-
\nDiffend configuration value for #{key} is invalid.\n
|
79
|
-
It should be #{KNOWN_KEYS[key].join(' or ')} but is #{hash.public_send(key).class}.\n
|
80
|
-
MSG
|
81
|
-
end
|
82
52
|
end
|
83
53
|
end
|
84
54
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Verify if the plugin is enabled
|
5
|
+
module Enabled
|
6
|
+
class << self
|
7
|
+
# Checks if plugin is enabled
|
8
|
+
#
|
9
|
+
# @return [Boolean] true if enabled, false otherwise
|
10
|
+
def call
|
11
|
+
::Bundler
|
12
|
+
.default_gemfile
|
13
|
+
.read
|
14
|
+
.split("\n")
|
15
|
+
.reject(&:empty?)
|
16
|
+
.map(&:strip)
|
17
|
+
.select { |line| line.start_with?('plugin') }
|
18
|
+
.any? { |line| line.include?('diffend') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/diffend/errors.rb
CHANGED
@@ -21,5 +21,7 @@ module Diffend
|
|
21
21
|
HandledException = Class.new(BaseError)
|
22
22
|
# Raised when we are unable to resolve dependencies
|
23
23
|
DependenciesResolveException = Class.new(BaseError)
|
24
|
+
# Failure of a shell command execution
|
25
|
+
FailedShellCommand = Class.new(BaseError)
|
24
26
|
end
|
25
27
|
end
|
data/lib/diffend/execute.rb
CHANGED
@@ -17,12 +17,12 @@ module Diffend
|
|
17
17
|
|
18
18
|
# Build bundler definition
|
19
19
|
#
|
20
|
-
# @return [Bundler::Definition]
|
20
|
+
# @return [::Bundler::Definition]
|
21
21
|
def build_definition(command)
|
22
22
|
Diffend::BuildBundlerDefinition.call(
|
23
23
|
command,
|
24
|
-
Bundler.default_gemfile,
|
25
|
-
Bundler.default_lockfile
|
24
|
+
::Bundler.default_gemfile,
|
25
|
+
::Bundler.default_lockfile
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ module Diffend
|
|
30
30
|
# @param response [Hash] response from diffend API
|
31
31
|
def build_message(config, response)
|
32
32
|
if response.key?('error')
|
33
|
-
build_error(
|
33
|
+
build_error(response)
|
34
34
|
elsif response.key?('action')
|
35
35
|
build_verdict(config, response)
|
36
36
|
else
|
@@ -39,10 +39,10 @@ module Diffend
|
|
39
39
|
# @return [Diffend::RequestObject]
|
40
40
|
def build_request_object(config, payload)
|
41
41
|
Diffend::RequestObject.new(
|
42
|
-
config
|
43
|
-
|
44
|
-
payload
|
45
|
-
|
42
|
+
config,
|
43
|
+
config.errors_url,
|
44
|
+
payload,
|
45
|
+
:post
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Repository for integrations
|
5
|
+
class IntegrationRepository
|
6
|
+
# Plugin code entry in Gemfile
|
7
|
+
GEMFILE_PLUGIN_ENTRY = 'plugin \'diffend\''
|
8
|
+
# Gemfile file name
|
9
|
+
GEMFILE_FILE_NAME = 'Gemfile'
|
10
|
+
# Gemfile backup file name
|
11
|
+
GEMFILE_BACKUP_FILE_NAME = 'Gemfile.backup'
|
12
|
+
# Plugin install command
|
13
|
+
PLUGIN_INSTALL_COMMAND = 'bundle plugin install diffend'
|
14
|
+
|
15
|
+
attr_reader :command, :name, :repository
|
16
|
+
|
17
|
+
# @param command [String] command executed via bundler
|
18
|
+
# @param name [String] repository name
|
19
|
+
def initialize(command, name)
|
20
|
+
@command = command
|
21
|
+
@name = name
|
22
|
+
@repository = Diffend::Repository.new(command, name)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] full name of the repository with command
|
26
|
+
def full_name
|
27
|
+
"#{command}_#{name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param path [String] path to the repository
|
31
|
+
def config?(path)
|
32
|
+
# check if .diffend.yml exists
|
33
|
+
return if File.exist?(File.join(path, Diffend::Config::FILENAME))
|
34
|
+
|
35
|
+
puts "Diffend configuration does not exist for #{command} #{name}"
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param path [String] path to the repository
|
40
|
+
def install_plugin(path)
|
41
|
+
cmd = Diffend::Shell.call_in_path(path, PLUGIN_INSTALL_COMMAND)
|
42
|
+
|
43
|
+
unless cmd[:exit_code].zero?
|
44
|
+
puts "#{PLUGIN_INSTALL_COMMAND} failed"
|
45
|
+
puts cmd[:stderr]
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
switch_plugin_to_development(path, cmd[:stdout])
|
50
|
+
add_plugin_to_gemfile(path)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
# @param path [String] path to the repository
|
56
|
+
# @param stdout [String] stdout from plugin install command
|
57
|
+
def switch_plugin_to_development(path, stdout)
|
58
|
+
installed_version = stdout.scan(/Installing diffend (\d*\.\d*\.\d*)/)[0][0]
|
59
|
+
diffend_working_path = File.expand_path('..', Bundler.bin_path)
|
60
|
+
bundler_plugins_path = File.join(path, '.bundle/plugin/gems')
|
61
|
+
bundler_diffend_plugin_path = File.join(bundler_plugins_path, "diffend-#{installed_version}")
|
62
|
+
FileUtils.mv(bundler_diffend_plugin_path, "#{bundler_diffend_plugin_path}-")
|
63
|
+
FileUtils.ln_s(diffend_working_path, bundler_diffend_plugin_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param path [String] path to the repository
|
67
|
+
def add_plugin_to_gemfile(path)
|
68
|
+
gemfile_path = File.join(path, GEMFILE_FILE_NAME)
|
69
|
+
|
70
|
+
FileUtils.mv(gemfile_path, File.join(path, GEMFILE_BACKUP_FILE_NAME))
|
71
|
+
file = File.open(gemfile_path, 'w')
|
72
|
+
source_detected = nil
|
73
|
+
|
74
|
+
File.readlines(
|
75
|
+
File.join(path, GEMFILE_BACKUP_FILE_NAME)
|
76
|
+
).each do |line|
|
77
|
+
if line.start_with?('source') && source_detected.nil?
|
78
|
+
source_detected = true
|
79
|
+
elsif source_detected
|
80
|
+
source_detected = false
|
81
|
+
file.write("\n#{GEMFILE_PLUGIN_ENTRY}\n")
|
82
|
+
end
|
83
|
+
|
84
|
+
file.write(line)
|
85
|
+
end
|
86
|
+
|
87
|
+
file.close
|
88
|
+
|
89
|
+
FileUtils.rm(File.join(path, GEMFILE_BACKUP_FILE_NAME))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -7,7 +7,7 @@ module Diffend
|
|
7
7
|
# Build diffend, host, packages, and platform specific information
|
8
8
|
#
|
9
9
|
# @param config [Diffend::Config]
|
10
|
-
# @param definition [Bundler::Definition] definition for your source
|
10
|
+
# @param definition [::Bundler::Definition] definition for your source
|
11
11
|
#
|
12
12
|
# @return [Hash] payload for diffend endpoint
|
13
13
|
def call(config, definition)
|
@@ -16,7 +16,6 @@ module Diffend
|
|
16
16
|
|
17
17
|
{
|
18
18
|
'command' => command,
|
19
|
-
'ips' => ips,
|
20
19
|
'name' => uname[:nodename],
|
21
20
|
'system' => {
|
22
21
|
'machine' => uname[:machine],
|
@@ -53,17 +52,6 @@ module Diffend
|
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
# Build host ips, except localhost and loopback
|
57
|
-
#
|
58
|
-
# @return [Array<String>]
|
59
|
-
def ips
|
60
|
-
Socket.ip_address_list.map do |ip|
|
61
|
-
next if ip.ipv4_loopback? || ip.ipv6_loopback? || ip.ipv6_linklocal?
|
62
|
-
|
63
|
-
ip.ip_address
|
64
|
-
end.compact
|
65
|
-
end
|
66
|
-
|
67
55
|
# Build host tags
|
68
56
|
#
|
69
57
|
# @return [Array]
|
@@ -9,8 +9,8 @@ module Diffend
|
|
9
9
|
ME_PATH = '.'
|
10
10
|
# Sources that we expect to match ourselves too
|
11
11
|
ME_SOURCES = [
|
12
|
-
Bundler::Source::Gemspec,
|
13
|
-
Bundler::Source::Path
|
12
|
+
::Bundler::Source::Gemspec,
|
13
|
+
::Bundler::Source::Path
|
14
14
|
].freeze
|
15
15
|
# List of dependency types
|
16
16
|
DEPENDENCIES_TYPES = {
|
@@ -32,14 +32,14 @@ module Diffend
|
|
32
32
|
|
33
33
|
class << self
|
34
34
|
# @param command [String] command executed via bundler
|
35
|
-
# @param definition [Bundler::Definition] definition for your source
|
35
|
+
# @param definition [::Bundler::Definition] definition for your source
|
36
36
|
def call(command, definition)
|
37
37
|
instance = new(command, definition)
|
38
38
|
|
39
|
-
Bundler.ui.silence { instance.resolve }
|
39
|
+
::Bundler.ui.silence { instance.resolve }
|
40
40
|
|
41
41
|
case command
|
42
|
-
when Commands::INSTALL, Commands::EXEC then instance.build_install
|
42
|
+
when Commands::INSTALL, Commands::EXEC, Commands::SECURE then instance.build_install
|
43
43
|
when Commands::UPDATE then instance.build_update
|
44
44
|
else
|
45
45
|
raise ArgumentError, "invalid command: #{command}"
|
@@ -48,7 +48,7 @@ module Diffend
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# @param command [String] command executed via bundler
|
51
|
-
# @param definition [Bundler::Definition] definition for your source
|
51
|
+
# @param definition [::Bundler::Definition] definition for your source
|
52
52
|
#
|
53
53
|
# @return [Hash] local dependencies
|
54
54
|
def initialize(command, definition)
|
@@ -71,7 +71,9 @@ module Diffend
|
|
71
71
|
def build_install
|
72
72
|
hash = build_main
|
73
73
|
|
74
|
-
@definition.
|
74
|
+
@definition.resolve.each do |spec|
|
75
|
+
# Skip metadata
|
76
|
+
next if spec.instance_variable_get(:@specification).nil?
|
75
77
|
next if skip?(spec.source)
|
76
78
|
|
77
79
|
locked_spec = @locked_specs.find { |s| s.name == spec.name }
|
@@ -93,7 +95,9 @@ module Diffend
|
|
93
95
|
def build_update
|
94
96
|
hash = build_main
|
95
97
|
|
96
|
-
@definition.
|
98
|
+
@definition.resolve.each do |spec|
|
99
|
+
# Skip metadata
|
100
|
+
next if spec.instance_variable_get(:@specification).nil?
|
97
101
|
next if skip?(spec.source)
|
98
102
|
|
99
103
|
locked_spec = @locked_specs.find { |s| s.name == spec.name }
|
@@ -125,8 +129,8 @@ module Diffend
|
|
125
129
|
|
126
130
|
# Build gem versions
|
127
131
|
#
|
128
|
-
# @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
|
129
|
-
# @param locked_spec [Bundler::LazySpecification, Gem::Specification, NilClass]
|
132
|
+
# @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
|
133
|
+
# @param locked_spec [::Bundler::LazySpecification, Gem::Specification, NilClass]
|
130
134
|
#
|
131
135
|
# @return [Array<String>]
|
132
136
|
def build_versions(spec, locked_spec = nil)
|
@@ -151,8 +155,8 @@ module Diffend
|
|
151
155
|
|
152
156
|
# Build gem platform
|
153
157
|
#
|
154
|
-
# @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
|
155
|
-
# @param locked_spec [Bundler::LazySpecification, Gem::Specification, NilClass]
|
158
|
+
# @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
|
159
|
+
# @param locked_spec [::Bundler::LazySpecification, Gem::Specification, NilClass]
|
156
160
|
#
|
157
161
|
# @return [String]
|
158
162
|
def build_spec_platform(spec, locked_spec)
|
@@ -175,18 +179,18 @@ module Diffend
|
|
175
179
|
|
176
180
|
# Build gem source type
|
177
181
|
#
|
178
|
-
# @param source [Bundler::Source] gem source type
|
182
|
+
# @param source [::Bundler::Source] gem source type
|
179
183
|
#
|
180
184
|
# @return [Integer] internal gem source type
|
181
185
|
def build_spec_gem_source_type(source)
|
182
186
|
case source
|
183
|
-
when Bundler::Source::Metadata
|
187
|
+
when ::Bundler::Source::Metadata
|
184
188
|
GEM_SOURCES_TYPES[:local]
|
185
|
-
when Bundler::Source::Rubygems, Bundler::Source::Rubygems::Remote
|
189
|
+
when ::Bundler::Source::Rubygems, ::Bundler::Source::Rubygems::Remote
|
186
190
|
GEM_SOURCES_TYPES[:gemfile_source]
|
187
|
-
when Bundler::Source::Git
|
191
|
+
when ::Bundler::Source::Git
|
188
192
|
GEM_SOURCES_TYPES[:gemfile_git]
|
189
|
-
when Bundler::Source::Path
|
193
|
+
when ::Bundler::Source::Path
|
190
194
|
GEM_SOURCES_TYPES[:gemfile_path]
|
191
195
|
else
|
192
196
|
raise ArgumentError, "unknown source #{source.class}"
|
@@ -195,7 +199,7 @@ module Diffend
|
|
195
199
|
|
196
200
|
# Build gem source
|
197
201
|
#
|
198
|
-
# @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
|
202
|
+
# @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
|
199
203
|
#
|
200
204
|
# @return [Hash]
|
201
205
|
def build_spec_source(spec)
|
@@ -209,16 +213,16 @@ module Diffend
|
|
209
213
|
|
210
214
|
# Figure out source for gem
|
211
215
|
#
|
212
|
-
# @param spec [Bundler::StubSpecification, Bundler::LazySpecification, Gem::Specification]
|
216
|
+
# @param spec [::Bundler::StubSpecification, ::Bundler::LazySpecification, Gem::Specification]
|
213
217
|
#
|
214
|
-
# @return [Bundler::Source] gem source type
|
218
|
+
# @return [::Bundler::Source] gem source type
|
215
219
|
def source_for_spec(spec)
|
216
220
|
return spec.remote if spec.remote
|
217
221
|
|
218
222
|
case spec.source
|
219
|
-
when Bundler::Source::Rubygems
|
220
|
-
Bundler::Source::Rubygems::Remote.new(spec.source.remotes.last)
|
221
|
-
when Bundler::Source::Metadata, Bundler::Source::Git, Bundler::Source::Path
|
223
|
+
when ::Bundler::Source::Rubygems
|
224
|
+
::Bundler::Source::Rubygems::Remote.new(spec.source.remotes.last)
|
225
|
+
when ::Bundler::Source::Metadata, ::Bundler::Source::Git, ::Bundler::Source::Path
|
222
226
|
spec.source
|
223
227
|
else
|
224
228
|
raise ArgumentError, "unknown source #{spec.source.class}"
|
@@ -227,25 +231,25 @@ module Diffend
|
|
227
231
|
|
228
232
|
# Build gem source name
|
229
233
|
#
|
230
|
-
# @param source [Bundler::Source] gem source type
|
234
|
+
# @param source [::Bundler::Source] gem source type
|
231
235
|
#
|
232
236
|
# @return [String]
|
233
237
|
def source_name_from_source(source)
|
234
238
|
case source
|
235
|
-
when Bundler::Source::Metadata
|
239
|
+
when ::Bundler::Source::Metadata
|
236
240
|
''
|
237
|
-
when Bundler::Source::Rubygems::Remote
|
241
|
+
when ::Bundler::Source::Rubygems::Remote
|
238
242
|
source_name(source.anonymized_uri)
|
239
|
-
when Bundler::Source::Git
|
243
|
+
when ::Bundler::Source::Git
|
240
244
|
source.instance_variable_get(:@safe_uri)
|
241
|
-
when Bundler::Source::Path
|
245
|
+
when ::Bundler::Source::Path
|
242
246
|
source.path
|
243
247
|
else
|
244
248
|
raise ArgumentError, "unknown source #{source.class}"
|
245
249
|
end
|
246
250
|
end
|
247
251
|
|
248
|
-
# @param uri [Bundler::URI]
|
252
|
+
# @param uri [::Bundler::URI]
|
249
253
|
#
|
250
254
|
# @return [String]
|
251
255
|
def source_name(uri)
|
@@ -272,7 +276,7 @@ module Diffend
|
|
272
276
|
|
273
277
|
# Build gem source type
|
274
278
|
#
|
275
|
-
# @param remotes [Array
|
279
|
+
# @param remotes [Array<::Bundler::URI>]
|
276
280
|
#
|
277
281
|
# @return [Integer] internal source type
|
278
282
|
def build_source_type(remotes)
|
@@ -281,7 +285,7 @@ module Diffend
|
|
281
285
|
|
282
286
|
# Checks if we should skip a source
|
283
287
|
#
|
284
|
-
# @param source [Bundler::Source] gem source type
|
288
|
+
# @param source [::Bundler::Source] gem source type
|
285
289
|
#
|
286
290
|
# @return [Boolean] true if we should skip this source, false otherwise
|
287
291
|
def skip?(source)
|
@@ -292,7 +296,7 @@ module Diffend
|
|
292
296
|
|
293
297
|
# Checks if it's a self source, this happens for repositories that are a gem
|
294
298
|
#
|
295
|
-
# @param source [Bundler::Source] gem source type
|
299
|
+
# @param source [::Bundler::Source] gem source type
|
296
300
|
#
|
297
301
|
# @return [Boolean] true if it's a self source, false otherwise
|
298
302
|
def me?(source)
|