code_ownership 1.36.1 → 1.36.2

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: 668edc0471999590cd95e9953151e6e30d02bf64b2bb14e544e5f7c56099c998
4
- data.tar.gz: bbdff6a9af05c8026b33c206d63f083d1c9ed82831bd7b1f3cf3707aa0f54a67
3
+ metadata.gz: b73797a7557aab4536aef1ae47614f8d43e4dc634ec3ab476913c38efec1ad42
4
+ data.tar.gz: 5d1724a6eadb02d5bd7f1e521177f760b9134575d34a9bea634f30d45765de2f
5
5
  SHA512:
6
- metadata.gz: 54a6b78ddb108894b20ddee99d0a6637770485b27c154b6676021f512d2aae39159d052e8f2c7986b71c824eb9f3f7bc4a3b9d5bc0c9e1848e7bceecee3e7728
7
- data.tar.gz: b4f39290cfc23f31b73642d3d6a5747ec79efc07210541c4b18c913f448c1df32efe6b4657e91f736055ab30ecf72b4910c22a0266503842aff84ad0e375be62
6
+ metadata.gz: 404f36c3804c30f3eb0fb5fc3a18faf71667c5fe4eab25f0d4527491ce838ee51c39824f3fcacc608e5e1356e82272bbe1928f18e0bd9a65e1c1941df595e5de
7
+ data.tar.gz: 326d2644787ee2e9d8c054b38762495db9be3c15305519176e3045c979b96e655136f3fb1def6840b8e975e56ee693fbc72dea8d10c6f69a86f2126376f70746
@@ -53,14 +53,8 @@ module CodeOwnership
53
53
  @expanded_cache ||= begin
54
54
  expanded_cache = {}
55
55
  @raw_cache_contents.each do |mapper_description, globs_by_owner|
56
- expanded_cache[mapper_description] = {}
57
- globs_by_owner.each do |glob, owner|
58
- Dir.glob(glob).each do |file, owner|
59
- expanded_cache[mapper_description][file] = owner
60
- end
61
- end
56
+ expanded_cache[mapper_description] = OwnerAssigner.assign_owners(globs_by_owner)
62
57
  end
63
-
64
58
  expanded_cache
65
59
  end
66
60
  end
@@ -0,0 +1,22 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module CodeOwnership
5
+ module Private
6
+ class OwnerAssigner
7
+ extend T::Sig
8
+
9
+ sig { params(globs_to_owning_team_map: GlobsToOwningTeamMap).returns(GlobsToOwningTeamMap) }
10
+ def self.assign_owners(globs_to_owning_team_map)
11
+ globs_to_owning_team_map.each_with_object({}) do |(glob, owner), mapping|
12
+ # addresses the case where a directory name includes regex characters
13
+ # such as `app/services/[test]/some_other_file.ts`
14
+ mapping[glob] = owner if File.exist?(glob)
15
+ Dir.glob(glob).each do |file|
16
+ mapping[file] ||= owner
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -8,6 +8,7 @@ require 'code_ownership/private/team_plugins/github'
8
8
  require 'code_ownership/private/codeowners_file'
9
9
  require 'code_ownership/private/parse_js_packages'
10
10
  require 'code_ownership/private/glob_cache'
11
+ require 'code_ownership/private/owner_assigner'
11
12
  require 'code_ownership/private/validations/files_have_owners'
12
13
  require 'code_ownership/private/validations/github_codeowners_up_to_date'
13
14
  require 'code_ownership/private/validations/files_have_unique_owners'
@@ -98,7 +99,6 @@ module CodeOwnership
98
99
  in_unowned_globs = configuration.unowned_globs.any? do |unowned_glob|
99
100
  File.fnmatch?(unowned_glob, file, File::FNM_PATHNAME | File::FNM_EXTGLOB)
100
101
  end
101
-
102
102
  in_owned_globs && !in_unowned_globs && File.exist?(file)
103
103
  end
104
104
 
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.36.1
4
+ version: 1.36.2
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-12-12 00:00:00.000000000 Z
11
+ date: 2024-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -44,16 +44,16 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.10821
47
+ version: 0.5.11249
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.5.10821
54
+ version: 0.5.11249
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry
56
+ name: debug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -168,6 +168,7 @@ files:
168
168
  - lib/code_ownership/private/codeowners_file.rb
169
169
  - lib/code_ownership/private/extension_loader.rb
170
170
  - lib/code_ownership/private/glob_cache.rb
171
+ - lib/code_ownership/private/owner_assigner.rb
171
172
  - lib/code_ownership/private/ownership_mappers/directory_ownership.rb
172
173
  - lib/code_ownership/private/ownership_mappers/file_annotations.rb
173
174
  - lib/code_ownership/private/ownership_mappers/js_package_ownership.rb