kennel 1.11.3 → 1.12.0
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
- data/lib/kennel/syncer.rb +21 -13
- data/lib/kennel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7114ffae96587ada9ea64441476daf3caf82f1149c877e9529a598651f25eece
|
4
|
+
data.tar.gz: 57986d14b955e2b392f68742e40b2284d8a3d36e67a8bce8d71c57ee35842145
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f205bdb359a2ce62a6d4564e89b9e13ebc7faed6ce3e7ec41fdff29a03ea86b9017c8cfcfe1c347ce4f77d7ed895fd5606f6373638cad92a30b5e49d5e5425e
|
7
|
+
data.tar.gz: 6619e5a232fe196deabcf5ef48d80ab01733f93922b842762cdd6baf705b5e72e70193d0f36eedb1bd53e21dd63804701797b6f491547a797b1dc3f24b3d04b2
|
data/lib/kennel/syncer.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
module Kennel
|
3
3
|
class Syncer
|
4
4
|
CACHE_FILE = "tmp/cache/details" # keep in sync with .travis.yml caching
|
5
|
+
TRACKING_FIELDS = [:message, :description].freeze
|
5
6
|
|
6
7
|
def initialize(api, expected, project: nil)
|
7
8
|
@api = api
|
@@ -28,6 +29,8 @@ module Kennel
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def update
|
32
|
+
block_irreversible_partial_changes
|
33
|
+
|
31
34
|
@create.each do |_, e|
|
32
35
|
reply = @api.create e.class.api_resource, e.as_json
|
33
36
|
reply = unnest(e.class.api_resource, reply)
|
@@ -54,11 +57,11 @@ module Kennel
|
|
54
57
|
def calculate_diff
|
55
58
|
@update = []
|
56
59
|
@delete = []
|
57
|
-
actual = Progress.progress
|
58
|
-
filter_by_project! download_definitions
|
59
|
-
end
|
60
|
+
actual = Progress.progress("Downloading definitions") { download_definitions }
|
60
61
|
|
61
62
|
Progress.progress "Diffing" do
|
63
|
+
filter_by_project! actual
|
64
|
+
|
62
65
|
details_cache do |cache|
|
63
66
|
actual.each do |a|
|
64
67
|
id = a.fetch(:id)
|
@@ -66,9 +69,7 @@ module Kennel
|
|
66
69
|
if e = delete_matching_expected(a)
|
67
70
|
fill_details(a, cache) if e.class::API_LIST_INCOMPLETE
|
68
71
|
diff = e.diff(a)
|
69
|
-
if diff.any?
|
70
|
-
@update << [id, e, a, diff]
|
71
|
-
end
|
72
|
+
@update << [id, e, a, diff] if diff.any?
|
72
73
|
elsif tracking_id(a) # was previously managed
|
73
74
|
@delete << [id, nil, a]
|
74
75
|
end
|
@@ -168,14 +169,21 @@ module Kennel
|
|
168
169
|
end
|
169
170
|
end
|
170
171
|
|
172
|
+
def block_irreversible_partial_changes
|
173
|
+
return unless @project_filter
|
174
|
+
return if
|
175
|
+
@delete.none? &&
|
176
|
+
@update.none? { |_, e, _, diff| e.id && diff.any? { |_, field| TRACKING_FIELDS.include?(field.to_sym) } }
|
177
|
+
|
178
|
+
raise "Partial updates should not modify resources with an id, since these changes are irreversible"
|
179
|
+
end
|
180
|
+
|
171
181
|
def filter_by_project!(definitions)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
182
|
+
return unless @project_filter
|
183
|
+
definitions.select! do |a|
|
184
|
+
id = tracking_id(a)
|
185
|
+
!id || id.start_with?("#{@project_filter}:")
|
177
186
|
end
|
178
|
-
definitions
|
179
187
|
end
|
180
188
|
|
181
189
|
def add_tracking_id(e)
|
@@ -189,7 +197,7 @@ module Kennel
|
|
189
197
|
end
|
190
198
|
|
191
199
|
def tracking_field(a)
|
192
|
-
|
200
|
+
TRACKING_FIELDS.detect { |f| a.key?(f) }
|
193
201
|
end
|
194
202
|
end
|
195
203
|
end
|
data/lib/kennel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kennel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|