git_ownership_insights 2.0.5 → 2.0.7
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: b2f6a04d3018e987e2762a5037c474904cf6602fded2e27f08df2789f0dc99c3
|
4
|
+
data.tar.gz: 8ae4f2dc116cf482b4ff0f7a10225e1d6aeefa4a1f7219a7909eca541a4a51f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef5dc57fa25ac45c1732177686c947bd30f373fce422a1208993da14e52a104f15ceab0902005c48b789428c2fcd6edac2e851303457ab21aaa7664ffde0a853
|
7
|
+
data.tar.gz: 0ee6b4f127938b0d4daa4e3f6b1e35491e79698af297bec7f96321313180fd4a2cf2a553727c5da3559879bbc152e2be175deac9ada09ebd210ce9d4c03a1b65
|
data/Gemfile.lock
CHANGED
data/bin/git_ownership_insights
CHANGED
@@ -54,16 +54,6 @@ OptionParser.new do |opts|
|
|
54
54
|
options[:team_regex] = team_regex
|
55
55
|
end
|
56
56
|
|
57
|
-
opts.on('--top-contributing-team STRING',
|
58
|
-
'Limit of top contributed to the directory teams in codeownership data [default: 5]') do |top_contributing_team|
|
59
|
-
options[:top_contributing_team] = top_contributing_team
|
60
|
-
end
|
61
|
-
|
62
|
-
opts.on('--top-touched-files STRING',
|
63
|
-
'Limit of top touched files by individual contributors in codeownership data [default: 5]') do |top_touched_files|
|
64
|
-
options[:top_touched_files] = top_touched_files
|
65
|
-
end
|
66
|
-
|
67
57
|
opts.on('--codeowners-path STRING', 'Path to CODEOWNERS file [default: .github/CODEOWNERS]') do |codeowners_path|
|
68
58
|
options[:codeowners_path] = codeowners_path
|
69
59
|
end
|
@@ -83,6 +73,11 @@ OptionParser.new do |opts|
|
|
83
73
|
options[:code_extension] = code_extension
|
84
74
|
end
|
85
75
|
|
76
|
+
opts.on('--output-to-files',
|
77
|
+
'Puts the output for hotspot and codeowners into files instead of the STDOUT (useful for CI and big amount of data) [default:false]') do
|
78
|
+
options[:file_output] = true
|
79
|
+
end
|
80
|
+
|
86
81
|
opts.on('-v', '--version', 'Display the version of the gem') do
|
87
82
|
puts "git_ownership_insights version #{GitOwnershipInsights::VERSION}"
|
88
83
|
exit
|
@@ -102,14 +97,13 @@ end.parse!
|
|
102
97
|
EXCLUSIONS = options[:exclusions]&.split(',')
|
103
98
|
REPO_PATH = options[:path] || '.'
|
104
99
|
TEAM_REGEX = options[:team_regex] || '[A-Za-z]+'
|
105
|
-
TOP_TOUCHED_FILES = options[:top_touched_files] || 5
|
106
|
-
TOP_CONTRIBUTED_TEAMS = options[:top_contributing_team] || 5
|
107
100
|
CODEOWNERS_PATH = options[:codeowners_path] || '.github/CODEOWNERS'
|
108
101
|
BIG_FILE_SIZE = options[:big_file_size] || 250
|
109
102
|
CI = options[:ci] || false
|
110
103
|
DEFAULT_BRANCH = options[:default_branch] || 'master'
|
111
104
|
CODEOWNERS = options[:codeowners] || false
|
112
105
|
HOTSPOT = options[:hotspot_files] || false
|
106
|
+
FILE_OUTPUT = options[:file_output] || false
|
113
107
|
CODE_EXTENSIONS = options[:code_extension] ? options[:code_extension].split(',') : ['.swift', '.kt']
|
114
108
|
EXCLUDED_FILES = options[:excluded_files]
|
115
109
|
|
@@ -125,8 +119,7 @@ unless CI
|
|
125
119
|
puts "Lines of code limit (big files) for the hotspot calculation: #{BIG_FILE_SIZE}"
|
126
120
|
puts "Hotspot detailed output is: #{options[:hotspot_files] ? 'on' : 'off'}\n"
|
127
121
|
puts "CODEOWNERS output is: #{options[:codeowners] ? 'on' : 'off'}\n"
|
128
|
-
puts "
|
129
|
-
puts "Limit of the files shown in codeownership data: #{TOP_TOUCHED_FILES}"
|
122
|
+
puts "Output to file mode is: #{options[:file_output] ? 'on' : 'off'}\n"
|
130
123
|
puts "CI mode is: #{options[:ci] ? 'on' : 'off'}\n"
|
131
124
|
puts "Debug mode is: #{options[:debug] ? 'on' : 'off'}\n\n"
|
132
125
|
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|
|
@@ -76,25 +75,28 @@ class GitOwnershipInsights
|
|
76
75
|
|
77
76
|
# Sort owners_data by total count in descending order
|
78
77
|
sorted_owners_data = owners_data.sort_by { |_, data| -data[:churn_count] }
|
79
|
-
|
80
|
-
# Take the last 5 elements
|
81
|
-
top_owners_data = sorted_owners_data.last(TOP_CONTRIBUTED_TEAMS.to_i)
|
82
|
-
|
83
78
|
converted_team_map = file_team_map.transform_keys { |key| File.basename(key) }
|
84
79
|
|
85
|
-
|
86
|
-
|
87
|
-
puts " #{owner.split('/').last}:\n Total Count: #{data[:churn_count]}"
|
80
|
+
sorted_owners_data.each do |owner, data|
|
81
|
+
output += "\n #{owner.split('/').last}:\n Total Count: #{data[:churn_count]}\n"
|
88
82
|
data[:directories].each do |dir, dir_data|
|
89
|
-
|
83
|
+
output += " Directory: #{dir}\n Top files:\n"
|
90
84
|
dir_data[:files].each do |file_data|
|
91
85
|
next if converted_team_map[File.basename(file_data[:name])].nil?
|
92
86
|
|
93
87
|
contributors = converted_team_map[file_data[:name]]&.first&.empty? ? ['Excluded contributor'] : converted_team_map[file_data[:name]].first
|
94
|
-
|
88
|
+
output += " #{File.basename(file_data[:name])} - #{file_data[:count].last} #{contributors}}"
|
95
89
|
end
|
96
90
|
end
|
97
91
|
end
|
92
|
+
|
93
|
+
if FILE_OUTPUT
|
94
|
+
File.open('codeowners.txt', 'w') do |f|
|
95
|
+
f.puts output
|
96
|
+
end
|
97
|
+
else
|
98
|
+
puts output
|
99
|
+
end
|
98
100
|
end
|
99
101
|
|
100
102
|
def find_owner(file:)
|
@@ -255,14 +257,22 @@ class GitOwnershipInsights
|
|
255
257
|
puts " *Contributors:* #{contributors}"
|
256
258
|
|
257
259
|
if HOTSPOT
|
258
|
-
|
259
|
-
|
260
|
+
hotspot_output = "\n *Hotspot files(#{filtered_top_touched_files.count}):*\n"
|
261
|
+
|
260
262
|
filtered_top_touched_files.each do |line|
|
261
|
-
|
263
|
+
hotspot_output += "\n"
|
262
264
|
file = line.first
|
263
265
|
contributors = line.last.first
|
264
266
|
commits = line.last.last
|
265
|
-
|
267
|
+
hotspot_output += " #{file.gsub(@directory_path, '')} Contributors: #{contributors} Commits: #{commits} Owner: #{find_owner(file:)}"
|
268
|
+
end
|
269
|
+
|
270
|
+
if FILE_OUTPUT
|
271
|
+
File.open('hotspot.txt', 'w') do |f|
|
272
|
+
f.puts hotspot_output
|
273
|
+
end
|
274
|
+
else
|
275
|
+
puts hotspot_output
|
266
276
|
end
|
267
277
|
end
|
268
278
|
|
@@ -5,8 +5,6 @@ require_relative '../lib/git_ownership_insights/git_ownership_insight'
|
|
5
5
|
RSpec.describe GitOwnershipInsights do
|
6
6
|
EXCLUSIONS = %w[exclusion1 exclusion2].freeze
|
7
7
|
TEAM_REGEX = '[A-Za-z]+'
|
8
|
-
TOP_TOUCHED_FILES = 5
|
9
|
-
TOP_CONTRIBUTED_TEAMS = 5
|
10
8
|
CODEOWNERS_PATH = '.github/CODEOWNERS'
|
11
9
|
BIG_FILE_SIZE = 250
|
12
10
|
CI = false
|
@@ -15,6 +13,7 @@ RSpec.describe GitOwnershipInsights do
|
|
15
13
|
HOTSPOT = true
|
16
14
|
CODE_EXTENSIONS = ['.swift', '.kt'].freeze
|
17
15
|
EXCLUDED_FILES = 'ignore'
|
16
|
+
FILE_OUTPUT = false
|
18
17
|
|
19
18
|
let(:dummy_directory_path) { 'spec/fixtures' }
|
20
19
|
let(:duration_in_days) { 7 }
|
@@ -56,11 +55,12 @@ RSpec.describe GitOwnershipInsights do
|
|
56
55
|
*Current total of [".swift", ".kt"] files in the folder:* 4
|
57
56
|
*Contributors:* {"FIOS"=>5, "FAND"=>2}
|
58
57
|
|
59
|
-
*Hotspot
|
60
|
-
|
58
|
+
*Hotspot files(1):*
|
59
|
+
|
60
|
+
/file1.swift Contributors: ["FIOS", "FAND"] Commits: 3 Owner: ["FIOS"]
|
61
|
+
|
62
|
+
*Code ownership data:*
|
61
63
|
|
62
|
-
*Code ownership data:*
|
63
|
-
Codeownership data:
|
64
64
|
FIOS:
|
65
65
|
Total Count: 3
|
66
66
|
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.7
|
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
|