code_ownership 2.1.1-x86_64-linux → 2.1.2-x86_64-linux

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: adae3a62f615f131fac8f1ecd05a6888cd12d32136c65ba1016640d56d5a08ea
4
- data.tar.gz: 52aacacd5d5f190336353cc4fe4aca00fc8b79fc1c2de95e3cf791f3a69e5d1d
3
+ metadata.gz: 11870e7233492c859a41589bd1a85a43825e2fe4ab12279fe681df97ace60fa8
4
+ data.tar.gz: bb5e9e12b04cfa6bc8bc73e557066f04a9a00401dd0f9d462cc6b3b59b9db583
5
5
  SHA512:
6
- metadata.gz: 581f3954eac7da7cf5079c9871bd653668873655c3fd24db3746ba2378291a6a36763e74faa47c93c63a67152f6cb8fea59c53bdec743f4bad57528f73f85e12
7
- data.tar.gz: cbbf56062481c954cc32af8375a388bdd3e79d562f9d2d8069aa86e5984539d56c8285ae1ea56e7e964de004ce9fcdf08a2194521ef0e2d56841125201febf1b
6
+ metadata.gz: beefff80a9b1d0dd3a618671ebd1fc9e6d74898c06be8dced72d45e852fe8e4c3759771d02b4edd5f86d3c7b5602d73e00f89478847f1400b10df6651e565bdf
7
+ data.tar.gz: d0aeb2d7c0653417cb969da695111a7ce54b8186e62a3c3618d7cd5a9510bbd29f27dfc85cc8eca3a67960d3e9d8ddc9c98f156d9d23e7fab8723104fcf94f43
data/README.md CHANGED
@@ -10,7 +10,7 @@ There is also a [companion VSCode Extension](https://github.com/rubyatscale/code
10
10
 
11
11
  ## Getting started
12
12
 
13
- To get started there's a few things you should do.
13
+ To get started there are a few things you should do.
14
14
 
15
15
  1. Create a `config/code_ownership.yml` file and declare where your files live. Here's a sample to start with:
16
16
 
@@ -42,7 +42,7 @@ There are five ways to declare code ownership using this gem:
42
42
 
43
43
  ### Directory-Based Ownership
44
44
 
45
- Directory based ownership allows for all files in that directory and all its sub-directories to be owned by one team. To define this, add a `.codeowner` file inside that directory with the name of the team as the contents of that file.
45
+ Directory-based ownership allows for all files in that directory and all its sub-directories to be owned by one team. To define this, add a `.codeowner` file inside that directory with the name of the team as the contents of that file.
46
46
 
47
47
  ```
48
48
  Team
@@ -58,7 +58,7 @@ File annotations are a last resort if there is no clear home for your code. File
58
58
 
59
59
  ### Package-Based Ownership
60
60
 
61
- Package based ownership integrates [`packwerk`](https://github.com/Shopify/packwerk) and has ownership defined per package. To define that all files within a package are owned by one team, configure your `package.yml` like this:
61
+ Package-based ownership integrates [`packwerk`](https://github.com/Shopify/packwerk) and has ownership defined per package. To define that all files within a package are owned by one team, configure your `package.yml` like this:
62
62
 
63
63
  ```yml
64
64
  enforce_dependency: true
@@ -92,7 +92,7 @@ unowned_globs:
92
92
 
93
93
  ### Javascript Package Ownership
94
94
 
95
- Javascript package based ownership allows you to specify an ownership key in a `package.json`. To use this, configure your `package.json` like this:
95
+ JavaScript package-based ownership allows you to specify an ownership key in a `package.json`. To use this, configure your `package.json` like this:
96
96
 
97
97
  ```json
98
98
  {
@@ -112,10 +112,10 @@ js_package_paths:
112
112
  - frontend/other_location_for_packages/*
113
113
  ```
114
114
 
115
- This defaults `**/`, which makes it look for `package.json` files across your application.
115
+ This defaults to `**/`, which makes it look for `package.json` files across your application.
116
116
 
117
117
  > [!NOTE]
118
- > Javscript package ownership does not respect `unowned_globs`. If you wish to disable usage of this feature you can set `js_package_paths` to an empty list.
118
+ > JavaScript package ownership does not respect `unowned_globs`. If you wish to disable usage of this feature you can set `js_package_paths` to an empty list.
119
119
 
120
120
  ```yml
121
121
  js_package_paths: []
@@ -184,7 +184,7 @@ If `codeowners_path` is set in `code_ownership.yml` codeowners will use that pat
184
184
  CodeOwnership comes with a validation function to ensure the following things are true:
185
185
 
186
186
  1. Only one mechanism is defining file ownership. That is -- you can't have a file annotation on a file owned via package-based or glob-based ownership. This helps make ownership behavior more clear by avoiding concerns about precedence.
187
- 2. All teams referenced as an owner for any file or package is a valid team (i.e. it's in the list of `CodeTeams.all`).
187
+ 2. All teams referenced as an owner for any file or package are valid teams (i.e. they're in the list of `CodeTeams.all`).
188
188
  3. All files have ownership. You can specify in `unowned_globs` to represent a TODO list of files to add ownership to.
189
189
  4. The `.github/CODEOWNERS` file is up to date. This is automatically corrected and staged unless specified otherwise with `bin/codeownership validate --skip-autocorrect --skip-stage`. You can turn this validation off by setting `skip_codeowners_validation: true` in `config/code_ownership.yml`.
190
190
 
@@ -223,7 +223,7 @@ codeownership validate --diff
223
223
 
224
224
  ## Development
225
225
 
226
- Please add to `CHANGELOG.md` and this `README.md` when you make make changes.
226
+ Please add to `CHANGELOG.md` and this `README.md` when you make changes.
227
227
 
228
228
  ## Running specs
229
229
 
@@ -6,13 +6,29 @@ module CodeOwnership
6
6
  module FilePathFinder
7
7
  extend T::Sig
8
8
 
9
+ sig { returns(String) }
10
+ def self.pwd_prefix
11
+ @pwd_prefix ||= T.let("#{Dir.pwd}/", T.nilable(String))
12
+ end
13
+
14
+ sig { returns(Pathname) }
15
+ def self.pwd
16
+ @pwd ||= T.let(Pathname.pwd, T.nilable(Pathname))
17
+ end
18
+
9
19
  # Returns a string version of the relative path to a Rails constant,
10
20
  # or nil if it can't find anything
11
21
  sig { params(klass: T.nilable(T.any(T::Class[T.anything], T::Module[T.anything]))).returns(T.nilable(String)) }
12
22
  def self.path_from_klass(klass)
13
23
  if klass
14
24
  path = Object.const_source_location(klass.to_s)&.first
15
- (path && Pathname.new(path).relative_path_from(Pathname.pwd).to_s) || nil
25
+ return nil unless path
26
+
27
+ if path.start_with?(pwd_prefix)
28
+ path.delete_prefix(pwd_prefix)
29
+ else
30
+ Pathname.new(path).relative_path_from(pwd).to_s
31
+ end
16
32
  end
17
33
  rescue NameError
18
34
  nil
@@ -30,7 +46,7 @@ module CodeOwnership
30
46
  # ./app/controllers/some_controller.rb:43:in `block (3 levels) in create'
31
47
  #
32
48
  backtrace_line = if RUBY_VERSION >= '3.4.0'
33
- %r{\A(#{Pathname.pwd}/|\./)?
49
+ %r{\A(#{pwd}/|\./)?
34
50
  (?<file>.+) # Matches 'app/controllers/some_controller.rb'
35
51
  :
36
52
  (?<line>\d+) # Matches '43'
@@ -38,7 +54,7 @@ module CodeOwnership
38
54
  '(?<function>.*)' # Matches "`block (3 levels) in create'"
39
55
  \z}x
40
56
  else
41
- %r{\A(#{Pathname.pwd}/|\./)?
57
+ %r{\A(#{pwd}/|\./)?
42
58
  (?<file>.+) # Matches 'app/controllers/some_controller.rb'
43
59
  :
44
60
  (?<line>\d+) # Matches '43'
@@ -13,9 +13,8 @@ module CodeOwnership
13
13
  return FilePathTeamCache.get(file_path) if FilePathTeamCache.cached?(file_path)
14
14
 
15
15
  result = T.let(RustCodeOwners.for_file(file_path), T.nilable(T::Hash[Symbol, String]))
16
- return if result.nil?
17
16
 
18
- if result[:team_name].nil?
17
+ if result.nil? || result[:team_name].nil?
19
18
  FilePathTeamCache.set(file_path, nil)
20
19
  else
21
20
  FilePathTeamCache.set(file_path, T.let(find_team!(T.must(result[:team_name]), allow_raise: allow_raise), T.nilable(CodeTeams::Team)))
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module CodeOwnership
5
- VERSION = '2.1.1'
5
+ VERSION = '2.1.2'
6
6
  end
@@ -315,5 +315,7 @@ module CodeOwnership
315
315
  sig { void }
316
316
  def self.bust_caches!
317
317
  Private::FilePathTeamCache.bust_cache!
318
+ Private::FilePathFinder.instance_variable_set(:@pwd, nil)
319
+ Private::FilePathFinder.instance_variable_set(:@pwd_prefix, nil)
318
320
  end
319
321
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_ownership
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-26 00:00:00.000000000 Z
11
+ date: 2026-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -176,7 +176,6 @@ files:
176
176
  - README.md
177
177
  - bin/codeownership
178
178
  - lib/code_ownership.rb
179
- - lib/code_ownership/3.2/code_ownership.so
180
179
  - lib/code_ownership/3.3/code_ownership.so
181
180
  - lib/code_ownership/3.4/code_ownership.so
182
181
  - lib/code_ownership/4.0/code_ownership.so
@@ -204,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
203
  requirements:
205
204
  - - ">="
206
205
  - !ruby/object:Gem::Version
207
- version: '3.2'
206
+ version: '3.3'
208
207
  - - "<"
209
208
  - !ruby/object:Gem::Version
210
209
  version: 4.1.dev