fast_code_owners 0.0.8-arm64-darwin → 0.0.10-arm64-darwin

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: f48813dd1c2bf81bad0f14ec58415b4314cb9c2b7cc6c2a2418bba750a9864a1
4
- data.tar.gz: f7a8806134bd00a2fda415ff767b59edda0d6e8fa594a00d2f1a708a5ce34c62
3
+ metadata.gz: f99340b8fc4e54eb25a1653ea1e95e62f496a1bc0cbe0d7c9e261abe7cad420d
4
+ data.tar.gz: a29f359629fc9ffdc62ad07eb823c8326f61f06c6bb555142bb7241c3e3c8665
5
5
  SHA512:
6
- metadata.gz: cb367bab9656cafc639481b10a0b037db738eb26d8260e84132ed2eb84cee6a1fad2e35ee0c427ea09d015180d853dcf058c8471b5a2391c55843567b8d80a6a
7
- data.tar.gz: beeacd25154949510fcaf30ff8d54324552523e263e67b15aede5906141cd454653a777a6f045a24052c9917342e9c4fe3cf63e2a8d4cb97f0241f6516908113
6
+ metadata.gz: db6a50766882185860353c9e355b068975b0014f8befe16da746d0bd77b022cbdef4a101c66bea9ca7acf88c20894a9a7cf0f0ee21538732b4bb339b74683aaf
7
+ data.tar.gz: 4d7386a1be5071f4b930350001c92b9257fa11e15afea6684e6123613fd01934e67c13cd9e354354c54f48f7d4c91a808b9cafdd870cf09433345cb2205e04d8
@@ -3,6 +3,7 @@
3
3
  require 'optparse'
4
4
  require 'pathname'
5
5
  require 'fileutils'
6
+ require 'json'
6
7
 
7
8
  module FastCodeOwners
8
9
  class Cli
@@ -16,7 +17,7 @@ module FastCodeOwners
16
17
  for_team(argv)
17
18
  elsif [nil, 'help'].include?(command)
18
19
  puts <<~USAGE
19
- Usage: bin/codeownership <subcommand>
20
+ Usage: bin/codeowners <subcommand>
20
21
 
21
22
  Subcommands:
22
23
  validate - run all validations
@@ -25,7 +26,7 @@ module FastCodeOwners
25
26
  help - display help information about code_ownership
26
27
  USAGE
27
28
  else
28
- puts "'#{command}' is not a code_ownership command. See `bin/codeownership help`."
29
+ puts "'#{command}' is not a code_ownership command. See `bin/codeowners help`."
29
30
  end
30
31
  end
31
32
 
@@ -33,7 +34,7 @@ module FastCodeOwners
33
34
  options = {}
34
35
 
35
36
  parser = OptionParser.new do |opts|
36
- opts.banner = 'Usage: bin/codeownership validate [options]'
37
+ opts.banner = 'Usage: bin/codeowners validate [options]'
37
38
 
38
39
  opts.on('--skip-autocorrect', 'Skip automatically correcting any errors, such as the .github/CODEOWNERS file') do
39
40
  options[:skip_autocorrect] = true
@@ -81,7 +82,7 @@ module FastCodeOwners
81
82
  files = argv.reject { |arg| arg.start_with?('--') }
82
83
 
83
84
  parser = OptionParser.new do |opts|
84
- opts.banner = 'Usage: bin/codeownership for_file [options]'
85
+ opts.banner = 'Usage: bin/codeowners for_file [options]'
85
86
 
86
87
  opts.on('--json', 'Output as JSON') do
87
88
  options[:json] = true
@@ -96,7 +97,7 @@ module FastCodeOwners
96
97
  parser.parse!(args)
97
98
 
98
99
  if files.count != 1
99
- raise 'Please pass in one file. Use `bin/codeownership for_file --help` for more info'
100
+ raise 'Please pass in one file. Use `bin/codeowners for_file --help` for more info'
100
101
  end
101
102
 
102
103
  team = FastCodeOwners.for_file(files.first)
@@ -121,7 +122,7 @@ module FastCodeOwners
121
122
 
122
123
  def self.for_team(argv)
123
124
  parser = OptionParser.new do |opts|
124
- opts.banner = 'Usage: bin/codeownership for_team \'Team Name\''
125
+ opts.banner = 'Usage: bin/codeowners for_team \'Team Name\''
125
126
 
126
127
  opts.on('--help', 'Shows this prompt') do
127
128
  puts opts
@@ -133,10 +134,10 @@ module FastCodeOwners
133
134
  parser.parse!(args)
134
135
 
135
136
  if teams.count != 1
136
- raise 'Please pass in one team. Use `bin/codeownership for_team --help` for more info'
137
+ raise 'Please pass in one team. Use `bin/codeowners for_team --help` for more info'
137
138
  end
138
139
 
139
- puts FastCodeOwners.for_team(teams.first)
140
+ puts FastCodeOwners.for_team(teams.first).join("\n")
140
141
  end
141
142
 
142
143
  private_class_method :validate!
@@ -15,10 +15,10 @@ module FastCodeOwners
15
15
  def for_file(file_path)
16
16
  return nil if file_path.start_with?('./')
17
17
 
18
- # return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path)
18
+ return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path)
19
+
19
20
  result = T.let(RustCodeOwners.for_file(file_path), T.nilable(T::Hash[Symbol, String]))
20
21
  return if result.nil?
21
- puts "ruby result: #{result}"
22
22
 
23
23
  if result[:team_name].nil?
24
24
  FilePathTeamCache.set(file_path, nil)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastCodeOwners
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.10'
5
5
  end
@@ -30,14 +30,18 @@ module FastCodeOwners
30
30
  autocorrect: T::Boolean,
31
31
  stage_changes: T::Boolean,
32
32
  files: T.nilable(T::Array[String])
33
- ).void
33
+ ).returns(T.nilable(T::Hash[Symbol, String]))
34
34
  end
35
35
  def validate!(
36
36
  autocorrect: true,
37
37
  stage_changes: true,
38
38
  files: nil
39
39
  )
40
- # todo
40
+ if autocorrect
41
+ ::RustCodeOwners.generate_and_validate
42
+ else
43
+ ::RustCodeOwners.validate
44
+ end
41
45
  end
42
46
 
43
47
  sig { params(file_path: String).returns(T.nilable(CodeTeams::Team)) }
@@ -69,6 +73,12 @@ module FastCodeOwners
69
73
  TeamFinder.first_owned_file_for_backtrace(backtrace, excluded_teams: excluded_teams)
70
74
  end
71
75
 
76
+ sig { params(team: T.any(CodeTeams::Team, String)).returns(String) }
77
+ def for_team(team)
78
+ team = T.must(CodeTeams.find(team)) if team.is_a?(String)
79
+ ::RustCodeOwners.for_team(team.name)
80
+ end
81
+
72
82
  sig { void }
73
83
  def bust_cache!
74
84
  FilePathTeamCache.bust_cache!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_code_owners
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Perry Hertler