github_repo_statistics 2.2.18 → 2.2.20
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: 41a049be21c83dce57e60dc938dff6824d47a007a98a28292667ce56118450bc
|
4
|
+
data.tar.gz: a78b853dd82721c83dd10fe17db33f199f084143264c8f0fe991a252b645d7f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7296fd692ec8d1fca369a8b4eef1ef7839b1c5ba6ec1f924d7eca834df8ab01eb590223314669006c9bf00b55e99c35f2d7089bd70900108ab1a0f2c91de22b9
|
7
|
+
data.tar.gz: 5066e055e2ba835d681df98e3cf7e988c48c96480541c418e28ff97f6b7bea7a7194e873f6e8dd69da36e20244b8f5b54abdb724f909774edd8f574bf9feb704
|
data/Gemfile.lock
CHANGED
@@ -178,6 +178,7 @@ class GithubRepoStatistics
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def git_commit_info(file:, start_date:, end_date:)
|
181
|
+
puts "File: #{file}, Start: #{start_date}, End: #{end_date}, Now: #{Time.now}" if @debug
|
181
182
|
`git log --pretty=format:"%s" --since="#{start_date}" --until="#{end_date}" --follow -- "#{file}"`
|
182
183
|
end
|
183
184
|
|
@@ -192,6 +193,7 @@ class GithubRepoStatistics
|
|
192
193
|
filename = File.basename(file)
|
193
194
|
commit_count = git_commit_count(file:, start_date:, end_date:).to_i
|
194
195
|
git_log = git_commit_info(file:, start_date:, end_date:).split("\n")
|
196
|
+
puts git_log if @debug
|
195
197
|
teams = git_log.map do |team|
|
196
198
|
team.match(/#{TEAM_REGEX}/)[0].upcase
|
197
199
|
end.reject { |e| EXCLUSIONS&.include?(e) }
|
@@ -214,12 +216,12 @@ class GithubRepoStatistics
|
|
214
216
|
file_team_map]
|
215
217
|
end
|
216
218
|
|
217
|
-
def filter_files(file_team_map:)
|
219
|
+
def filter_files(file_team_map:, size: BIG_FILE_SIZE)
|
218
220
|
file_team_map.select do |file_path|
|
219
221
|
next unless File.exist?(file_path)
|
220
222
|
|
221
223
|
# Check if the file size is more than BIG_FILE_SIZE lines (excluding empty and commented lines)
|
222
|
-
File.foreach(file_path).reject { |line| line.match(%r{^\s*(//|/\*.*\*/|\s*$)}) }.count >
|
224
|
+
File.foreach(file_path).reject { |line| line.match(%r{^\s*(//|/\*.*\*/|\s*$)}) }.count > size.to_i
|
223
225
|
end
|
224
226
|
end
|
225
227
|
|
@@ -316,7 +318,7 @@ class GithubRepoStatistics
|
|
316
318
|
if HOTSPOT
|
317
319
|
hotspot_output = []
|
318
320
|
|
319
|
-
|
321
|
+
filter_files(file_team_map: file_team_map, size: 0).each do |line|
|
320
322
|
file = line.first
|
321
323
|
contributors = line.last.first
|
322
324
|
lines_of_code = count_lines_of_code(file)
|
@@ -349,9 +351,9 @@ class GithubRepoStatistics
|
|
349
351
|
|
350
352
|
return unless @steps.positive?
|
351
353
|
|
352
|
-
system("git checkout `git rev-list -1 --before='#{(@begin_time -
|
354
|
+
system("git checkout `git rev-list -1 --before='#{(@begin_time - 115).strftime('%B %d %Y')}' HEAD`",
|
353
355
|
%i[out err] => File::NULL)
|
354
|
-
@begin_time -=
|
356
|
+
@begin_time -= 115
|
355
357
|
contribution_message
|
356
358
|
end
|
357
359
|
end
|
@@ -12,16 +12,15 @@ class ReleaseMergeReport
|
|
12
12
|
def report
|
13
13
|
branch_counts = count_merged_pull_requests_per_branch
|
14
14
|
grouped_branch_counts = group_branch_counts(branch_counts)
|
15
|
-
require 'pry'
|
16
|
-
binding.pry
|
17
|
-
|
15
|
+
# require 'pry'
|
16
|
+
# binding.pry
|
18
17
|
# Print the grouped branch counts
|
19
18
|
puts 'Branches with Merged Pull Requests:'
|
20
19
|
grouped_branch_counts.each do |branch, count|
|
21
20
|
puts "#{branch}: #{count}"
|
22
21
|
end
|
23
22
|
|
24
|
-
ENV['BQ_CREDENTIALS'] = `cat /Users/serghei.moret/.config/gcloud/application_default_credentials.json`
|
23
|
+
# ENV['BQ_CREDENTIALS'] = `cat /Users/serghei.moret/.config/gcloud/application_default_credentials.json`
|
25
24
|
|
26
25
|
export_to_bigquery(grouped_branch_counts) if ENV['BQ_CREDENTIALS']
|
27
26
|
|
@@ -35,7 +34,7 @@ class ReleaseMergeReport
|
|
35
34
|
client.auto_paginate = true
|
36
35
|
|
37
36
|
tags = client.tags(@repo)
|
38
|
-
|
37
|
+
branch_info = Hash.new { |hash, key| hash[key] = { count: 0, teams: [], tribes: []} }
|
39
38
|
|
40
39
|
tags.each do |tag|
|
41
40
|
next if !tag.name.match?(/^(v23|v24)\./) && !tag.name.match?(/^(23|24)\./)
|
@@ -50,31 +49,46 @@ class ReleaseMergeReport
|
|
50
49
|
pull_requests = client.pull_requests(@repo, state: 'closed', sort: 'updated', direction: 'desc', base: branch_name)
|
51
50
|
.select { |pr| pr.merged_at }
|
52
51
|
|
53
|
-
|
52
|
+
pull_requests.each do |pr|
|
53
|
+
branch_info[branch_name][:count] += 1
|
54
|
+
|
55
|
+
# Extract team identifiers from the pull request labels
|
56
|
+
teams = pr.labels.map { |label| label.name.match(/^squad:\s*(.*)$/i)&.captures }.compact.flatten
|
57
|
+
tribes = pr.labels.map { |label| label.name.match(/^tribe:\s*(.*)$/i)&.captures }.compact.flatten
|
58
|
+
branch_info[branch_name][:teams].push(teams)
|
59
|
+
branch_info[branch_name][:tribes].push(tribes)
|
60
|
+
end
|
61
|
+
branch_info[branch_name][:count] = 0 if branch_info[branch_name].nil?
|
54
62
|
end
|
55
63
|
|
56
|
-
|
64
|
+
branch_info
|
57
65
|
end
|
58
66
|
|
59
|
-
def group_branch_counts(
|
60
|
-
patch_counts = Hash.new
|
61
|
-
hotfix_counts = Hash.new { |hash, key| hash[key] =
|
67
|
+
def group_branch_counts(branch_info)
|
68
|
+
patch_counts = Hash.new { |hash, key| hash[key] = { count: 0, teams: [], tribes: []} }
|
69
|
+
hotfix_counts = Hash.new { |hash, key| hash[key] = { count: 0, teams: [], tribes: []} }
|
62
70
|
|
63
|
-
|
71
|
+
branch_info.each do |branch, info|
|
64
72
|
major_minor_version, patch_version = branch.match(/^#{@branch_prefix}(\d+\.\d+)(?:\.(\d+))?/)&.captures
|
65
73
|
|
66
74
|
if patch_version.nil?
|
67
75
|
# Branch is a patch version
|
68
|
-
patch_counts[major_minor_version] += count
|
69
|
-
|
76
|
+
patch_counts[major_minor_version][:count] += info[:count]
|
77
|
+
patch_counts[major_minor_version][:teams] += info[:teams]
|
78
|
+
patch_counts[major_minor_version][:tribes] += info[:tribes]
|
79
|
+
|
80
|
+
|
81
|
+
elsif info[:count] > 0
|
70
82
|
# Branch is a hotfix version
|
71
|
-
hotfix_counts[major_minor_version][
|
83
|
+
hotfix_counts[major_minor_version][:count] += info[:count]
|
84
|
+
hotfix_counts[major_minor_version][:teams] += info[:teams]
|
85
|
+
hotfix_counts[major_minor_version][:tribes] += info[:tribes]
|
72
86
|
end
|
73
87
|
end
|
74
88
|
|
75
89
|
# Sum up the counts for hotfix versions within the same major and minor version
|
76
|
-
hotfix_counts.each do |major_minor_version,
|
77
|
-
hotfix_counts[major_minor_version] =
|
90
|
+
hotfix_counts.each do |major_minor_version, hotfix_info|
|
91
|
+
hotfix_counts[major_minor_version][:count] = hotfix_info[:count]
|
78
92
|
end
|
79
93
|
|
80
94
|
{ patch_versions: patch_counts, hotfix_versions: hotfix_counts }
|
@@ -92,20 +106,55 @@ class ReleaseMergeReport
|
|
92
106
|
|
93
107
|
date = DateTime.now
|
94
108
|
|
95
|
-
branch_counts.each do |branch, count|
|
109
|
+
branch_counts[:patch_versions].each do |branch, count|
|
110
|
+
# Construct JSON string for teams
|
111
|
+
teams_json = count[:teams].map { |team| "'#{team}'" }.join(',')
|
112
|
+
tribes_json = count[:tribes].map { |tribes| "'#{tribes}'" }.join(',')
|
113
|
+
|
114
|
+
# Construct the SQL query
|
96
115
|
query = <<~SQL
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
116
|
+
MERGE INTO release_merges AS target
|
117
|
+
USING (SELECT '#{branch}' AS release, '#{@repo}' AS platform) AS source
|
118
|
+
ON target.release = source.release AND target.platform = source.platform
|
119
|
+
WHEN MATCHED THEN
|
120
|
+
UPDATE SET
|
121
|
+
target.merge_count = #{count[:count]},
|
122
|
+
target.timestamp = '#{date}',
|
123
|
+
target.contributors = ARRAY[#{teams_json}],
|
124
|
+
target.contributors_tribe = ARRAY[#{tribes_json}]
|
125
|
+
WHEN NOT MATCHED THEN
|
126
|
+
INSERT (release, merge_count, platform, timestamp, contributors, contributors_tribe)
|
127
|
+
VALUES ('#{branch}', #{count[:count]}, '#{@repo}', '#{date}', ARRAY[#{teams_json}], ARRAY[#{tribes_json}]);
|
107
128
|
SQL
|
129
|
+
|
130
|
+
# Execute the query
|
131
|
+
dataset.query(query)
|
132
|
+
|
133
|
+
# Update the date
|
108
134
|
date -= 7
|
135
|
+
end
|
136
|
+
|
137
|
+
branch_counts[:hotfix_versions].each do |branch, count|
|
138
|
+
# Construct JSON string for teams
|
139
|
+
teams_json = count[:teams].map { |team| "'#{team}'" }.join(',')
|
140
|
+
tribes_json = count[:tribes].map { |tribes| "'#{tribes}'" }.join(',')
|
141
|
+
|
142
|
+
# Construct the SQL query
|
143
|
+
query = <<~SQL
|
144
|
+
MERGE INTO release_merges AS target
|
145
|
+
USING (SELECT '#{branch}' AS release, '#{@repo}' AS platform) AS source
|
146
|
+
ON target.release = source.release AND target.platform = source.platform
|
147
|
+
WHEN MATCHED THEN
|
148
|
+
UPDATE SET
|
149
|
+
target.hotfix_count = #{count[:count]},
|
150
|
+
target.contributors_hotfixes = ARRAY[#{teams_json}],
|
151
|
+
target.contributors_hotfixes_tribe = ARRAY[#{tribes_json}]
|
152
|
+
WHEN NOT MATCHED THEN
|
153
|
+
INSERT (release, hotfix_count, platform, contributors_hotfixes, contributors_hotfixes_tribe )
|
154
|
+
VALUES ('#{branch}', #{count[:count]}, '#{@repo}', ARRAY[#{teams_json}], ARRAY[#{tribes_json}]);
|
155
|
+
SQL
|
156
|
+
|
157
|
+
# Execute the query
|
109
158
|
dataset.query(query)
|
110
159
|
end
|
111
160
|
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.2.
|
4
|
+
version: 2.2.20
|
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-04-
|
11
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: date
|