git_ownership_insights 1.0.4 → 1.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: eed900c5cbbf25ebae6d25b453a5d994518875986a5fd757d7554b546d9a7dbe
4
- data.tar.gz: c63e8d5565b97f970bc80c0b311f131116a619fa93743270e08395d99a3d8cf3
3
+ metadata.gz: 6b7a7be3eb274378081cac3ffa1c7698dcc17dc1ea5e8dd61b3bfbdedfdee55c
4
+ data.tar.gz: 68011fb06d78d3eee4d47e3dcf3bf68e79c759d03acbfee3edaa525d8627d8bc
5
5
  SHA512:
6
- metadata.gz: 7229e4d3b818bd48dc85dd88aada8f259f7d2ea0bb4e96e0947700e367d9d3d87250e4cb5107c30fe71bc34543085e675c9f30028c87eb6d5b43b575ac0a4957
7
- data.tar.gz: 2b061059f5ff9b61ec3ee80b71df8e54cb8b6ed157c5e49c175e6c72f3c2cac40b59ebc7d78fc1b9202b108eb546f188dee3ed61a71bef8a39953fa56c8573dd
6
+ metadata.gz: 2782093b040f0947b82f0ad29633628afda6ac83824e1532ba8157f569efc7199f11c29b8055ec11073b1436efcb890a5ccff44450aadf1ae17c5c3fcb48d1cc
7
+ data.tar.gz: 1e7017a0f1cb0bfe93ff9c6a1193de0fd78f59bf4d17fd0834c4a2390af8dd7fab16680aafd0bc5ffb04b175454c395a2cbea2d79f30f758f04e105335d0aabe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_ownership_insights (1.0.4)
4
+ git_ownership_insights (1.0.6)
5
5
  date
6
6
  pry
7
7
 
@@ -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,8 +247,6 @@ 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"
229
-
230
250
  # Filter files based on extension and size
231
251
  filtered_files = file_team_map.select do |file_path|
232
252
  next unless File.exist?(file_path)
@@ -236,16 +256,31 @@ def contribution_message(directory_path:, duration_in_days:, begin_time:, debug:
236
256
  end
237
257
 
238
258
  filtered_top_touched_files = filtered_files.sort_by { |element, count| [-count.last, element] }
259
+
260
+ puts "Timeframe: #{(begin_time - duration_in_days).strftime('%Y-%m-%d')} to #{begin_time.strftime('%Y-%m-%d')}"
261
+ puts " Hotspot Code Changes: #{churn_count} (#{hotspot_changes_percentage.round(2)}%)"
262
+ puts " Cross-Squad File Dependencies Count: #{teams_count}"
263
+ puts " Files exceeding #{BIG_FILE_SIZE} lines with multiple contributors: #{filtered_top_touched_files.count}"
264
+ count_hotspot_lines(filtered_files.keys)
239
265
  count_big_files(directory_path)
240
- puts " Total files longer than #{BIG_FILE_SIZE} lines with multiple contributors: #{filtered_top_touched_files.count}\n"
266
+ 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)}%"
267
+ puts " Total amount of code changes: #{total_changes}"
268
+ puts " Total files changed: #{code_files_with_changes.count}"
269
+ puts " Total files in the folder: #{file_count}"
270
+ puts " Contributors: #{contributors}"
271
+
241
272
  if HOTSPOT
273
+ puts "\n"
274
+ puts " Hotspot changes:"
242
275
  filtered_top_touched_files.each do |line|
243
- puts " #{line.first.gsub(directory_path, '')} Contributors: #{line.last.first} Commits: #{line.last.last}"
276
+ puts " #{line.first.gsub(directory_path, '')} Contributors: #{line.last.first} Commits: #{line.last.last}"
244
277
  end
245
278
  end
246
- puts "\n\n"
279
+
247
280
 
248
281
  if CODEOWNERS
282
+ puts "\n"
283
+ puts "Code ownership data:"
249
284
  codeowners = read_codeowners_file
250
285
 
251
286
  owners_data = Hash.new do |hash, key|
@@ -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.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serghei Moret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date