pronto-rails_migrations_annotated 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e35554920a786374696461d01c168c4ca1402367fac9a70a5b7773d0319fdaea
4
- data.tar.gz: 58b72c0c38bd9c18c10d336ebb71da9571f6cb04e728ef4c1eabeddb7a321c83
3
+ metadata.gz: 89475a6adfbe75efa5ddedde4bf3a3903fa0af08a785d87a879e41f1cee58736
4
+ data.tar.gz: 19a2822864b7098ea985950b20a25980fc8ef4139d82172a6734eea1041941fc
5
5
  SHA512:
6
- metadata.gz: f2b895e654cf9b9b170d344093615014760d9fe377fedf8ccadf65c13817a5ce7fb7d9ea0a4d2e2ff9343e3ba366b53555614a6f36405ec1ff1f16ed652142d6
7
- data.tar.gz: 86b29d8e6fc2783fdb70311d0613ce673db46af9f0934cbcb7ec321665f0651ccef4b673f0d059c043a2574ebe5d349be379b2d417aa6f04b8826d1f8bd1ef77
6
+ metadata.gz: 5a945a8d9e39a13b05826b34766efbdd634ce3529f7e937987e78933152d3fa1e9752df40debc0f82d83664a703c389df33975617009c9bb601c11bbb5e4eb50
7
+ data.tar.gz: 123f8d704e85d0748e1abea9d2bcc491fd2d2d788a4f18fddbe6e7a0a68fe1fc30212c13725e3fa0b5936d6b428657e92871990f92f767a40802ff4e4b96d5ac
data/Gemfile.lock CHANGED
@@ -1,45 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pronto-rails_migrations_annotated (0.0.5)
4
+ pronto-rails_migrations_annotated (0.0.6)
5
5
  pronto (~> 0.11)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.8.1)
10
+ addressable (2.8.6)
11
11
  public_suffix (>= 2.0.2, < 6.0)
12
12
  ast (2.4.2)
13
13
  diff-lcs (1.4.4)
14
- faraday (2.5.2)
15
- faraday-net_http (>= 2.0, < 3.1)
16
- ruby2_keywords (>= 0.0.4)
17
- faraday-net_http (3.0.0)
14
+ faraday (2.9.0)
15
+ faraday-net_http (>= 2.0, < 3.2)
16
+ faraday-net_http (3.1.0)
17
+ net-http
18
18
  gitlab (4.19.0)
19
19
  httparty (~> 0.20)
20
20
  terminal-table (>= 1.5.1)
21
- httparty (0.20.0)
22
- mime-types (~> 3.0)
21
+ httparty (0.21.0)
22
+ mini_mime (>= 1.0.0)
23
23
  multi_xml (>= 0.5.2)
24
- mime-types (3.4.1)
25
- mime-types-data (~> 3.2015)
26
- mime-types-data (3.2022.0105)
24
+ mini_mime (1.1.5)
27
25
  multi_xml (0.6.0)
28
- octokit (4.25.1)
26
+ net-http (0.4.1)
27
+ uri
28
+ octokit (7.2.0)
29
29
  faraday (>= 1, < 3)
30
30
  sawyer (~> 0.9)
31
31
  parallel (1.21.0)
32
32
  parser (3.0.2.0)
33
33
  ast (~> 2.4.1)
34
- pronto (0.11.0)
35
- gitlab (~> 4.4, >= 4.4.0)
36
- httparty (>= 0.13.7)
37
- octokit (~> 4.7, >= 4.7.0)
34
+ pronto (0.11.2)
35
+ gitlab (>= 4.4.0, < 5.0)
36
+ httparty (>= 0.13.7, < 1.0)
37
+ octokit (>= 4.7.0, < 8.0)
38
38
  rainbow (>= 2.2, < 4.0)
39
- rexml (~> 3.2)
40
- rugged (>= 0.23.0, < 1.1.0)
39
+ rexml (>= 3.2.5, < 4.0)
40
+ rugged (>= 0.23.0, < 2.0)
41
41
  thor (>= 0.20.3, < 2.0)
42
- public_suffix (5.0.0)
42
+ public_suffix (5.0.4)
43
43
  rainbow (3.0.0)
44
44
  rake (13.0.6)
45
45
  regexp_parser (2.1.1)
@@ -76,17 +76,18 @@ GEM
76
76
  rubocop-rspec (2.6.0)
77
77
  rubocop (~> 1.19)
78
78
  ruby-progressbar (1.11.0)
79
- ruby2_keywords (0.0.5)
80
- rugged (1.0.1)
79
+ rugged (1.7.1)
81
80
  sawyer (0.9.2)
82
81
  addressable (>= 2.3.5)
83
82
  faraday (>= 0.17.3, < 3)
84
83
  terminal-table (3.0.2)
85
84
  unicode-display_width (>= 1.1.1, < 3)
86
- thor (1.2.1)
85
+ thor (1.3.0)
87
86
  unicode-display_width (1.8.0)
87
+ uri (0.13.0)
88
88
 
89
89
  PLATFORMS
90
+ arm64-darwin-22
90
91
  x86_64-darwin-21
91
92
 
92
93
  DEPENDENCIES
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pronto
4
4
  module RailsMigrationsAnnotatedVersion
5
- VERSION = "0.0.5"
5
+ VERSION = "0.0.6"
6
6
  end
7
7
  end
@@ -25,7 +25,9 @@ module Pronto
25
25
  private
26
26
 
27
27
  def add_message_at_patch(patches, message, level = :warning, line: :first)
28
- patches = [patches] unless patches.is_a?(Array)
28
+ patches = [patches].compact unless patches.is_a?(Array)
29
+ raise "Patch not found for message (#{message.inspect})" if patches.empty?
30
+
29
31
  patches.each do |patch|
30
32
  target_line = case line
31
33
  when :first then patch.added_lines.first || patch.lines.first
@@ -122,7 +124,7 @@ module Pronto
122
124
  "Migration #{wrong_version} is missing from structure.sql", :error)
123
125
  end
124
126
 
125
- return if structure_patches.any? || found_missing_migration
127
+ return if structure_patches.any? || found_missing_migration || migration_patches.none?
126
128
 
127
129
  add_message_at_patch(migration_patches, "Migration file detected, but no changes in structure.sql")
128
130
  end
@@ -150,8 +152,23 @@ module Pronto
150
152
 
151
153
  def check_structure_versions_sorted(versions_from_schema)
152
154
  return if versions_from_schema == versions_from_schema.sort
155
+ return if versions_from_schema == versions_from_schema.sort.reverse
156
+
157
+ # guess sort order by lower offending migrations count
158
+ offending = [
159
+ versions_from_schema.each_cons(2).select { |(a, b)| a > b }, # if ascending
160
+ versions_from_schema.each_cons(2).select { |(a, b)| a < b } # if sort is desc
161
+ ].min_by(&:size).flat_map { |pair| pair.map { |line| line.gsub(/[^0-9]+/, "") } }
162
+
163
+ if structure_patches.none?
164
+ puts "WARNING: structure.sql migrations are not sorted (not in changes, offending #{offending.join(', ')})"
165
+ return
166
+ end
167
+
168
+ offending_regex = Regexp.union(offending)
153
169
 
154
170
  add_message_at_patch(
171
+ structure_patches.first { |patch| patch.lines.any? { |line| line.content.match?(offending_regex) } } ||
155
172
  structure_patches.first { |patch| patch.lines.any? { |line| line.content.match?(migration_line_regex) } },
156
173
  "Migration versions must be sorted and have correct syntax"
157
174
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-rails_migrations_annotated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-19 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.1.6
67
+ rubygems_version: 3.4.10
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Pronto runner to check rails migrations to be separate from other code, but