diffend 0.2.19 → 0.2.27
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 +2 -2
- data.tar.gz.sig +0 -0
- data/.github/workflows/ci.yml +5 -0
- data/CHANGELOG.md +47 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +12 -1
- data/lib/diffend.rb +97 -19
- data/lib/diffend/build_bundler_definition.rb +26 -0
- data/lib/diffend/commands.rb +4 -2
- data/lib/diffend/config/fetcher.rb +8 -4
- data/lib/diffend/errors.rb +4 -4
- data/lib/diffend/handle_errors/build_exception_payload.rb +30 -0
- data/lib/diffend/handle_errors/display_to_stdout.rb +17 -0
- data/lib/diffend/handle_errors/messages.rb +29 -0
- data/lib/diffend/handle_errors/report.rb +71 -0
- data/lib/diffend/monitor.rb +28 -0
- data/lib/diffend/request.rb +185 -0
- data/lib/diffend/request_object.rb +6 -0
- data/lib/diffend/track.rb +104 -0
- data/lib/diffend/voting.rb +72 -13
- data/lib/diffend/voting/versions/local.rb +55 -29
- data/lib/diffend/voting/versions/remote.rb +57 -13
- data/scripts/generate_payload_for_file.rb +1 -1
- metadata +11 -3
- metadata.gz.sig +0 -0
- data/lib/diffend/voting/request.rb +0 -191
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6539b727e33d38eb0b3fb6f38f25c3fd2abda05f337f50af2db1fe135575510
|
4
|
+
data.tar.gz: c6808082290c195a846117fd4c16a4fa4cb20f65cc289cbadbd71532f8ae5713
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eb4e7749b9a9a0824770921d150e180ed5b40ba19a7f22d1f65154474347110221dc96049c2b4b5d7136c850c5775c07bc4e840b005dda13043742ac74238d2
|
7
|
+
data.tar.gz: 427d6b00c913174e535de300020f8fe715bda9b3f946f1fbe25906dfa734bb4dd3c349735470fbacb9740c287dd5252bcf6b481e40120daba3138afda6f334e9
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
�
|
2
|
-
|
1
|
+
�Ęk�oش�_��Ip��B�GZ�hήO���D�[���S�;��o��x�"Q�������#I� �ir�h����H��o����E��R^��[Ñ~����fg*��ᢩ{H-�s'�:��2cI�NX��r]w˛� �qo���$��_�5�9��.G�H�P�
|
2
|
+
������2��LE>��=�L$6�;Y��{���`{�=��G���_�JĬ��V{#jB-G!b��*{�T9= ��_cC��7��̂̈́V�9>m*Fs����0���0�$�X�:u4�����"�5�D��{K9CIz`�K�1��O�P��Py��Ѱ�3����\���_����S:��<;�vA����9�;�@�+#�&�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -9,6 +9,9 @@ jobs:
|
|
9
9
|
matrix:
|
10
10
|
ruby:
|
11
11
|
- '2.7'
|
12
|
+
- '2.6'
|
13
|
+
- '2.5'
|
14
|
+
- 'jruby'
|
12
15
|
include:
|
13
16
|
- ruby: '2.7'
|
14
17
|
coverage: 'true'
|
@@ -31,6 +34,8 @@ jobs:
|
|
31
34
|
run: |
|
32
35
|
gem install bundler --no-document
|
33
36
|
- name: Bundle install
|
37
|
+
env:
|
38
|
+
DIFFEND_DEVELOPMENT: true
|
34
39
|
run: |
|
35
40
|
bundle config path vendor/bundle
|
36
41
|
bundle install --jobs 4 --retry 3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,44 @@
|
|
2
2
|
|
3
3
|
## [Unreleased][master]
|
4
4
|
|
5
|
+
## [0.2.27] (2020-09-16)
|
6
|
+
- introduce `Diffend::RequestObject` ([#40](https://github.com/diffend-io/diffend-ruby/pull/40))
|
7
|
+
- clean up error codes and introduce `DIFFEND_INGORE_EXCEPTIONS` ([#41](https://github.com/diffend-io/diffend-ruby/pull/41))
|
8
|
+
- introduce `Diffend::Monitor` and `Diffend::Track` ([#15](https://github.com/diffend-io/diffend-ruby/pull/15))
|
9
|
+
|
10
|
+
## [0.2.26] (2020-09-10)
|
11
|
+
- introduce `DIFFEND_DEVELOPMENT` environment variable ([#36](https://github.com/diffend-io/diffend-ruby/pull/36))
|
12
|
+
- adjust message for allow verdict ([#37](https://github.com/diffend-io/diffend-ruby/pull/37))
|
13
|
+
- do not run the plugin when it is not enabled ([#38](https://github.com/diffend-io/diffend-ruby/pull/38))
|
14
|
+
|
15
|
+
## [0.2.25] (2020-09-09)
|
16
|
+
- add support for a warn verdict ([#34](https://github.com/diffend-io/diffend-ruby/pull/34))
|
17
|
+
|
18
|
+
## [0.2.24] (2020-09-08)
|
19
|
+
- better error handling of response ([#28](https://github.com/diffend-io/diffend-ruby/pull/28))
|
20
|
+
- fix jruby specs ([#29](https://github.com/diffend-io/diffend-ruby/pull/29))
|
21
|
+
- handle request server errors ([#30](https://github.com/diffend-io/diffend-ruby/pull/30))
|
22
|
+
- better detection of gem source ([#31](https://github.com/diffend-io/diffend-ruby/pull/31))
|
23
|
+
- detect if we are running outdated version of the plugin ([#32](https://github.com/diffend-io/diffend-ruby/pull/32))
|
24
|
+
|
25
|
+
## [0.2.23] (2020-09-06)
|
26
|
+
- fix how we build gem platform ([#26](https://github.com/diffend-io/diffend-ruby/pull/26))
|
27
|
+
- test against jruby, ruby-2.5 and ruby-2.6 ([#25](https://github.com/diffend-io/diffend-ruby/pull/25))
|
28
|
+
|
29
|
+
## [0.2.22] (2020-09-03)
|
30
|
+
- fix how we build host command
|
31
|
+
|
32
|
+
## [0.2.21] (2020-09-03)
|
33
|
+
- bring back support for ruby 2.5.x
|
34
|
+
|
35
|
+
## [0.2.20] (2020-09-03)
|
36
|
+
- expose host command ([#21](https://github.com/diffend-io/diffend-ruby/pull/21))
|
37
|
+
- expose host pid ([#20](https://github.com/diffend-io/diffend-ruby/pull/20))
|
38
|
+
- use `Bundler.feature_flag.default_cli_command` which is used as the default task if no command provided, instead of `Diffend::Commands::INSTALL` ([#19](https://github.com/diffend-io/diffend-ruby/pull/19))
|
39
|
+
- better error handling ([#18](https://github.com/diffend-io/diffend-ruby/pull/18))
|
40
|
+
- better detection of gem versions ([#17](https://github.com/diffend-io/diffend-ruby/pull/17))
|
41
|
+
- introduce `Diffend::BuildBundlerDefinition` ([#16](https://github.com/diffend-io/diffend-ruby/pull/16))
|
42
|
+
|
5
43
|
## [0.2.19] (2020-08-18)
|
6
44
|
|
7
45
|
- better detection of gem sources ([#13](https://github.com/diffend-io/diffend-ruby/pull/13))
|
@@ -22,7 +60,15 @@
|
|
22
60
|
|
23
61
|
- initial release
|
24
62
|
|
25
|
-
[master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.
|
63
|
+
[master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.27...HEAD
|
64
|
+
[0.2.27]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.26...v0.2.27
|
65
|
+
[0.2.26]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.25...v0.2.26
|
66
|
+
[0.2.25]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.24...v0.2.25
|
67
|
+
[0.2.24]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.23...v0.2.24
|
68
|
+
[0.2.23]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.22...v0.2.23
|
69
|
+
[0.2.22]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.21...v0.2.22
|
70
|
+
[0.2.21]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.20...v0.2.21
|
71
|
+
[0.2.20]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.19...v0.2.20
|
26
72
|
[0.2.19]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.18...v0.2.19
|
27
73
|
[0.2.18]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.17...v0.2.18
|
28
74
|
[0.2.17]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.16...v0.2.17
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
diffend (0.2.
|
4
|
+
diffend (0.2.27)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
byebug (11.1.3)
|
10
|
+
coderay (1.1.3)
|
10
11
|
diff-lcs (1.4.4)
|
12
|
+
ffi (1.13.1-java)
|
13
|
+
method_source (1.0.0)
|
14
|
+
pry (0.13.1-java)
|
15
|
+
coderay (~> 1.1)
|
16
|
+
method_source (~> 1.0)
|
17
|
+
spoon (~> 0.0)
|
11
18
|
rake (13.0.1)
|
12
19
|
rspec (3.9.0)
|
13
20
|
rspec-core (~> 3.9.0)
|
@@ -22,14 +29,18 @@ GEM
|
|
22
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
30
|
rspec-support (~> 3.9.0)
|
24
31
|
rspec-support (3.9.3)
|
32
|
+
spoon (0.0.6)
|
33
|
+
ffi
|
25
34
|
|
26
35
|
PLATFORMS
|
36
|
+
java
|
27
37
|
ruby
|
28
38
|
|
29
39
|
DEPENDENCIES
|
30
40
|
bundler
|
31
41
|
byebug
|
32
42
|
diffend!
|
43
|
+
pry
|
33
44
|
rake
|
34
45
|
rspec
|
35
46
|
|
data/lib/diffend.rb
CHANGED
@@ -5,16 +5,23 @@
|
|
5
5
|
].each(&method(:require))
|
6
6
|
|
7
7
|
%w[
|
8
|
+
build_bundler_definition
|
8
9
|
errors
|
9
10
|
config/fetcher
|
10
11
|
config/file_finder
|
11
12
|
config/validator
|
12
13
|
commands
|
14
|
+
handle_errors/messages
|
15
|
+
handle_errors/build_exception_payload
|
16
|
+
handle_errors/display_to_stdout
|
17
|
+
handle_errors/report
|
18
|
+
request_object
|
19
|
+
request
|
13
20
|
voting
|
21
|
+
track
|
14
22
|
].each { |file| require "diffend/#{file}" }
|
15
23
|
|
16
24
|
%w[
|
17
|
-
request
|
18
25
|
versions/local
|
19
26
|
versions/remote
|
20
27
|
].each { |file| require "diffend/voting/#{file}" }
|
@@ -22,7 +29,7 @@
|
|
22
29
|
# Diffend main namespace
|
23
30
|
module Diffend
|
24
31
|
# Current plugin version
|
25
|
-
VERSION = '0.2.
|
32
|
+
VERSION = '0.2.27'
|
26
33
|
# Diffend homepage
|
27
34
|
HOMEPAGE = 'https://diffend.io'
|
28
35
|
|
@@ -30,35 +37,106 @@ module Diffend
|
|
30
37
|
# Registers the plugin and add before install all hook
|
31
38
|
def register
|
32
39
|
Bundler::Plugin.add_hook('before-install-all') do |_|
|
33
|
-
|
34
|
-
command,
|
35
|
-
build_definition(command)
|
36
|
-
)
|
40
|
+
execute
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
# Execute diffend plugin
|
45
|
+
def execute
|
46
|
+
return unless enabled?
|
47
|
+
|
48
|
+
verify_version
|
49
|
+
|
50
|
+
config = fetch_config
|
47
51
|
|
48
|
-
|
52
|
+
Diffend::Voting.call(
|
53
|
+
command,
|
54
|
+
config,
|
55
|
+
Diffend::BuildBundlerDefinition.call(
|
56
|
+
command,
|
57
|
+
Bundler.default_gemfile,
|
58
|
+
Bundler.default_lockfile
|
59
|
+
)
|
60
|
+
)
|
61
|
+
rescue Diffend::Errors::HandledException
|
62
|
+
return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true'
|
49
63
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
64
|
+
exit 255
|
65
|
+
rescue StandardError => e
|
66
|
+
Diffend::HandleErrors::Report.call(
|
67
|
+
exception: e,
|
68
|
+
config: config,
|
69
|
+
message: :unhandled_exception,
|
70
|
+
report: true,
|
71
|
+
raise_exception: false
|
54
72
|
)
|
73
|
+
|
74
|
+
return if ENV['DIFFEND_IGNORE_ERRORS'] == 'true'
|
75
|
+
|
76
|
+
exit 255
|
77
|
+
end
|
78
|
+
|
79
|
+
def verify_version
|
80
|
+
return if ENV['DIFFEND_DEVELOPMENT'] == 'true'
|
81
|
+
return if installed_version == VERSION
|
82
|
+
|
83
|
+
build_outdated_version_message(installed_version)
|
84
|
+
.tap(&Bundler.ui.method(:error))
|
85
|
+
|
86
|
+
exit 2
|
87
|
+
end
|
88
|
+
|
89
|
+
# @return [String] installed plugin version
|
90
|
+
def installed_version
|
91
|
+
Bundler::Plugin
|
92
|
+
.index
|
93
|
+
.plugin_path('diffend')
|
94
|
+
.basename
|
95
|
+
.to_s
|
96
|
+
.split('-')
|
97
|
+
.last
|
98
|
+
end
|
99
|
+
|
100
|
+
# Checks if plugin is enabled
|
101
|
+
#
|
102
|
+
# @return [Boolean] true if enabled, false otherwise
|
103
|
+
def enabled?
|
104
|
+
Bundler
|
105
|
+
.default_gemfile
|
106
|
+
.read
|
107
|
+
.split("\n")
|
108
|
+
.reject(&:empty?)
|
109
|
+
.map(&:strip)
|
110
|
+
.select { |line| line.start_with?('plugin') }
|
111
|
+
.any? { |line| line.include?('diffend') }
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param version [Hash] installed version
|
115
|
+
#
|
116
|
+
# @return [String]
|
117
|
+
def build_outdated_version_message(version)
|
118
|
+
<<~MSG
|
119
|
+
\nYou are running an outdated version (#{version}) of the plugin, which will lead to issues.
|
120
|
+
\nPlease upgrade to the latest one (#{VERSION}) by executing "rm -rf .bundle/plugin".\n
|
121
|
+
MSG
|
55
122
|
end
|
56
123
|
|
57
124
|
# Command that was run with bundle
|
58
125
|
#
|
59
126
|
# @return [String]
|
60
127
|
def command
|
61
|
-
ARGV.first ||
|
128
|
+
ARGV.first || Bundler.feature_flag.default_cli_command.to_s
|
129
|
+
end
|
130
|
+
|
131
|
+
# Fetch diffend config file
|
132
|
+
#
|
133
|
+
# @return [OpenStruct, nil] configuration object
|
134
|
+
#
|
135
|
+
# @raise [Errors::MissingConfigurationFile] when no config file
|
136
|
+
def fetch_config
|
137
|
+
Config::Fetcher.call(
|
138
|
+
File.expand_path('..', Bundler.bin_path)
|
139
|
+
)
|
62
140
|
end
|
63
141
|
end
|
64
142
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
# Builds bundler definition used within the plugin
|
5
|
+
module BuildBundlerDefinition
|
6
|
+
class << self
|
7
|
+
# Build clean instance of bundler definition, as we don't want to pollute the main one
|
8
|
+
#
|
9
|
+
# @param command [String] bundler command that we are executing
|
10
|
+
# @param gemfile [String] path to Gemfile
|
11
|
+
# @param lockfile [String] path to Gemfile.lock
|
12
|
+
#
|
13
|
+
# @return [Bundler::Definition]
|
14
|
+
def call(command, gemfile, lockfile)
|
15
|
+
unlock = command == 'update' ? true : nil
|
16
|
+
|
17
|
+
Bundler.configure
|
18
|
+
Bundler::Fetcher.disable_endpoint = nil
|
19
|
+
|
20
|
+
Bundler::Definition
|
21
|
+
.build(gemfile, lockfile, unlock)
|
22
|
+
.tap(&:validate_runtime!)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/diffend/commands.rb
CHANGED
@@ -3,9 +3,11 @@
|
|
3
3
|
module Diffend
|
4
4
|
# Modules grouping supported bundler commands
|
5
5
|
module Commands
|
6
|
-
#
|
6
|
+
# Bundler install command
|
7
7
|
INSTALL = 'install'
|
8
|
-
#
|
8
|
+
# Bundler update command
|
9
9
|
UPDATE = 'update'
|
10
|
+
# Bundler exec command
|
11
|
+
EXEC = 'exec'
|
10
12
|
end
|
11
13
|
end
|
@@ -27,16 +27,20 @@ module Diffend
|
|
27
27
|
build(build_path)
|
28
28
|
rescue Errors::MissingConfigurationFile
|
29
29
|
Bundler.ui.error(build_missing_error_message(build_path))
|
30
|
-
|
30
|
+
|
31
|
+
raise Diffend::Errors::HandledException
|
31
32
|
rescue Errors::EmptyConfigurationFile
|
32
33
|
Bundler.ui.error(build_empty_error_message(build_path))
|
33
|
-
|
34
|
+
|
35
|
+
raise Diffend::Errors::HandledException
|
34
36
|
rescue Errors::MalformedConfigurationFile
|
35
37
|
Bundler.ui.error(build_malformed_error_message(build_path))
|
36
|
-
|
38
|
+
|
39
|
+
raise Diffend::Errors::HandledException
|
37
40
|
rescue *MISSING_KEY_ERRORS => e
|
38
41
|
Bundler.ui.error(build_missing_key_error_message(e))
|
39
|
-
|
42
|
+
|
43
|
+
raise Diffend::Errors::HandledException
|
40
44
|
end
|
41
45
|
|
42
46
|
private
|
data/lib/diffend/errors.rb
CHANGED
@@ -19,9 +19,9 @@ module Diffend
|
|
19
19
|
ShareableKeyMissingInConfigurationFile = Class.new(BaseError)
|
20
20
|
# Raised when build_path is missing in configuration file
|
21
21
|
BuildPathMissingInConfigurationFile = Class.new(BaseError)
|
22
|
-
#
|
23
|
-
|
24
|
-
#
|
25
|
-
|
22
|
+
# Raised when server-side error occurs
|
23
|
+
RequestServerError = Class.new(BaseError)
|
24
|
+
# Raised when we had an exception that we know how to handle
|
25
|
+
HandledException = Class.new(BaseError)
|
26
26
|
end
|
27
27
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Diffend
|
6
|
+
module HandleErrors
|
7
|
+
# Module responsible for building exception payload
|
8
|
+
module BuildExceptionPayload
|
9
|
+
class << self
|
10
|
+
# Build exception payload
|
11
|
+
#
|
12
|
+
# @param exception [Exception, NilClass] expection that was raised
|
13
|
+
# @param payload [Hash] with versions to check
|
14
|
+
#
|
15
|
+
# @return [Hash]
|
16
|
+
def call(exception, payload)
|
17
|
+
{
|
18
|
+
request_id: SecureRandom.uuid,
|
19
|
+
payload: payload,
|
20
|
+
exception: {
|
21
|
+
class: exception&.class,
|
22
|
+
message: exception&.message,
|
23
|
+
backtrace: exception&.backtrace
|
24
|
+
}
|
25
|
+
}.freeze
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
module HandleErrors
|
5
|
+
# Module responsible for displaying exception payload to stdout
|
6
|
+
module DisplayToStdout
|
7
|
+
class << self
|
8
|
+
# Display exception payload to stdout
|
9
|
+
#
|
10
|
+
# @param exception_payload [Hash]
|
11
|
+
def call(exception_payload)
|
12
|
+
puts exception_payload.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Diffend
|
4
|
+
module HandleErrors
|
5
|
+
module Messages
|
6
|
+
PAYLOAD_DUMP = '^^^ Above is the dump of your request ^^^'
|
7
|
+
UNHANDLED_EXCEPTION = <<~MSG
|
8
|
+
\nSomething went really wrong. We recorded this incident in our system and will review it.\n
|
9
|
+
This is a bug, don't hesitate.\n
|
10
|
+
Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
|
11
|
+
MSG
|
12
|
+
UNSUPPORTED_RESPONSE = <<~MSG
|
13
|
+
\nAPI returned an unsupported response. We recorded this incident in our system and will review it.\n
|
14
|
+
This is a bug, don't hesitate.\n
|
15
|
+
Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
|
16
|
+
MSG
|
17
|
+
UNSUPPORTED_VERDICT = <<~MSG
|
18
|
+
\nAPI returned an unsupported verdict. We recorded this incident in our system and will review it.\n
|
19
|
+
This is a bug, don't hesitate.\n
|
20
|
+
Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
|
21
|
+
MSG
|
22
|
+
REQUEST_ERROR = <<~MSG
|
23
|
+
\nWe were unable to process your request at this time. We recorded this incident in our system and will review it.\n
|
24
|
+
If you think that this is a bug, don't hesitate.\n
|
25
|
+
Create an issue at https://github.com/diffend-io/diffend-ruby/issues\n
|
26
|
+
MSG
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|