code_ownership 1.36.0 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73797a7557aab4536aef1ae47614f8d43e4dc634ec3ab476913c38efec1ad42
|
4
|
+
data.tar.gz: 5d1724a6eadb02d5bd7f1e521177f760b9134575d34a9bea634f30d45765de2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -10,8 +10,6 @@ module CodeOwnership
|
|
10
10
|
include Mapper
|
11
11
|
|
12
12
|
CODEOWNERS_DIRECTORY_FILE_NAME = '.codeowner'
|
13
|
-
RELATIVE_ROOT = Pathname('.').freeze
|
14
|
-
ABSOLUTE_ROOT = Pathname('/').freeze
|
15
13
|
|
16
14
|
@@directory_cache = T.let({}, T::Hash[String, T.nilable(CodeTeams::Team)]) # rubocop:disable Style/ClassVars
|
17
15
|
|
@@ -88,11 +86,19 @@ module CodeOwnership
|
|
88
86
|
|
89
87
|
if File.directory?(file)
|
90
88
|
team = get_team_from_codeowners_file_within_directory(file_path)
|
89
|
+
return team unless team.nil?
|
91
90
|
end
|
92
91
|
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
path_components = file_path.each_filename.to_a
|
93
|
+
if file_path.absolute?
|
94
|
+
path_components = ['/', *path_components]
|
95
|
+
end
|
96
|
+
|
97
|
+
(path_components.length - 1).downto(0).each do |i|
|
98
|
+
team = get_team_from_codeowners_file_within_directory(
|
99
|
+
Pathname.new(File.join(*T.unsafe(path_components[0...i])))
|
100
|
+
)
|
101
|
+
return team unless team.nil?
|
96
102
|
end
|
97
103
|
|
98
104
|
team
|
@@ -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.
|
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:
|
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.
|
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.
|
54
|
+
version: 0.5.11249
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
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
|