code_ownership 1.32.16 → 1.32.18

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: 7a5c5f4a43ef44ffca514c001aa9eae7042bcdf445913afaa15adf40520e1d6d
4
- data.tar.gz: e6cb1255f18886edabdd09086ed86d616742b9683311b657e7ba4c418baff443
3
+ metadata.gz: f00d3f6cebe0c0c1a832fe6bd5487b39edb84a0cb316ecbcea33bbf2b090d9bd
4
+ data.tar.gz: 6092a31cf222e8b734f19338d612ac1b08c121c20dbc822b1271e97ab11980c0
5
5
  SHA512:
6
- metadata.gz: ede48eace0e4e7096671816ba0c1264fad5d3ea465ba5473a5724da95623e4982e5058b81f8eca0df39602889d88a3ea041cdb12fbb0a9e489b029fe32fa8579
7
- data.tar.gz: 55c7bd2a181710065712eb211b969dbefbfb9d83daedbfec324816cc8aae38fd1161ddde6b049370866a00d75b6a4df5d374629a5a619cabbb8f8e1e8b511182
6
+ metadata.gz: 054d5179ae0516d621f71e222308c28c769dfcfe1fd66595ddbe23f6f18126bbfc683ef9a6882a67e8599e88b5fd6800eb95c8f1b55e80c66a13bd8c13a245ba
7
+ data.tar.gz: a1bcaa5dce9cb34158ce59d73b17d7cdc1494502ca802aa01b5bc3f5af507fd8187b5561e8b26f24151ec1e72eeee24a12c4b314f853af4a0f9230530e6d500d
data/README.md CHANGED
@@ -96,7 +96,7 @@ See `code_ownership_spec.rb` for an example.
96
96
  `CodeOwnership.for_class` can be given a class and will either return `nil`, or a `CodeTeams::Team`.
97
97
 
98
98
  ```ruby
99
- CodeOwnership.for_class(MyClass.name)
99
+ CodeOwnership.for_class(MyClass)
100
100
  ```
101
101
 
102
102
  Under the hood, this finds the file where the class is defined and returns the owner of that file.
@@ -12,16 +12,16 @@ module CodeOwnership
12
12
  class << self
13
13
  extend T::Sig
14
14
 
15
- sig { params(base: Class).void }
15
+ sig { params(base: T::Class[Mapper]).void }
16
16
  def included(base)
17
- @mappers ||= T.let(@mappers, T.nilable(T::Array[Class]))
17
+ @mappers ||= T.let(@mappers, T.nilable(T::Array[T::Class[Mapper]]))
18
18
  @mappers ||= []
19
19
  @mappers << base
20
20
  end
21
21
 
22
22
  sig { returns(T::Array[Mapper]) }
23
23
  def all
24
- T.unsafe(@mappers).map(&:new)
24
+ (@mappers || []).map(&:new)
25
25
  end
26
26
  end
27
27
 
@@ -49,6 +49,7 @@ module CodeOwnership
49
49
  def update_cache(cache, files)
50
50
  # We map files to nil owners so that files whose annotation have been removed will be properly
51
51
  # overwritten (i.e. removed) from the cache.
52
+ fileset = Set.new(files)
52
53
  updated_cache_for_files = globs_to_owner(files)
53
54
  cache.merge!(updated_cache_for_files)
54
55
 
@@ -57,7 +58,8 @@ module CodeOwnership
57
58
  !Private.file_tracked?(file) ||
58
59
  # If a file no longer has a file annotation (i.e. `globs_to_owner` doesn't map it)
59
60
  # it should be removed from the cache
60
- !updated_cache_for_files.key?(file)
61
+ # We make sure to only apply this to the input files since otherwise `updated_cache_for_files.key?(file)` would always return `false` when files == []
62
+ (fileset.include?(file) && !updated_cache_for_files.key?(file))
61
63
  end
62
64
 
63
65
  invalid_files.each do |invalid_file|
@@ -14,16 +14,16 @@ module CodeOwnership
14
14
  class << self
15
15
  extend T::Sig
16
16
 
17
- sig { params(base: Class).void }
17
+ sig { params(base: T::Class[Validator]).void }
18
18
  def included(base)
19
- @validators ||= T.let(@validators, T.nilable(T::Array[Class]))
19
+ @validators ||= T.let(@validators, T.nilable(T::Array[T::Class[Validator]]))
20
20
  @validators ||= []
21
21
  @validators << base
22
22
  end
23
23
 
24
24
  sig { returns(T::Array[Validator]) }
25
25
  def all
26
- T.unsafe(@validators).map(&:new)
26
+ (@validators || []).map(&:new)
27
27
  end
28
28
  end
29
29
  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: 1.32.16
4
+ version: 1.32.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.5.10821
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.5.10821
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement