diffend 0.2.40 → 0.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.github/workflows/ci.yml +2 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +40 -0
- data/lib/diffend/errors.rb +2 -0
- data/lib/diffend/handle_errors/report.rb +4 -4
- data/lib/diffend/integration_repository.rb +92 -0
- data/lib/diffend/local_context/packages.rb +6 -2
- data/lib/diffend/plugin.rb +3 -0
- data/lib/diffend/repository.rb +109 -0
- data/lib/diffend/request_object.rb +1 -1
- data/lib/diffend/request_verdict.rb +4 -4
- data/lib/diffend/shell.rb +44 -0
- data/lib/diffend/track.rb +4 -4
- data/lib/diffend/version.rb +1 -1
- 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 +123 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc35a87fc80048201e46cf210e72c4359849b9c17b3208a885e151c2384be274
|
|
4
|
+
data.tar.gz: c438271e070263543f0cc7ae84911631bc8f57dd4804d2fe58d529caf7929e49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e41e7343c6c0f1137dab1999ceebc1c8df54c2950e92f68b592d4f2b03c5fc2e5817b9443068423f2ea1508cc78884c169a4551a61e2723bb5c931d6ce05ed4
|
|
7
|
+
data.tar.gz: 877952bdb836a09034b0e72862cf374a8049a46ee4b416125beaad3a9102b14a1d22878b4128e6efded825d0bc896fcf1873f046f111da9d5ced03907c2d3a1b
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
## [Unreleased][master]
|
|
4
|
+
- introduce integration specs ([#107](https://github.com/diffend-io/diffend-ruby/pull/107))
|
|
5
|
+
- use `Bundler::Definition.resolve` for specs ([#112](https://github.com/diffend-io/diffend-ruby/pull/112))
|
|
4
6
|
|
|
5
7
|
## [0.2.40] (2021-02-23)
|
|
6
8
|
- don't expose ips, we can identify instance by a hostname ([#108](https://github.com/diffend-io/diffend-ruby/pull/108))
|
data/Gemfile.lock
CHANGED
data/Rakefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
%w[
|
|
4
|
+
bundler/setup
|
|
5
|
+
].each(&method(:require))
|
|
6
|
+
|
|
7
|
+
require 'diffend/errors'
|
|
8
|
+
require 'diffend/config'
|
|
9
|
+
require 'diffend/shell'
|
|
10
|
+
require 'diffend/repository'
|
|
11
|
+
require 'diffend/integration_repository'
|
|
12
|
+
|
|
13
|
+
task :integration_suite do
|
|
14
|
+
Diffend::Repository::SUPPORTED.each do |command, repositories|
|
|
15
|
+
repositories.each do |repository_name|
|
|
16
|
+
repository = Diffend::IntegrationRepository.new(command, repository_name)
|
|
17
|
+
repository.repository.isolate do |path|
|
|
18
|
+
start = Time.now.to_f
|
|
19
|
+
|
|
20
|
+
repository.config?(path)
|
|
21
|
+
|
|
22
|
+
Bundler.with_unbundled_env do
|
|
23
|
+
repository.install_plugin(path)
|
|
24
|
+
|
|
25
|
+
cmd = Diffend::Shell.call_in_path(path, "bundle #{command}")
|
|
26
|
+
|
|
27
|
+
unless cmd[:exit_code].zero?
|
|
28
|
+
puts "#{repository.full_name} FAILED"
|
|
29
|
+
puts cmd[:stderr]
|
|
30
|
+
exit 1
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
took = Time.now.to_f - start
|
|
35
|
+
|
|
36
|
+
puts "#{repository.full_name} OK, took #{took.round(1)}s"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
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
|
|
@@ -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
|
|
@@ -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 }
|
data/lib/diffend/plugin.rb
CHANGED
|
@@ -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
|
|
@@ -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