Skip to content

Commit

Permalink
Write commented out CODEOWNERS entries for opted-out teams (#49)
Browse files Browse the repository at this point in the history
* Write commented out CODEOWNERS entries for opted-out teams

* bump version
  • Loading branch information
Alex Evanczuk authored Apr 11, 2023
1 parent ce31f6a commit 67cb391
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
code_ownership (1.32.6)
code_ownership (1.32.7)
code_teams (~> 1.0)
packs
sorbet-runtime
Expand Down
2 changes: 1 addition & 1 deletion code_ownership.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "code_ownership"
spec.version = '1.32.6'
spec.version = '1.32.7'
spec.authors = ['Gusto Engineers']
spec.email = ['[email protected]']
spec.summary = 'A gem to help engineering teams declare ownership of code'
Expand Down
17 changes: 9 additions & 8 deletions lib/code_ownership/private/codeowners_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ def self.expected_contents_lines
ownership_map_cache.each do |path, code_team|
team_mapping = github_team_map[code_team.name]
next if team_mapping.nil?
next if ignored_teams.include?(code_team.name)
entry = "/#{path} #{team_mapping}"
# In order to use the codeowners file as a proper cache, we'll need to insert commented out entries for ignored teams
# entry = if ignored_teams.include?(code_team.name)
# "# /#{path} #{team_mapping}"
# else
# "/#{path} #{team_mapping}"
# end

# Leaving a commented out entry has two major benefits:
# 1) It allows the CODEOWNERS file to be used as a cache for validations
# 2) It allows users to specifically see what their team will not be notified about.
entry = if ignored_teams.include?(code_team.name)
"# /#{path} #{team_mapping}"
else
"/#{path} #{team_mapping}"
end
ownership_entries << entry
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ module CodeOwnership
# code/file owner is notified. Reference GitHub docs for more details:
# https://help.github.com/en/articles/about-code-owners
# Annotations at the top of file
# /frontend/javascripts/packages/my_package/owned_file.jsx @MyOrg/bar-team
# /packs/my_pack/owned_file.rb @MyOrg/bar-team
# Team-specific owned globs
# /app/services/bar_stuff/** @MyOrg/bar-team
# /frontend/javascripts/bar_stuff/** @MyOrg/bar-team
# Owner metadata key in package.yml
# /packs/my_other_package/**/** @MyOrg/bar-team
# Owner metadata key in package.json
# /frontend/javascripts/packages/my_other_package/**/** @MyOrg/bar-team
# Team YML ownership
# /config/teams/bar.yml @MyOrg/bar-team
EXPECTED
end
end
Expand Down

0 comments on commit 67cb391

Please sign in to comment.