github_repo_statistics 2.2.28 → 2.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2992ae14c4b2bab0ffc8cdee2c5c2e33a0b7dcc08f2fdb62b194975e944dd625
|
4
|
+
data.tar.gz: 43837ce970edb37d1f52fc88a97a4799d7cf72d33057788d06e71bee9e90e4e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1566d02371061b2a29bd5177438c5fc399c0e554144f110940b686b865c6f7959ca7f7bd54db700ae4745725d430457ec7508c8eb5be0ebf3cbd682c5efca3d
|
7
|
+
data.tar.gz: f13509d5a8de4daa42c02a5194b3814a75d2110b15ab63b0cfb503ac6d2a76aa75d9d1a496b613b723e6f3596ea0d113ba59577f738ae501a1b2d762161a03dd
|
@@ -181,6 +181,10 @@ class GithubRepoStatistics
|
|
181
181
|
`git log origin/master --pretty=format:"%s" --since="#{start_date}" --until="#{end_date}" -- "#{file}"`
|
182
182
|
end
|
183
183
|
|
184
|
+
def new_changes?(file:)
|
185
|
+
git_commit_info(file:, start_date: DateTime.now - 1, end_date: DateTime.now) == "" ? false : true
|
186
|
+
end
|
187
|
+
|
184
188
|
def analyze_changed_files(uniq_code_files_with_changes:, start_date:, end_date:)
|
185
189
|
all_teams = []
|
186
190
|
cross_teams_count = 0
|
@@ -192,6 +196,13 @@ class GithubRepoStatistics
|
|
192
196
|
filename = File.basename(file)
|
193
197
|
commit_count = git_commit_count(file:, start_date:, end_date:).to_i
|
194
198
|
git_log = git_commit_info(file:, start_date:, end_date:).split("\n")
|
199
|
+
prs = git_log.map do |pr|
|
200
|
+
match = pr.match(/#(\d+)/)
|
201
|
+
if match
|
202
|
+
match[0]
|
203
|
+
end
|
204
|
+
end.uniq
|
205
|
+
|
195
206
|
teams = git_log.map do |team|
|
196
207
|
team.match(/#{TEAM_REGEX}/)[0].upcase
|
197
208
|
end.reject { |e| EXCLUSIONS&.include?(e) }
|
@@ -202,7 +213,7 @@ class GithubRepoStatistics
|
|
202
213
|
|
203
214
|
if teams.count > 1
|
204
215
|
files_changed_by_many_teams += 1
|
205
|
-
file_team_map.merge!(file.to_s => [teams, commit_count])
|
216
|
+
file_team_map.merge!(file.to_s => [teams, prs, commit_count])
|
206
217
|
cross_teams_count += teams.count
|
207
218
|
else
|
208
219
|
single_ownership_teams_count += 1
|
@@ -238,7 +249,7 @@ class GithubRepoStatistics
|
|
238
249
|
occurrences = all_teams.flatten.compact.tally
|
239
250
|
sorted_occurrences = occurrences.sort_by { |element, count| [-count, element] }
|
240
251
|
contributors = Hash[sorted_occurrences]
|
241
|
-
churn_count = file_team_map.values.map { |value| value
|
252
|
+
churn_count = file_team_map.values.map { |value| value.last }.sum
|
242
253
|
hotspot_changes_percentage = ((churn_count.to_f / total_changes) * 100).round(2)
|
243
254
|
# Filter files based on extension, existence and size
|
244
255
|
filtered_files = filter_files(file_team_map:)
|
@@ -322,15 +333,17 @@ class GithubRepoStatistics
|
|
322
333
|
lines_of_code = count_lines_of_code(file)
|
323
334
|
commits = line.last.last
|
324
335
|
owner = find_owner(file:)
|
336
|
+
prs = line.last[1]
|
337
|
+
new_change = new_changes?(file:)
|
325
338
|
|
326
|
-
hotspot_output << [file.gsub(@directory_path, ''), contributors, lines_of_code, commits, owner]
|
339
|
+
hotspot_output << [file.gsub(@directory_path, ''), new_change, contributors, lines_of_code, commits, owner, prs]
|
327
340
|
end
|
328
341
|
|
329
|
-
hotspot_output.sort_by! { |row| -row[
|
342
|
+
hotspot_output.sort_by! { |row| -row[3] }
|
330
343
|
|
331
344
|
if FILE_OUTPUT
|
332
345
|
CSV.open('hotspot.csv', 'w') do |csv|
|
333
|
-
csv << ['File', 'Contributors', 'Lines', 'Commits', 'Owner']
|
346
|
+
csv << ['File', 'New change', 'Contributors', 'Lines', 'Commits', 'Owner', 'PRs']
|
334
347
|
hotspot_output.each do |row|
|
335
348
|
csv << row
|
336
349
|
end
|
@@ -338,7 +351,7 @@ class GithubRepoStatistics
|
|
338
351
|
else
|
339
352
|
puts "\n *Hotspot files(#{filtered_top_touched_files.count}):*\n"
|
340
353
|
hotspot_output.each do |row|
|
341
|
-
puts " #{row[0]} Contributors: #{row[1]}
|
354
|
+
puts " #{row[0]} Contributors: #{row[1]} New change: #{row[2]} Lines: #{row[3]} Commits: #{row[4]} Owner: #{row[5]} PRs: #{row[6]}"
|
342
355
|
end
|
343
356
|
end
|
344
357
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_repo_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
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-05-
|
11
|
+
date: 2024-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: date
|