code_ownership 1.32.9 → 1.32.11

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: 71768f254f9fbb891679c002c16c20bd70a2125460e3c66995821cfe2784fe56
4
- data.tar.gz: ce5698b1505d306026f807a142f648942ea06d3ab65576d05c623f6bdbdc1dfa
3
+ metadata.gz: 766c909e87feb435319240d22675e5bd3bbbb2da5e9984098df27eb6586b2d46
4
+ data.tar.gz: 74e9e35278a45fce5aecf0de4131c56785c774eb6abe9e3d6db599f3bf6332f1
5
5
  SHA512:
6
- metadata.gz: 7b2e5da9f4e02b4db10c47be40b1b4bce33f7c44ad18797ff326a6e245f5dc57b2a8534c74fde74a1966970720a9bedf50d59858923e07f64d8e21d9f8411df1
7
- data.tar.gz: b08f25b9008d86b19207931cb44c13adea814b998af8700b1fa445ad09e48e6549f86d6e4b75db41e5a783bf080ea5e25371d97db5307de8c5451bcd3d4fe3da
6
+ metadata.gz: eae6b000156ff509afe12b70019d3b73a62d30718f890f62dcd8ff46c8a03687e5cbc041463ef5b28e0de85bbb96c72799db95334d575bd5b42669ece4960885
7
+ data.tar.gz: e4c4b07430f1b611fb2e1493210a67c2a0e69013fdeddaa2042f8b6334e3b1c66d666343030da1af79b7af2dd9d8873af88556143cfa60406aa0991f72f7a9be
@@ -68,9 +68,10 @@ module CodeOwnership
68
68
 
69
69
  Mapper.all.each do |mapper|
70
70
  mapped_files = mapper.globs_to_owner(Private.tracked_files)
71
+ glob_to_owner_map_by_mapper_description[mapper.description] ||= {}
72
+
71
73
  mapped_files.each do |glob, owner|
72
74
  next if owner.nil?
73
- glob_to_owner_map_by_mapper_description[mapper.description] ||= {}
74
75
  glob_to_owner_map_by_mapper_description.fetch(mapper.description)[glob] = owner
75
76
  end
76
77
  end
@@ -18,8 +18,6 @@ module CodeOwnership
18
18
  extend T::Sig
19
19
  include Mapper
20
20
 
21
- @@map_files_to_owners = T.let({}, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
22
-
23
21
  TEAM_PATTERN = T.let(/\A(?:#|\/\/) @team (?<team>.*)\Z/.freeze, Regexp)
24
22
  DESCRIPTION = 'Annotations at the top of file'
25
23
 
@@ -37,9 +35,7 @@ module CodeOwnership
37
35
  returns(T::Hash[String, ::CodeTeams::Team])
38
36
  end
39
37
  def globs_to_owner(files)
40
- return @@map_files_to_owners if @@map_files_to_owners&.keys && @@map_files_to_owners.keys.count > 0
41
-
42
- @@map_files_to_owners = files.each_with_object({}) do |filename_relative_to_root, mapping| # rubocop:disable Style/ClassVars
38
+ files.each_with_object({}) do |filename_relative_to_root, mapping| # rubocop:disable Style/ClassVars
43
39
  owner = file_annotation_based_owner(filename_relative_to_root)
44
40
  next unless owner
45
41
 
@@ -119,7 +115,6 @@ module CodeOwnership
119
115
 
120
116
  sig { override.void }
121
117
  def bust_caches!
122
- @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
123
118
  end
124
119
  end
125
120
  end
@@ -9,8 +9,6 @@ module CodeOwnership
9
9
  extend T::Sig
10
10
  include Mapper
11
11
 
12
- @@package_yml_cache = T.let({}, T::Hash[String, T.nilable(Packs::Pack)]) # rubocop:disable Style/ClassVars
13
-
14
12
  sig do
15
13
  override.params(file: String).
16
14
  returns(T.nilable(::CodeTeams::Team))
@@ -69,7 +67,6 @@ module CodeOwnership
69
67
 
70
68
  sig { override.void }
71
69
  def bust_caches!
72
- @@package_yml_cache = {} # rubocop:disable Style/ClassVars
73
70
  end
74
71
  end
75
72
  end
@@ -12,8 +12,6 @@ module CodeOwnership
12
12
 
13
13
  @@map_files_to_owners = T.let(@map_files_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
14
14
  @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
15
- @@codeowners_lines_to_owners = T.let(@codeowners_lines_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
16
- @@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
17
15
 
18
16
  sig do
19
17
  params(files: T::Array[String]).
@@ -103,9 +101,7 @@ module CodeOwnership
103
101
  returns(T::Hash[String, ::CodeTeams::Team])
104
102
  end
105
103
  def globs_to_owner(files)
106
- return @@codeowners_lines_to_owners if @@codeowners_lines_to_owners&.keys && @@codeowners_lines_to_owners.keys.count > 0
107
-
108
- @@codeowners_lines_to_owners = CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
104
+ CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
109
105
  TeamPlugins::Ownership.for(team).owned_globs.each do |owned_glob|
110
106
  map[owned_glob] = team
111
107
  end
@@ -114,7 +110,6 @@ module CodeOwnership
114
110
 
115
111
  sig { override.void }
116
112
  def bust_caches!
117
- @@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
118
113
  @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
119
114
  end
120
115
 
@@ -11,8 +11,6 @@ module CodeOwnership
11
11
 
12
12
  @@map_files_to_owners = T.let(@map_files_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
13
13
  @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
14
- @@codeowners_lines_to_owners = T.let(@codeowners_lines_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
15
- @@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
16
14
 
17
15
  sig do
18
16
  params(files: T::Array[String]).
@@ -39,16 +37,13 @@ module CodeOwnership
39
37
  returns(T::Hash[String, ::CodeTeams::Team])
40
38
  end
41
39
  def globs_to_owner(files)
42
- return @@codeowners_lines_to_owners if @@codeowners_lines_to_owners&.keys && @@codeowners_lines_to_owners.keys.count > 0
43
-
44
- @@codeowners_lines_to_owners = CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
40
+ CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
45
41
  map[team.config_yml] = team
46
42
  end
47
43
  end
48
44
 
49
45
  sig { override.void }
50
46
  def bust_caches!
51
- @@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
52
47
  @@map_files_to_owners = {} # rubocop:disable Style/ClassVars
53
48
  end
54
49
 
@@ -43,27 +43,23 @@ module CodeOwnership
43
43
 
44
44
  sig { params(team: T.any(CodeTeams::Team, String)).returns(String) }
45
45
  def for_team(team)
46
- Private.load_configuration!
47
-
48
46
  team = T.must(CodeTeams.find(team)) if team.is_a?(String)
49
47
  ownership_information = T.let([], T::Array[String])
50
48
 
51
49
  ownership_information << "# Code Ownership Report for `#{team.name}` Team"
52
- Mapper.all.each do |mapper|
53
- ownership_information << "## #{mapper.description}"
54
- codeowners_lines = mapper.globs_to_owner(Private.tracked_files)
50
+
51
+ Private.glob_cache.raw_cache_contents.each do |mapper_description, glob_to_owning_team_map|
52
+ ownership_information << "## #{mapper_description}"
55
53
  ownership_for_mapper = []
56
- codeowners_lines.each do |line, team_for_line|
57
- next if team_for_line.nil?
58
- if team_for_line.name == team.name
59
- ownership_for_mapper << "- #{line}"
60
- end
54
+ glob_to_owning_team_map.each do |glob, owning_team|
55
+ next if owning_team != team
56
+ ownership_for_mapper << "- #{glob}"
61
57
  end
62
58
 
63
59
  if ownership_for_mapper.empty?
64
60
  ownership_information << 'This team owns nothing in this category.'
65
61
  else
66
- ownership_information += ownership_for_mapper
62
+ ownership_information += ownership_for_mapper.sort
67
63
  end
68
64
 
69
65
  ownership_information << ""
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_ownership
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.32.9
4
+ version: 1.32.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="