code_ownership 1.32.0 → 1.32.2
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 +4 -4
- data/lib/code_ownership/private.rb +12 -4
- data/lib/code_ownership.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32fde48e3bfda45fef25ea894835a45548aac619699a8c56549000ca373916b5
|
4
|
+
data.tar.gz: e9155c7e859a17a8d31bc0f092822bd161f65a965b356060295be61ee695858b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d407ad1c1437c75b7ee9b5df5e22bfe74d90b5e353f62546879fdaf09b7be6d9bbb4c67f70fe0721d55729215377f407f03a83bb094f0fd8d24ad209cbd65957
|
7
|
+
data.tar.gz: dcef3ed24a4af4825a3f8320bcd704885dee0f4f65d7db08515844a67a094dca32f06024275a4d4361908f85f5cbbbdffb27e53c79efab1c384cd1348bb642db
|
@@ -25,6 +25,14 @@ module CodeOwnership
|
|
25
25
|
@configuration ||= Configuration.fetch
|
26
26
|
end
|
27
27
|
|
28
|
+
# This is just an alias for `configuration` that makes it more explicit what we're doing instead of just calling `configuration`.
|
29
|
+
# This is necessary because configuration may contain extensions of code ownership, so those extensions should be loaded prior to
|
30
|
+
# calling APIs that provide ownership information.
|
31
|
+
sig { returns(Configuration) }
|
32
|
+
def self.load_configuration!
|
33
|
+
configuration
|
34
|
+
end
|
35
|
+
|
28
36
|
sig { void }
|
29
37
|
def self.bust_caches!
|
30
38
|
@configuration = nil
|
@@ -50,10 +58,10 @@ module CodeOwnership
|
|
50
58
|
|
51
59
|
# Returns a string version of the relative path to a Rails constant,
|
52
60
|
# or nil if it can't find something
|
53
|
-
sig { params(
|
54
|
-
def self.
|
55
|
-
if
|
56
|
-
path = Object.const_source_location(
|
61
|
+
sig { params(klass_string: T.nilable(String)).returns(T.nilable(String)) }
|
62
|
+
def self.path_from_klass_string(klass_string)
|
63
|
+
if klass_string
|
64
|
+
path = Object.const_source_location(klass_string)&.first
|
57
65
|
(path && Pathname.new(path).relative_path_from(Pathname.pwd).to_s) || nil
|
58
66
|
else
|
59
67
|
nil
|
data/lib/code_ownership.rb
CHANGED
@@ -28,6 +28,8 @@ module CodeOwnership
|
|
28
28
|
return nil if file.start_with?('./')
|
29
29
|
return @for_file[file] if @for_file.key?(file)
|
30
30
|
|
31
|
+
Private.load_configuration!
|
32
|
+
|
31
33
|
owner = T.let(nil, T.nilable(CodeTeams::Team))
|
32
34
|
|
33
35
|
Mapper.all.each do |mapper|
|
@@ -40,6 +42,8 @@ module CodeOwnership
|
|
40
42
|
|
41
43
|
sig { params(team: T.any(CodeTeams::Team, String)).returns(String) }
|
42
44
|
def for_team(team)
|
45
|
+
Private.load_configuration!
|
46
|
+
|
43
47
|
team = T.must(CodeTeams.find(team)) if team.is_a?(String)
|
44
48
|
ownership_information = T.let([], T::Array[String])
|
45
49
|
|
@@ -87,6 +91,7 @@ module CodeOwnership
|
|
87
91
|
autocorrect: true,
|
88
92
|
stage_changes: true
|
89
93
|
)
|
94
|
+
Private.load_configuration!
|
90
95
|
tracked_file_subset = Private.tracked_files & files
|
91
96
|
Private.validate!(files: tracked_file_subset, autocorrect: autocorrect, stage_changes: stage_changes)
|
92
97
|
end
|
@@ -144,20 +149,23 @@ module CodeOwnership
|
|
144
149
|
end
|
145
150
|
private_class_method(:backtrace_with_ownership)
|
146
151
|
|
147
|
-
sig { params(klass: T.nilable(T.any(Class, Module))).returns(T.nilable(::CodeTeams::Team)) }
|
152
|
+
sig { params(klass: T.nilable(T.any(Class, Module, String))).returns(T.nilable(::CodeTeams::Team)) }
|
148
153
|
def for_class(klass)
|
149
154
|
@memoized_values ||= T.let(@memoized_values, T.nilable(T::Hash[String, T.nilable(::CodeTeams::Team)]))
|
150
155
|
@memoized_values ||= {}
|
156
|
+
|
157
|
+
klass_string = klass.to_s
|
158
|
+
|
151
159
|
# We use key because the memoized value could be `nil`
|
152
|
-
if !@memoized_values.key?(
|
153
|
-
path = Private.
|
160
|
+
if !@memoized_values.key?(klass_string)
|
161
|
+
path = Private.path_from_klass_string(klass_string)
|
154
162
|
return nil if path.nil?
|
155
163
|
|
156
164
|
value_to_memoize = for_file(path)
|
157
|
-
@memoized_values[
|
165
|
+
@memoized_values[klass_string] = value_to_memoize
|
158
166
|
value_to_memoize
|
159
167
|
else
|
160
|
-
@memoized_values[
|
168
|
+
@memoized_values[klass_string]
|
161
169
|
end
|
162
170
|
end
|
163
171
|
|
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.
|
4
|
+
version: 1.32.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-03-
|
11
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|