danger-dangermattic 1.2.3 → 1.2.4
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/dangermattic/gem_version.rb +1 -1
- data/lib/dangermattic/plugins/manifest_pr_checker.rb +12 -7
- data/lib/dangermattic/plugins/pr_size_checker.rb +10 -12
- data/spec/pr_size_checker_spec.rb +13 -12
- 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: ad580440b78f9c9bd16790cb679c1a38a2ab32f22e9936f12e88398cef578a9f
|
4
|
+
data.tar.gz: ca179653e7759647821a2653f659ff04d56d38ce725993a31454f493180f1ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a30553a0ff163ac72fa5492fc6db0047bf8e7569241a8cdce1de71bf8e8224703a271ca32afe0947ba61a751bcfbb048ed744c22e527513a2d0ae26adbd40ef0
|
7
|
+
data.tar.gz: f7657a8e47f25a63169a0e965a067792df749ee3fd8468199744dff509083f8b292da4475bef161bd38edcfe3acbf1c747e7a929d24136b3cd59bce0130e408c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -115,13 +115,19 @@ module Danger
|
|
115
115
|
private
|
116
116
|
|
117
117
|
def check_manifest_lock_updated(file_name:, lock_file_name:, instruction:, report_type: :warning)
|
118
|
+
all_files = git_utils.all_changed_files
|
119
|
+
|
118
120
|
# Find all the modified manifest files
|
119
|
-
manifest_modified_files =
|
121
|
+
manifest_modified_files = all_files.select { |f| File.basename(f) == file_name }
|
122
|
+
|
123
|
+
# Build a hash mapping directory -> set of basenames for O(1) lookup
|
124
|
+
files_by_dir = all_files.group_by { |f| File.dirname(f) }
|
125
|
+
.transform_values { |files| files.to_set { |f| File.basename(f) } }
|
120
126
|
|
121
127
|
# For each manifest file, check if the corresponding lockfile (in the same dir) was also modified
|
122
128
|
manifest_modified_files.each do |manifest_file|
|
123
|
-
|
124
|
-
next if
|
129
|
+
manifest_dir = File.dirname(manifest_file)
|
130
|
+
next if files_by_dir[manifest_dir]&.include?(lock_file_name)
|
125
131
|
|
126
132
|
message = format(MESSAGE, manifest_file, lock_file_name, instruction)
|
127
133
|
reporter.report(message: message, type: report_type)
|
@@ -129,11 +135,10 @@ module Danger
|
|
129
135
|
end
|
130
136
|
|
131
137
|
def check_manifest_lock_updated_strict(manifest_path:, manifest_lock_path:, instruction:, report_type: :warning)
|
132
|
-
|
133
|
-
return unless manifest_modified
|
138
|
+
all_files_set = git_utils.all_changed_files.to_set
|
134
139
|
|
135
|
-
|
136
|
-
return if
|
140
|
+
return unless all_files_set.include?(manifest_path)
|
141
|
+
return if all_files_set.include?(manifest_lock_path)
|
137
142
|
|
138
143
|
message = format(MESSAGE, manifest_path, File.basename(manifest_lock_path), instruction)
|
139
144
|
reporter.report(message: message, type: report_type)
|
@@ -76,13 +76,12 @@ module Danger
|
|
76
76
|
def insertions_size(file_selector: nil)
|
77
77
|
return danger.git.insertions unless file_selector
|
78
78
|
|
79
|
-
|
79
|
+
# Only check added and modified files - deleted files have 0 insertions
|
80
|
+
filtered_files = git_utils.added_and_modified_files.select(&file_selector)
|
80
81
|
|
81
82
|
filtered_files.sum do |file|
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
danger.git.info_for_file(file)&.[](:insertions).to_i
|
83
|
+
# Use cached stats directly instead of calling info_for_file for each file
|
84
|
+
danger.git.diff.stats[:files][file]&.[](:insertions).to_i
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
@@ -97,10 +96,8 @@ module Danger
|
|
97
96
|
filtered_files = git_utils.all_changed_files.select(&file_selector)
|
98
97
|
|
99
98
|
filtered_files.sum do |file|
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
danger.git.info_for_file(file)&.[](:deletions).to_i
|
99
|
+
# Use cached stats directly instead of calling info_for_file for each file
|
100
|
+
danger.git.diff.stats[:files][file]&.[](:deletions).to_i
|
104
101
|
end
|
105
102
|
end
|
106
103
|
|
@@ -115,10 +112,11 @@ module Danger
|
|
115
112
|
filtered_files = git_utils.all_changed_files.select(&file_selector)
|
116
113
|
|
117
114
|
filtered_files.sum do |file|
|
118
|
-
#
|
119
|
-
|
115
|
+
# Use cached stats directly instead of calling info_for_file for each file
|
116
|
+
stats = danger.git.diff.stats[:files][file]
|
117
|
+
next 0 unless stats
|
120
118
|
|
121
|
-
|
119
|
+
stats[:deletions].to_i + stats[:insertions].to_i
|
122
120
|
end
|
123
121
|
end
|
124
122
|
end
|
@@ -146,19 +146,20 @@ module Danger
|
|
146
146
|
allow(@plugin.git).to receive_messages(added_files: [added_config, added_file], modified_files: [modified_file1, modified_file2, added_test_file, modified_strings], deleted_files: [deleted_file1, deleted_test_file, deleted_strings, deleted_file2])
|
147
147
|
|
148
148
|
allow(@plugin.git).to receive(:diff).and_return(instance_double(Git::Diff))
|
149
|
-
|
149
|
+
# Populate stats hash directly with insertions/deletions data for the optimized code path
|
150
|
+
expected_files = {
|
151
|
+
added_test_file => { insertions: 201 },
|
152
|
+
added_config => { insertions: 311 },
|
153
|
+
added_file => { insertions: 13 },
|
154
|
+
modified_file1 => { insertions: 127, deletions: 159 },
|
155
|
+
modified_file2 => { insertions: 43, deletions: 37 },
|
156
|
+
modified_strings => { insertions: 432, deletions: 297 },
|
157
|
+
deleted_file1 => { deletions: 246 },
|
158
|
+
deleted_file2 => { deletions: 493 },
|
159
|
+
deleted_test_file => { deletions: 222 },
|
160
|
+
deleted_strings => { deletions: 593 }
|
161
|
+
}
|
150
162
|
allow(@plugin.git.diff).to receive(:stats).and_return({ files: expected_files })
|
151
|
-
|
152
|
-
allow(@plugin.git).to receive(:info_for_file).with(added_test_file).and_return({ insertions: 201 })
|
153
|
-
allow(@plugin.git).to receive(:info_for_file).with(added_config).and_return({ insertions: 311 })
|
154
|
-
allow(@plugin.git).to receive(:info_for_file).with(added_file).and_return({ insertions: 13 })
|
155
|
-
allow(@plugin.git).to receive(:info_for_file).with(modified_file1).and_return({ insertions: 127, deletions: 159 })
|
156
|
-
allow(@plugin.git).to receive(:info_for_file).with(modified_file2).and_return({ insertions: 43, deletions: 37 })
|
157
|
-
allow(@plugin.git).to receive(:info_for_file).with(modified_strings).and_return({ insertions: 432, deletions: 297 })
|
158
|
-
allow(@plugin.git).to receive(:info_for_file).with(deleted_file1).and_return({ deletions: 246 })
|
159
|
-
allow(@plugin.git).to receive(:info_for_file).with(deleted_file2).and_return({ deletions: 493 })
|
160
|
-
allow(@plugin.git).to receive(:info_for_file).with(deleted_test_file).and_return({ deletions: 222 })
|
161
|
-
allow(@plugin.git).to receive(:info_for_file).with(deleted_strings).and_return({ deletions: 593 })
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-dangermattic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Automattic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09
|
11
|
+
date: 2025-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|