git_ownership_insights 1.0.0 → 1.0.3

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: 4bca095a91102d5a60161e08921ba7af125dfc7a5ee528bd527ab57720814d62
4
- data.tar.gz: 39e9afe47d9af3c4e1b49a084001c52bef8b55f8f8ee9057bd264c000e466fba
3
+ metadata.gz: c8e4215542d1b1f05793def9ec7da4bf9c9cbdcc8b8fd0e00a912188ce877b85
4
+ data.tar.gz: 0b10b78de68c0f71013a9d6a9458b45dd824ed283bd3b0613c93f3146b0d1fc8
5
5
  SHA512:
6
- metadata.gz: 207a6053d21c89408c33ca31068ae8d2fb2a88b7bf4bd63d5cdbdafbcbffc6e3df05bee91142adb88030cb2befe7cbfe48258a9a70fd4a952cfa0f3ef2601aed
7
- data.tar.gz: 10f59df955f3a5321cf046761303befc0260490069a81cbe40d505ffa82a19dd03d2b03896f7cdd882a39b3a29cc686c6cf911ff1c196abaceb7607ddacaab59
6
+ metadata.gz: f0cd127fa863e8d06d868527b5d3f2ea662f560d6149f95bbef1df18ed3442c7d08b6eb27aa4ed8e223c5bdbb2772a37aa1c8de41fb6920e5f96d7fd3555e833
7
+ data.tar.gz: 58fcc55d06921ce4c57c008496c82af548992d2e007b24d3449a2b51b1957ac41aa5a0a87bf809d7435814cf5273e8e70aff80659bc5786772e4c8a144687ae3
@@ -4,16 +4,17 @@
4
4
  require 'date'
5
5
  require 'optparse'
6
6
  require 'pry'
7
+ require_relative '../lib/git_ownership_insights/version'
7
8
 
8
9
  options = {}
9
10
  OptionParser.new do |opts|
10
11
  opts.banner = 'Usage: git_ownership_insights [options]'
11
12
 
12
- opts.on('--debug', 'Enable debug mode') do
13
+ opts.on('-d', '--debug', 'Enable debug mode') do
13
14
  options[:debug] = true
14
15
  end
15
16
 
16
- opts.on('--ci', 'Do not print the info messages for better CI text parsing [default: false]') do
17
+ opts.on('-ci', '--ci', 'Do not print the info messages for better CI text parsing [default: false]') do
17
18
  options[:ci] = true
18
19
  end
19
20
 
@@ -21,59 +22,64 @@ OptionParser.new do |opts|
21
22
  options[:codeowners] = true
22
23
  end
23
24
 
24
- opts.on('--hotspot-files', 'Print the found hotspot files (big files touched by many) [default: false]') do
25
+ opts.on('-hf', '--hotspot-files', 'Print the found hotspot files (big files touched by many) [default: false]') do
25
26
  options[:hotspot_files] = true
26
27
  end
27
28
 
28
- opts.on('--excluded-contributors STRING', 'Comma-delimited list of excluded contributors [example: WEB,RAILS,MOBILE]') do |exclusions|
29
+ opts.on('-ec', '--excluded-contributors STRING', 'Comma-delimited list of excluded contributors [example: WEB,RAILS,MOBILE]') do |exclusions|
29
30
  options[:exclusions] = exclusions
30
31
  end
31
32
 
32
- opts.on('--excluded-files STRING', 'Comma-delimited list of excluded files [example: ViewController,AppDelegate.swift]') do |excluded_files|
33
+ opts.on('-ef', '--excluded-files STRING', 'Comma-delimited list of excluded files [example: ViewController,AppDelegate.swift]') do |excluded_files|
33
34
  options[:excluded_files] = excluded_files
34
35
  end
35
36
 
36
- opts.on('--steps STRING', 'Number of steps the script will go into the past [default: 1]') do |steps|
37
+ opts.on('-s', '--steps STRING', 'Number of steps the script will go into the past [default: 1]') do |steps|
37
38
  options[:steps] = steps
38
39
  end
39
40
 
40
- opts.on('--duration-in-days STRING',
41
+ opts.on('-d', '--duration-in-days STRING',
41
42
  'Number of days to aggregate the changes for [default: 30]') do |duration_in_days|
42
43
  options[:duration_in_days] = duration_in_days
43
44
  end
44
45
 
45
- opts.on('--path STRING', 'Path to the directory or file to calculate the ownership [default: "."]') do |path|
46
+ opts.on('-p', '--path STRING', 'Path to the directory or file to calculate the ownership [default: "."]') do |path|
46
47
  options[:path] = path
47
48
  end
48
49
 
49
- opts.on('--team-regex STRING', 'Regex that will identify the team name [default: "[A-Za-z]+"]') do |team_regex|
50
+ opts.on('-reg', '--team-regex STRING', 'Regex that will identify the team name [default: "[A-Za-z]+"]') do |team_regex|
50
51
  options[:team_regex] = team_regex
51
52
  end
52
53
 
53
- opts.on('--top-contributing-team STRING', 'Limit of top contributed to the directory teams in codeownership data [default: 5]') do |top_contributing_team|
54
+ opts.on('-t', '--top-contributing-team STRING', 'Limit of top contributed to the directory teams in codeownership data [default: 5]') do |top_contributing_team|
54
55
  options[:top_contributing_team] = top_contributing_team
55
56
  end
56
57
 
57
- opts.on('--top-touched-files STRING', 'Limit of top touched files by individual contributors in codeownership data [default: 5]') do |top_touched_files|
58
+ opts.on('-files', '--top-touched-files STRING', 'Limit of top touched files by individual contributors in codeownership data [default: 5]') do |top_touched_files|
58
59
  options[:top_touched_files] = top_touched_files
59
60
  end
60
61
 
61
- opts.on('--codeowners-path STRING', 'Path to CODEOWNERS file [default: .github/CODEOWNERS]') do |codeowners_path|
62
+ opts.on('-cp', '--codeowners-path STRING', 'Path to CODEOWNERS file [default: .github/CODEOWNERS]') do |codeowners_path|
62
63
  options[:codeowners_path] = codeowners_path
63
64
  end
64
65
 
65
- opts.on('--big-file-size STRING', 'The amount of lines in the file to be considered big [default: 250]') do |big_file_size|
66
+ opts.on('-s', '--big-file-size STRING', 'The amount of lines in the file to be considered big [default: 250]') do |big_file_size|
66
67
  options[:big_file_size] = big_file_size
67
68
  end
68
69
 
69
- opts.on('--default-branch STRING', 'The default branch to pull and run metrics for [default: master]') do |default_branch|
70
+ opts.on('-b', '--default-branch STRING', 'The default branch to pull and run metrics for [default: master]') do |default_branch|
70
71
  options[:default_branch] = default_branch
71
72
  end
72
73
 
73
- opts.on('--code-extensions STRING', 'The file extensions that consider to be code [default: ".kt, .swift"]') do |code_extension|
74
+ opts.on('-ext', '--code-extensions STRING', 'The file extensions that consider to be code [default: ".kt, .swift"]') do |code_extension|
74
75
  options[:code_extension] = code_extension
75
76
  end
76
77
 
78
+ opts.on('-v', '--version', 'Display the version of the gem') do
79
+ puts "git_ownership_insights version #{GitOwnershipInsights::VERSION}"
80
+ exit
81
+ end
82
+
77
83
  opts.on('-h', '--help', 'Display this help message') do
78
84
  puts opts
79
85
  puts <<~EXAMPLES
@@ -172,14 +178,18 @@ def contribution_message(directory_path:, duration_in_days:, begin_time:, debug:
172
178
  end_date = begin_time.to_time.to_i
173
179
  file_count = `git ls-tree -r --name-only $(git rev-list -1 --since="#{start_date}" --until="#{end_date}" HEAD) -- "#{directory_path}" | wc -l`.to_i
174
180
  all_files_with_changes = `git log --name-only --pretty=format:"" --since="#{start_date}" --until="#{end_date}" "#{directory_path}"`.split.sort
175
- excluded_patterns = EXCLUDED_FILES.split(',')
181
+ excluded_patterns = EXCLUDED_FILES.split(',') if EXCLUDED_FILES
176
182
 
177
183
  code_files_with_changes = all_files_with_changes.select {|f|
178
184
  extension = File.extname(f)
179
185
  valid_extensions = CODE_EXTENSIONS
180
186
  valid_extensions.include?(extension)
181
- }.reject do |file|
182
- excluded_patterns.any? { |pattern| file.include?(pattern) }
187
+ }
188
+
189
+ if EXCLUDED_FILES
190
+ code_files_with_changes = code_files_with_changes.reject do |file|
191
+ excluded_patterns.any? { |pattern| file.include?(pattern) }
192
+ end
183
193
  end
184
194
 
185
195
  uniq_code_files_with_changes = code_files_with_changes.uniq
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitOwnershipInsights
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.3'
5
5
  end
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: 1.0.0
4
+ version: 1.0.3
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-22 00:00:00.000000000 Z
11
+ date: 2024-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: date