git_ownership_insights 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eed900c5cbbf25ebae6d25b453a5d994518875986a5fd757d7554b546d9a7dbe
4
- data.tar.gz: c63e8d5565b97f970bc80c0b311f131116a619fa93743270e08395d99a3d8cf3
3
+ metadata.gz: dc9c0c038149e42cd56b515168124dd68d50476169deedd38e98cb8593770106
4
+ data.tar.gz: bc3e24fb12aac9bf7e94e6649b61b4941d1dfba20a7cc23f4ba56e566631faa1
5
5
  SHA512:
6
- metadata.gz: 7229e4d3b818bd48dc85dd88aada8f259f7d2ea0bb4e96e0947700e367d9d3d87250e4cb5107c30fe71bc34543085e675c9f30028c87eb6d5b43b575ac0a4957
7
- data.tar.gz: 2b061059f5ff9b61ec3ee80b71df8e54cb8b6ed157c5e49c175e6c72f3c2cac40b59ebc7d78fc1b9202b108eb546f188dee3ed61a71bef8a39953fa56c8573dd
6
+ metadata.gz: 7638cb2568573d64238ba56438b9bb70e7a7ec6c9d28ac353e79c867d174039c04237103fc424cadd146d169bbce2014a8651445cc660ae2b7a06a7126bdb7cd
7
+ data.tar.gz: 5941142ba797b288b7a82e5a5b20edf91eb2c00cf754375743eccbb70e0ad31b8ce111f03f1c238746724d096f686b3f0b786c75432d3571e9b290eea7ae1284
@@ -167,12 +167,33 @@ def count_big_files(directory_path, size: BIG_FILE_SIZE)
167
167
  end
168
168
  end
169
169
 
170
- puts " Total number of files longer than #{size} lines: #{count}"
170
+ puts " Total number of code files longer than #{size} lines: #{count}"
171
+ end
172
+
173
+ def count_hotspot_lines(files)
174
+ code_files = files.select {|f|
175
+ extension = File.extname(f)
176
+ valid_extensions = ['.swift', '.kt']
177
+ valid_extensions.include?(extension)
178
+ }
179
+
180
+ # Initialize a counter for files that meet the criteria
181
+ count = 0
182
+
183
+ # Iterate through each file and check the line count
184
+ code_files.each do |file|
185
+ lines_count = File.foreach(file).reject { |line| line.match(/^\s*(\/\/|\/\*.*\*\/|\s*$)/) }.count
186
+
187
+ count += lines_count
188
+ end
189
+
190
+ puts " Total lines of hotspot code: #{count}"
171
191
  end
172
192
 
173
193
  def contribution_message(directory_path:, duration_in_days:, begin_time:, debug: nil, steps: nil)
174
194
  duration_in_days = duration_in_days.to_i
175
195
  all_teams = []
196
+ teams_count = 0
176
197
  files_changed_by_many_teams = 0
177
198
  total_changes = 0
178
199
  start_date = begin_time.to_time.to_i - duration_in_days * 86_400
@@ -213,6 +234,7 @@ def contribution_message(directory_path:, duration_in_days:, begin_time:, debug:
213
234
  if teams.count > 1
214
235
  files_changed_by_many_teams += 1
215
236
  file_team_map.merge!("#{file}" => [teams, commit_count])
237
+ teams_count += teams.count
216
238
  end
217
239
 
218
240
  puts "\n#{filename} [#{commit_count}]:#{teams}\n" if debug
@@ -225,7 +247,14 @@ def contribution_message(directory_path:, duration_in_days:, begin_time:, debug:
225
247
  churn_count = file_team_map.values.map { |value| value[1] }.sum
226
248
  hotspot_changes_percentage = (churn_count.to_f / total_changes.to_f)*100
227
249
 
228
- puts "Timeframe: #{(begin_time - duration_in_days).strftime('%Y-%m-%d')} to #{begin_time.strftime('%Y-%m-%d')}\n Code files with a single contributor: #{(100 - ((files_changed_by_many_teams.to_f / code_files_with_changes.count.to_f) * 100)).round(2)}%\n Hotspot code changes: #{churn_count} (#{hotspot_changes_percentage.round(2)}%)\n Amount of code changes: #{total_changes}\n Total files changed: #{code_files_with_changes.count}\n Total files in the folder: #{file_count}\n Contributors: #{contributors}\n"
250
+ puts "Timeframe: #{(begin_time - duration_in_days).strftime('%Y-%m-%d')} to #{begin_time.strftime('%Y-%m-%d')}"
251
+ puts " Code files with a single contributor: #{(100 - ((files_changed_by_many_teams.to_f / code_files_with_changes.count.to_f) * 100)).round(2)}%"
252
+ puts " Hotspot code changes: #{churn_count} (#{hotspot_changes_percentage.round(2)}%)"
253
+ puts " Total occurrences of cross-squad dependencies over same files: #{teams_count}"
254
+ puts " Amount of code changes: #{total_changes}"
255
+ puts " Total files changed: #{code_files_with_changes.count}"
256
+ puts " Total files in the folder: #{file_count}"
257
+ puts " Contributors: #{contributors}"
229
258
 
230
259
  # Filter files based on extension and size
231
260
  filtered_files = file_team_map.select do |file_path|
@@ -237,6 +266,7 @@ def contribution_message(directory_path:, duration_in_days:, begin_time:, debug:
237
266
 
238
267
  filtered_top_touched_files = filtered_files.sort_by { |element, count| [-count.last, element] }
239
268
  count_big_files(directory_path)
269
+ count_hotspot_lines(filtered_files.keys)
240
270
  puts " Total files longer than #{BIG_FILE_SIZE} lines with multiple contributors: #{filtered_top_touched_files.count}\n"
241
271
  if HOTSPOT
242
272
  filtered_top_touched_files.each do |line|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitOwnershipInsights
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_ownership_insights
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serghei Moret