fast_code_owners 0.0.5-aarch64-linux-musl → 0.0.8-aarch64-linux-musl

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: 71f5dbec583a888c011dd8f1c72e735bf1aaedc4c434726edff5f4a45c70b59f
4
- data.tar.gz: '0049ea912d0f1ff1672dc6a17ea8192639213128abcf2de66de5e70d6490df0b'
3
+ metadata.gz: f97fc0d6733854af6d51c297c0796940e1f39c86dbeeb76a6672b49b178a87e3
4
+ data.tar.gz: fd3df5e29985fa3be73643722f5cbc892a0eaae08977917ec9d531d370b299df
5
5
  SHA512:
6
- metadata.gz: a93f8d69e71712d2ff9ecaf9bd95d2d38e24a17540f22dfcb06059254a34119c47b74013ba762b6fc8c66629a11896566d4e49bcf3bb2f295fb7e7fb8d0b85d0
7
- data.tar.gz: d1c826839bb1fbf1590155349ca03fdb0e771fe3db4fd86f319dc9e769d3caa3e46b9df0f2303120eea1d0cca07c432b9d97b44b66ea79d2609fff8ec93f03cf
6
+ metadata.gz: b866f23017f710f711fc2e353ad403ad63b9cd791a078d5d2c3996759153c7d46d5d41f5a4cf7bf7c7d76ae8a4830d2d57a3b9eac913def051fb2289fe3b2fc2
7
+ data.tar.gz: 6f93af0906c1323cef96e7595c7e0ddcb2960f5f065d6fb09e3a68c401eb0d2225813e6df9ecdfd27d415414b095c5a103873a87ca360973f1b8e83fc523f06b
data/README.md CHANGED
@@ -8,10 +8,6 @@ The [codeowners-rs](https://github.com/rubyatscale/codeowners-rs) CLI is a fast
8
8
 
9
9
  **fast_code_owners** provides Ruby APIs that delegate to codeowners-rs. Much of this code was lifted from [code_ownership](https://github.com/rubyatscale/code_ownership).
10
10
 
11
- ## Dependencies
12
-
13
- - [Rust](https://www.rust-lang.org/tools/install) must be installed and in the PATH
14
-
15
11
  ## Installation
16
12
 
17
13
  ```bash
data/exe/codeowners ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env dotslash
2
+
3
+ {
4
+ "name": "codeowners",
5
+ "platforms": {
6
+ "macos-x86_64": {
7
+ "size": 4331528,
8
+ "hash": "blake3",
9
+ "digest": "32bfc7664302bbb52a3130e1207e1b50aa717ebcd03baf3bf166415c98100dde",
10
+ "format": "tar.gz",
11
+ "path": "codeowners",
12
+ "providers": [
13
+ {
14
+ "url": "https://github.com/rubyatscale/codeowners-rs/releases/download/v0.2.4/codeowners-mac.tar.gz"
15
+ },
16
+ {
17
+ "type": "github-release",
18
+ "repo": "https://github.com/rubyatscale/codeowners-rs",
19
+ "tag": "v0.2.4",
20
+ "name": "codeowners-mac.tar.gz"
21
+ }
22
+ ]
23
+ },
24
+ "macos-aarch64": {
25
+ "size": 4331528,
26
+ "hash": "blake3",
27
+ "digest": "32bfc7664302bbb52a3130e1207e1b50aa717ebcd03baf3bf166415c98100dde",
28
+ "format": "tar.gz",
29
+ "path": "codeowners",
30
+ "providers": [
31
+ {
32
+ "url": "https://github.com/rubyatscale/codeowners-rs/releases/download/v0.2.4/codeowners-mac.tar.gz"
33
+ },
34
+ {
35
+ "type": "github-release",
36
+ "repo": "https://github.com/rubyatscale/codeowners-rs",
37
+ "tag": "v0.2.4",
38
+ "name": "codeowners-mac.tar.gz"
39
+ }
40
+ ]
41
+ },
42
+ "linux-x86_64": {
43
+ "size": 18038611,
44
+ "hash": "blake3",
45
+ "digest": "e04e66621efc4c2755b4ef912f5154e9dddafc4a1651bb565fc01465f059d9be",
46
+ "format": "tar.gz",
47
+ "path": "codeowners",
48
+ "providers": [
49
+ {
50
+ "url": "https://github.com/rubyatscale/codeowners-rs/releases/download/v0.2.4/x86_64-unknown-linux-gnu.tar.gz"
51
+ },
52
+ {
53
+ "type": "github-release",
54
+ "repo": "https://github.com/rubyatscale/codeowners-rs",
55
+ "tag": "v0.2.4",
56
+ "name": "x86_64-unknown-linux-gnu.tar.gz"
57
+ }
58
+ ]
59
+ },
60
+ "linux-aarch64": {
61
+ "size": 17411182,
62
+ "hash": "blake3",
63
+ "digest": "f812a66e884e91a5b708b0c0e03149079ef07e2803f0b207a9ca6fad6fe06207",
64
+ "format": "tar.gz",
65
+ "path": "codeowners",
66
+ "providers": [
67
+ {
68
+ "url": "https://github.com/rubyatscale/codeowners-rs/releases/download/v0.2.4/aarch64-unknown-linux-gnu.tar.gz"
69
+ },
70
+ {
71
+ "type": "github-release",
72
+ "repo": "https://github.com/rubyatscale/codeowners-rs",
73
+ "tag": "v0.2.4",
74
+ "name": "aarch64-unknown-linux-gnu.tar.gz"
75
+ }
76
+ ]
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,144 @@
1
+ # typed: true
2
+
3
+ require 'optparse'
4
+ require 'pathname'
5
+ require 'fileutils'
6
+
7
+ module FastCodeOwners
8
+ class Cli
9
+ def self.run!(argv)
10
+ command = argv.shift
11
+ if command == 'validate'
12
+ validate!(argv)
13
+ elsif command == 'for_file'
14
+ for_file(argv)
15
+ elsif command == 'for_team'
16
+ for_team(argv)
17
+ elsif [nil, 'help'].include?(command)
18
+ puts <<~USAGE
19
+ Usage: bin/codeownership <subcommand>
20
+
21
+ Subcommands:
22
+ validate - run all validations
23
+ for_file - find code ownership for a single file
24
+ for_team - find code ownership information for a team
25
+ help - display help information about code_ownership
26
+ USAGE
27
+ else
28
+ puts "'#{command}' is not a code_ownership command. See `bin/codeownership help`."
29
+ end
30
+ end
31
+
32
+ def self.validate!(argv)
33
+ options = {}
34
+
35
+ parser = OptionParser.new do |opts|
36
+ opts.banner = 'Usage: bin/codeownership validate [options]'
37
+
38
+ opts.on('--skip-autocorrect', 'Skip automatically correcting any errors, such as the .github/CODEOWNERS file') do
39
+ options[:skip_autocorrect] = true
40
+ end
41
+
42
+ opts.on('-d', '--diff', 'Only run validations with staged files') do
43
+ options[:diff] = true
44
+ end
45
+
46
+ opts.on('-s', '--skip-stage', 'Skips staging the CODEOWNERS file') do
47
+ options[:skip_stage] = true
48
+ end
49
+
50
+ opts.on('--help', 'Shows this prompt') do
51
+ puts opts
52
+ exit
53
+ end
54
+ end
55
+ args = parser.order!(argv)
56
+ parser.parse!(args)
57
+
58
+ files = if options[:diff]
59
+ ENV.fetch('CODEOWNERS_GIT_STAGED_FILES') { `git diff --staged --name-only` }.split("\n").select do |file|
60
+ File.exist?(file)
61
+ end
62
+ else
63
+ nil
64
+ end
65
+
66
+ FastCodeOwners.validate!(
67
+ files: files,
68
+ autocorrect: !options[:skip_autocorrect],
69
+ stage_changes: !options[:skip_stage]
70
+ )
71
+ end
72
+
73
+ # For now, this just returns team ownership
74
+ # Later, this could also return code ownership errors about that file.
75
+ def self.for_file(argv)
76
+ options = {}
77
+
78
+ # Long-term, we probably want to use something like `thor` so we don't have to implement logic
79
+ # like this. In the short-term, this is a simple way for us to use the built-in OptionParser
80
+ # while having an ergonomic CLI.
81
+ files = argv.reject { |arg| arg.start_with?('--') }
82
+
83
+ parser = OptionParser.new do |opts|
84
+ opts.banner = 'Usage: bin/codeownership for_file [options]'
85
+
86
+ opts.on('--json', 'Output as JSON') do
87
+ options[:json] = true
88
+ end
89
+
90
+ opts.on('--help', 'Shows this prompt') do
91
+ puts opts
92
+ exit
93
+ end
94
+ end
95
+ args = parser.order!(argv)
96
+ parser.parse!(args)
97
+
98
+ if files.count != 1
99
+ raise 'Please pass in one file. Use `bin/codeownership for_file --help` for more info'
100
+ end
101
+
102
+ team = FastCodeOwners.for_file(files.first)
103
+
104
+ team_name = team&.name || 'Unowned'
105
+ team_yml = team&.config_yml || 'Unowned'
106
+
107
+ if options[:json]
108
+ json = {
109
+ team_name: team_name,
110
+ team_yml: team_yml
111
+ }
112
+
113
+ puts json.to_json
114
+ else
115
+ puts <<~MSG
116
+ Team: #{team_name}
117
+ Team YML: #{team_yml}
118
+ MSG
119
+ end
120
+ end
121
+
122
+ def self.for_team(argv)
123
+ parser = OptionParser.new do |opts|
124
+ opts.banner = 'Usage: bin/codeownership for_team \'Team Name\''
125
+
126
+ opts.on('--help', 'Shows this prompt') do
127
+ puts opts
128
+ exit
129
+ end
130
+ end
131
+ teams = argv.reject { |arg| arg.start_with?('--') }
132
+ args = parser.order!(argv)
133
+ parser.parse!(args)
134
+
135
+ if teams.count != 1
136
+ raise 'Please pass in one team. Use `bin/codeownership for_team --help` for more info'
137
+ end
138
+
139
+ puts FastCodeOwners.for_team(teams.first)
140
+ end
141
+
142
+ private_class_method :validate!
143
+ end
144
+ end
@@ -14,10 +14,11 @@ module FastCodeOwners
14
14
  sig { params(file_path: String).returns(T.nilable(CodeTeams::Team)) }
15
15
  def for_file(file_path)
16
16
  return nil if file_path.start_with?('./')
17
- return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path)
18
17
 
18
+ # return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path)
19
19
  result = T.let(RustCodeOwners.for_file(file_path), T.nilable(T::Hash[Symbol, String]))
20
20
  return if result.nil?
21
+ puts "ruby result: #{result}"
21
22
 
22
23
  if result[:team_name].nil?
23
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.5'
4
+ VERSION = '0.0.8'
5
5
  end
@@ -9,6 +9,7 @@ require_relative 'fast_code_owners/file_path_team_cache'
9
9
  require_relative 'fast_code_owners/team_finder'
10
10
  require_relative 'fast_code_owners/version'
11
11
  require_relative 'fast_code_owners/file_path_finder'
12
+ require_relative 'fast_code_owners/cli'
12
13
 
13
14
  begin
14
15
  RUBY_VERSION =~ /(\d+\.\d+)/
@@ -24,6 +25,21 @@ module FastCodeOwners
24
25
  extend T::Helpers
25
26
  requires_ancestor { Kernel }
26
27
 
28
+ sig do
29
+ params(
30
+ autocorrect: T::Boolean,
31
+ stage_changes: T::Boolean,
32
+ files: T.nilable(T::Array[String])
33
+ ).void
34
+ end
35
+ def validate!(
36
+ autocorrect: true,
37
+ stage_changes: true,
38
+ files: nil
39
+ )
40
+ # todo
41
+ end
42
+
27
43
  sig { params(file_path: String).returns(T.nilable(CodeTeams::Team)) }
28
44
  def for_file(file_path)
29
45
  TeamFinder.for_file(file_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_code_owners
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.8
5
5
  platform: aarch64-linux-musl
6
6
  authors:
7
7
  - Perry Hertler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-03 00:00:00.000000000 Z
11
+ date: 2025-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -125,11 +125,13 @@ dependencies:
125
125
  description: A ruby interface that determines file ownership for git repositories
126
126
  email:
127
127
  - perry.hertler@gusto.com
128
- executables: []
128
+ executables:
129
+ - codeowners
129
130
  extensions: []
130
131
  extra_rdoc_files: []
131
132
  files:
132
133
  - README.md
134
+ - exe/codeowners
133
135
  - ext/fast_code_owners/tests/fixtures/valid_project/config/code_ownership.yml
134
136
  - ext/fast_code_owners/tests/fixtures/valid_project/config/teams/bar.yml
135
137
  - ext/fast_code_owners/tests/fixtures/valid_project/config/teams/foo.yml
@@ -138,6 +140,7 @@ files:
138
140
  - lib/fast_code_owners.rb
139
141
  - lib/fast_code_owners/3.2/fast_code_owners.so
140
142
  - lib/fast_code_owners/3.4/fast_code_owners.so
143
+ - lib/fast_code_owners/cli.rb
141
144
  - lib/fast_code_owners/file_path_finder.rb
142
145
  - lib/fast_code_owners/file_path_team_cache.rb
143
146
  - lib/fast_code_owners/team_finder.rb