github_repo_statistics 2.2.19 → 2.2.21
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22715ee89ab9a04e544646b19dd848c758661fd16583844d71a11dbe44428b5f
|
4
|
+
data.tar.gz: 52f34b4a141f1408f50c1615d55785e28d7a6ce1052d7e18ff714a9d108bc570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbc8035a098fc62d186f2c4db8345d334f137f7df0e7d3ef660ae42e506d4930df8f22d1eea36894041b058f49718fb9139cec3ba73d72184e9371696fa2352f
|
7
|
+
data.tar.gz: ded920b5c06400ed83b02b5da34a61663398e76214c86c74e7713bd49cd249eb6eb9d7f1446af6127c9e7465520f68e6d1a4257475abbe8cd7ad5be2b555340c
|
data/Gemfile.lock
CHANGED
@@ -178,7 +178,10 @@ class GithubRepoStatistics
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def git_commit_info(file:, start_date:, end_date:)
|
181
|
-
|
181
|
+
puts "File: #{file}, Start: #{start_date}, End: #{end_date}, Now: #{Time.now}" if @debug
|
182
|
+
res = `git log --pretty=format:"%s" --since="#{start_date}" --until="#{end_date}" --follow -- "#{file}"`
|
183
|
+
puts res if @debug
|
184
|
+
res
|
182
185
|
end
|
183
186
|
|
184
187
|
def analyze_changed_files(uniq_code_files_with_changes:, start_date:, end_date:)
|
@@ -192,6 +195,7 @@ class GithubRepoStatistics
|
|
192
195
|
filename = File.basename(file)
|
193
196
|
commit_count = git_commit_count(file:, start_date:, end_date:).to_i
|
194
197
|
git_log = git_commit_info(file:, start_date:, end_date:).split("\n")
|
198
|
+
puts git_log if @debug
|
195
199
|
teams = git_log.map do |team|
|
196
200
|
team.match(/#{TEAM_REGEX}/)[0].upcase
|
197
201
|
end.reject { |e| EXCLUSIONS&.include?(e) }
|
@@ -349,9 +353,9 @@ class GithubRepoStatistics
|
|
349
353
|
|
350
354
|
return unless @steps.positive?
|
351
355
|
|
352
|
-
system("git checkout `git rev-list -1 --before='#{(@begin_time -
|
356
|
+
system("git checkout `git rev-list -1 --before='#{(@begin_time - 115).strftime('%B %d %Y')}' HEAD`",
|
353
357
|
%i[out err] => File::NULL)
|
354
|
-
@begin_time -=
|
358
|
+
@begin_time -= 115
|
355
359
|
contribution_message
|
356
360
|
end
|
357
361
|
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.21
|
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
|