github_repo_statistics 2.3.5 → 2.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd986a058fd4af9648d2900297d60aaf9a8f53d76f2a58c6a50adbfb40411d0
|
4
|
+
data.tar.gz: 4e3c39e106d2e4bd0776f4806c0329a49e7279798c48fce3561d342cd47306c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe19b7e6e44588af15ce682f7b2a0a0e3a219d5c4c4d7ba041e33ff57869adc1093f6219681329e16279680cd37913d3bb1815b00eebb97b16309c960cdc975
|
7
|
+
data.tar.gz: 5636c1a35d16b9cddcd0084bd41423833a3b607d9ebcad0338caa02e62e7a23e17a301e0a1b62ef3283612b75affcd4f113efec6bba8de333be0b0879547d575
|
data/bin/github_repo_statistics
CHANGED
@@ -78,6 +78,16 @@ OptionParser.new do |opts|
|
|
78
78
|
options[:code_extension] = code_extension
|
79
79
|
end
|
80
80
|
|
81
|
+
opts.on('--team-to-focus STRING',
|
82
|
+
'The team identifier to focus for the metric collection [default: ""]') do |team_to_focus|
|
83
|
+
options[:team_to_focus] = team_to_focus
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on('--codeowner-to-focus STRING',
|
87
|
+
'The codeowner identifier to focus for the metric collection [default: ""]') do |codeowner_to_focus|
|
88
|
+
options[:codeowner_to_focus] = codeowner_to_focus
|
89
|
+
end
|
90
|
+
|
81
91
|
opts.on('--output-to-files',
|
82
92
|
'Puts the output for hotspot and codeowners into files instead of the STDOUT (useful for CI and big amount of data) [default:false]') do
|
83
93
|
options[:file_output] = true
|
@@ -112,6 +122,8 @@ FILE_OUTPUT = options[:file_output] || false
|
|
112
122
|
CODE_EXTENSIONS = options[:code_extension] ? options[:code_extension].split(',') : ['.swift', '.kt']
|
113
123
|
EXCLUDED_FILES = options[:excluded_files]
|
114
124
|
EXCLUDED_PRS = options[:excluded_prs]
|
125
|
+
TEAM_TO_FOCUS = options[:team_to_focus]
|
126
|
+
CODEOWNER_TO_FOCUS = options[:codeowner_to_focus]
|
115
127
|
|
116
128
|
unless CI
|
117
129
|
puts "\nDirectory: #{REPO_PATH}\n"
|
@@ -150,10 +150,24 @@ class GithubRepoStatistics
|
|
150
150
|
File.foreach(file).reject { |line| line.match(%r{^\s*(//|/\*.*\*/|\s*$)}) }.count
|
151
151
|
end
|
152
152
|
|
153
|
-
def filter_existing_code_files(files)
|
153
|
+
def filter_existing_code_files(files, start_date, end_date)
|
154
154
|
files.select do |f|
|
155
155
|
next unless File.exist?(f)
|
156
156
|
|
157
|
+
git_log = git_commit_info(file: f, start_date:, end_date:).split("\n")
|
158
|
+
|
159
|
+
teams = git_log.map do |team|
|
160
|
+
team.match(/#{TEAM_REGEX}/)[0].upcase
|
161
|
+
end.reject { |e| EXCLUSIONS&.include?(e) }
|
162
|
+
|
163
|
+
if TEAM_TO_FOCUS && CODEOWNER_TO_FOCUS
|
164
|
+
next if !teams.include?(TEAM_TO_FOCUS) && !find_owner(file: f).include?(CODEOWNER_TO_FOCUS)
|
165
|
+
elsif TEAM_TO_FOCUS
|
166
|
+
next unless teams.include?(TEAM_TO_FOCUS)
|
167
|
+
elsif CODEOWNER_TO_FOCUS
|
168
|
+
next unless find_owner(file: f).include?(CODEOWNER_TO_FOCUS)
|
169
|
+
end
|
170
|
+
|
157
171
|
if EXCLUDED_FILES
|
158
172
|
excluded_patterns = EXCLUDED_FILES.split(',')
|
159
173
|
next if excluded_patterns.any? { |pattern| f.include?(pattern) }
|
@@ -245,10 +259,11 @@ class GithubRepoStatistics
|
|
245
259
|
start_date = @begin_time.to_time.to_i - duration_in_days * 86_400
|
246
260
|
end_date = @begin_time.to_time.to_i
|
247
261
|
git_ls = git_files(directory_path: @directory_path)
|
248
|
-
file_count = filter_existing_code_files(git_ls.split).count
|
262
|
+
file_count = filter_existing_code_files(git_ls.split, start_date, end_date).count
|
249
263
|
all_files_with_changes = files_with_changes(directory_path: @directory_path, start_date:, end_date:).split.sort
|
250
|
-
code_files_with_changes = filter_existing_code_files(all_files_with_changes)
|
264
|
+
code_files_with_changes = filter_existing_code_files(all_files_with_changes, start_date, end_date)
|
251
265
|
uniq_code_files_with_changes = code_files_with_changes.uniq
|
266
|
+
|
252
267
|
all_teams, cross_teams_count, single_ownership_teams_count, files_changed_by_many_teams, total_changes, file_team_map = analyze_changed_files(
|
253
268
|
uniq_code_files_with_changes:, start_date:, end_date:
|
254
269
|
)
|
@@ -20,7 +20,7 @@ class ReleaseMergeReport
|
|
20
20
|
puts "#{branch}: #{count}"
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
ENV['BQ_CREDENTIALS'] = `cat /Users/serghei.moret/.config/gcloud/application_default_credentials.json`
|
24
24
|
|
25
25
|
export_to_bigquery(grouped_branch_counts) if ENV['BQ_CREDENTIALS']
|
26
26
|
|
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.3.
|
4
|
+
version: 2.3.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-05-
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: date
|