code_ownership 1.32.10 → 1.32.12

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: e0713332aa7dacd9ec6f097bba250555cb25208f594fd08bfba4a4ecf951d06b
4
- data.tar.gz: aa039e732cfa8aad7a16439bc2608f51c043eef2f9b642513a7616b95b319c01
3
+ metadata.gz: b1b8e7ef51559926e34ee47610390c8f5db30d4db7f4cdcfc2abd84381b49130
4
+ data.tar.gz: cf479183e50a26c9a19f37b8160c14ad0ab81f5f0c2906b4cefa4f45e19aad76
5
5
  SHA512:
6
- metadata.gz: 1c7b7a855b051aa6c856f39144e17484180fa6ff530ec7af3b7870ebf4cbf61b5b33c1a17d2402a319d784a7a17d7b226b64542c65a002707bb87419e1a660dd
7
- data.tar.gz: b91f701455620e4fe27f2a99b20b58f6b03d78fa04d66548d3f85b1e4202cdf9c09ec2b53a454a3bca419d33b65150c5c24977e9eca93efc102c25e36df21303
6
+ metadata.gz: 37d5cd46fda60ec57244bc2b654dd81ea3bbd48c47cb3008804dbdb48249ae7c9a2163f9d2776bdc08989aaa945f3e8f2718784a27009b578b131cf9259307e3
7
+ data.tar.gz: a89b8b30f8acb6f82c6727ede45e3c372cdca5204343e155a2d4300c221fc50ab1feea708afdee8a123601078979e6accfbfec5d4381af2bf67a684db938fda8
@@ -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
@@ -135,6 +135,12 @@ module CodeOwnership
135
135
  # This will skip over lines that are not of the correct form
136
136
  next if split_line.count > 2
137
137
  entry, github_team = split_line
138
+ code_team = github_team_to_code_team_map[T.must(github_team)]
139
+ # If a GitHub team is changed and a user runs `bin/codeownership validate`, we won't be able to identify
140
+ # what team is associated with the removed github team.
141
+ # Therefore, if we can't determine the team, we just skip it.
142
+ # This affects how complete the cache is, but that will still be caught by `bin/codeownership validate`.
143
+ next if code_team.nil?
138
144
  raw_cache_contents[current_mapper] ||= {}
139
145
  raw_cache_contents.fetch(current_mapper)[T.must(entry)] = github_team_to_code_team_map.fetch(T.must(github_team))
140
146
  end
@@ -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,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.10
4
+ version: 1.32.12
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-12 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams