Skip to content

Commit 67cb391

Browse files
author
Alex Evanczuk
authored
Write commented out CODEOWNERS entries for opted-out teams (#49)
* Write commented out CODEOWNERS entries for opted-out teams * bump version
1 parent ce31f6a commit 67cb391

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
code_ownership (1.32.6)
4+
code_ownership (1.32.7)
55
code_teams (~> 1.0)
66
packs
77
sorbet-runtime

code_ownership.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = "code_ownership"
3-
spec.version = '1.32.6'
3+
spec.version = '1.32.7'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'

lib/code_ownership/private/codeowners_file.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ def self.expected_contents_lines
5656
ownership_map_cache.each do |path, code_team|
5757
team_mapping = github_team_map[code_team.name]
5858
next if team_mapping.nil?
59-
next if ignored_teams.include?(code_team.name)
60-
entry = "/#{path} #{team_mapping}"
61-
# In order to use the codeowners file as a proper cache, we'll need to insert commented out entries for ignored teams
62-
# entry = if ignored_teams.include?(code_team.name)
63-
# "# /#{path} #{team_mapping}"
64-
# else
65-
# "/#{path} #{team_mapping}"
66-
# end
59+
60+
# Leaving a commented out entry has two major benefits:
61+
# 1) It allows the CODEOWNERS file to be used as a cache for validations
62+
# 2) It allows users to specifically see what their team will not be notified about.
63+
entry = if ignored_teams.include?(code_team.name)
64+
"# /#{path} #{team_mapping}"
65+
else
66+
"/#{path} #{team_mapping}"
67+
end
6768
ownership_entries << entry
6869
end
6970

spec/lib/code_ownership/private/validations/github_codeowners_up_to_date_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ module CodeOwnership
150150
# code/file owner is notified. Reference GitHub docs for more details:
151151
# https://help.github.com/en/articles/about-code-owners
152152
153+
154+
# Annotations at the top of file
155+
# /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team
156+
# /packs/my_pack/owned_file.rb @MyOrg/bar-team
157+
158+
# Team-specific owned globs
159+
# /app/services/bar_stuff/** @MyOrg/bar-team
160+
# /frontend/javascripts/bar_stuff/** @MyOrg/bar-team
161+
162+
# Owner metadata key in package.yml
163+
# /packs/my_other_package/**/** @MyOrg/bar-team
164+
165+
# Owner metadata key in package.json
166+
# /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team
167+
168+
# Team YML ownership
169+
# /config/teams/bar.yml @MyOrg/bar-team
153170
EXPECTED
154171
end
155172
end

0 commit comments

Comments
 (0)