git_ownership_insights 2.0.5 → 2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e95410a234ad6fdf3d9684a28da2dcd3515cb77c3f949fa0c2e97723cb6e76f
|
4
|
+
data.tar.gz: e212afe069ae204cd8f2eb8b07a49774dd64de590945940da812e6c4048ab111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b9ea8b6441df0167ff471a2118a293c5e250dbecc817a330985a29ab950d12b59d8de1c24cb2b2b275fbfc842500174deeb906d792e6d51338adc905c62d919
|
7
|
+
data.tar.gz: d08540070983653aa3216aab3a3e7b01d46e36e35666cc7ca0e7d4307e7d7995742628b781704397a8dcfa633cfce82cd8d34d2f78f33eb13bed559aaa7d810a
|
data/Gemfile.lock
CHANGED
data/bin/git_ownership_insights
CHANGED
@@ -83,6 +83,11 @@ OptionParser.new do |opts|
|
|
83
83
|
options[:code_extension] = code_extension
|
84
84
|
end
|
85
85
|
|
86
|
+
opts.on('--output-to-files',
|
87
|
+
'Puts the output for hotspot and codeowners into files instead of the STDOUT (useful for CI and big amount of data) [default:false]') do
|
88
|
+
options[:file_output] = true
|
89
|
+
end
|
90
|
+
|
86
91
|
opts.on('-v', '--version', 'Display the version of the gem') do
|
87
92
|
puts "git_ownership_insights version #{GitOwnershipInsights::VERSION}"
|
88
93
|
exit
|
@@ -110,6 +115,7 @@ CI = options[:ci] || false
|
|
110
115
|
DEFAULT_BRANCH = options[:default_branch] || 'master'
|
111
116
|
CODEOWNERS = options[:codeowners] || false
|
112
117
|
HOTSPOT = options[:hotspot_files] || false
|
118
|
+
FILE_OUTPUT = options[:file_output] || false
|
113
119
|
CODE_EXTENSIONS = options[:code_extension] ? options[:code_extension].split(',') : ['.swift', '.kt']
|
114
120
|
EXCLUDED_FILES = options[:excluded_files]
|
115
121
|
|
@@ -127,6 +133,7 @@ unless CI
|
|
127
133
|
puts "CODEOWNERS output is: #{options[:codeowners] ? 'on' : 'off'}\n"
|
128
134
|
puts "Limit of the teams shown in codeownership data: #{TOP_CONTRIBUTED_TEAMS}"
|
129
135
|
puts "Limit of the files shown in codeownership data: #{TOP_TOUCHED_FILES}"
|
136
|
+
puts "Output to file mode is: #{options[:file_output] ? 'on' : 'off'}\n"
|
130
137
|
puts "CI mode is: #{options[:ci] ? 'on' : 'off'}\n"
|
131
138
|
puts "Debug mode is: #{options[:debug] ? 'on' : 'off'}\n\n"
|
132
139
|
end
|
@@ -54,8 +54,7 @@ class GitOwnershipInsights
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def handle_codeowners(file_team_map:)
|
57
|
-
|
58
|
-
puts '*Code ownership data:*'
|
57
|
+
output = "\n *Code ownership data:*\n"
|
59
58
|
codeowners = read_codeowners_file
|
60
59
|
|
61
60
|
owners_data = Hash.new do |hash, key|
|
@@ -82,19 +81,26 @@ class GitOwnershipInsights
|
|
82
81
|
|
83
82
|
converted_team_map = file_team_map.transform_keys { |key| File.basename(key) }
|
84
83
|
|
85
|
-
puts ' Codeownership data:'
|
86
84
|
top_owners_data.each do |owner, data|
|
87
|
-
|
85
|
+
output += "\n #{owner.split('/').last}:\n Total Count: #{data[:churn_count]}\n"
|
88
86
|
data[:directories].each do |dir, dir_data|
|
89
|
-
|
87
|
+
output += " Directory: #{dir}\n Top files:\n"
|
90
88
|
dir_data[:files].each do |file_data|
|
91
89
|
next if converted_team_map[File.basename(file_data[:name])].nil?
|
92
90
|
|
93
91
|
contributors = converted_team_map[file_data[:name]]&.first&.empty? ? ['Excluded contributor'] : converted_team_map[file_data[:name]].first
|
94
|
-
|
92
|
+
output += " #{File.basename(file_data[:name])} - #{file_data[:count].last} #{contributors}}"
|
95
93
|
end
|
96
94
|
end
|
97
95
|
end
|
96
|
+
|
97
|
+
if FILE_OUTPUT
|
98
|
+
File.open('codeowners.txt', 'w') do |f|
|
99
|
+
f.puts output
|
100
|
+
end
|
101
|
+
else
|
102
|
+
puts output
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
def find_owner(file:)
|
@@ -255,14 +261,22 @@ class GitOwnershipInsights
|
|
255
261
|
puts " *Contributors:* #{contributors}"
|
256
262
|
|
257
263
|
if HOTSPOT
|
258
|
-
|
259
|
-
|
264
|
+
hotspot_output = "\n *Hotspot files(#{filtered_top_touched_files.count}):*\n"
|
265
|
+
|
260
266
|
filtered_top_touched_files.each do |line|
|
261
|
-
|
267
|
+
hotspot_output += "\n"
|
262
268
|
file = line.first
|
263
269
|
contributors = line.last.first
|
264
270
|
commits = line.last.last
|
265
|
-
|
271
|
+
hotspot_output += " #{file.gsub(@directory_path, '')} Contributors: #{contributors} Commits: #{commits} Owner: #{find_owner(file:)}"
|
272
|
+
end
|
273
|
+
|
274
|
+
if FILE_OUTPUT
|
275
|
+
File.open('hotspot.txt', 'w') do |f|
|
276
|
+
f.puts hotspot_output
|
277
|
+
end
|
278
|
+
else
|
279
|
+
puts hotspot_output
|
266
280
|
end
|
267
281
|
end
|
268
282
|
|
@@ -15,6 +15,7 @@ RSpec.describe GitOwnershipInsights do
|
|
15
15
|
HOTSPOT = true
|
16
16
|
CODE_EXTENSIONS = ['.swift', '.kt'].freeze
|
17
17
|
EXCLUDED_FILES = 'ignore'
|
18
|
+
FILE_OUTPUT = false
|
18
19
|
|
19
20
|
let(:dummy_directory_path) { 'spec/fixtures' }
|
20
21
|
let(:duration_in_days) { 7 }
|
@@ -56,11 +57,12 @@ RSpec.describe GitOwnershipInsights do
|
|
56
57
|
*Current total of [".swift", ".kt"] files in the folder:* 4
|
57
58
|
*Contributors:* {"FIOS"=>5, "FAND"=>2}
|
58
59
|
|
59
|
-
*Hotspot
|
60
|
-
|
60
|
+
*Hotspot files(1):*
|
61
|
+
|
62
|
+
/file1.swift Contributors: ["FIOS", "FAND"] Commits: 3 Owner: ["FIOS"]
|
63
|
+
|
64
|
+
*Code ownership data:*
|
61
65
|
|
62
|
-
*Code ownership data:*
|
63
|
-
Codeownership data:
|
64
66
|
FIOS:
|
65
67
|
Total Count: 3
|
66
68
|
Directory: spec/fixtures
|
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: 2.0.
|
4
|
+
version: 2.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
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: date
|