code_ownership 1.32.14 → 1.32.16

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: c54909c0c5a072df5080509fc4668dc9770fd83d77af60b7469e9cfb0560266d
4
- data.tar.gz: 6854819e28031063796f639714943a8f61eacb31cf8d665c06f4434e01530f20
3
+ metadata.gz: 7a5c5f4a43ef44ffca514c001aa9eae7042bcdf445913afaa15adf40520e1d6d
4
+ data.tar.gz: e6cb1255f18886edabdd09086ed86d616742b9683311b657e7ba4c418baff443
5
5
  SHA512:
6
- metadata.gz: 9fe8a85e433ee7eded9c939f23e112304e06e7c90debe840d4ba5810ba274f7d021df890e9da1c83eded7c8999eb0377be82513470ca8e2ef3a6e2bb5a505a2e
7
- data.tar.gz: f33c0630d6f3014a07caa9b042897e8aab71fed3ec649566b6c189d2b20ad02e973162542efb6828a91616cf911756d353c1544ccd3e9c88c56f988e0c493967
6
+ metadata.gz: ede48eace0e4e7096671816ba0c1264fad5d3ea465ba5473a5724da95623e4982e5058b81f8eca0df39602889d88a3ea041cdb12fbb0a9e489b029fe32fa8579
7
+ data.tar.gz: 55c7bd2a181710065712eb211b969dbefbfb9d83daedbfec324816cc8aae38fd1161ddde6b049370866a00d75b6a4df5d374629a5a619cabbb8f8e1e8b511182
data/README.md CHANGED
@@ -125,7 +125,7 @@ CodeOwnership comes with a validation function to ensure the following things ar
125
125
  1) Only one mechanism is defining file ownership. That is -- you can't have a file annotation on a file owned via package-based or glob-based ownership. This helps make ownership behavior more clear by avoiding concerns about precedence.
126
126
  2) All teams referenced as an owner for any file or package is a valid team (i.e. it's in the list of `CodeTeams.all`).
127
127
  3) All files have ownership. You can specify in `unowned_globs` to represent a TODO list of files to add ownership to.
128
- 3) The `.github/CODEOWNERS` file is up to date. This is automatically corrected and staged unless specified otherwise with `bin/codeownership validate --skip-autocorrect --skip-stage`. You can turn this validation off by setting `skip_codeowners_validation: true` in `code_ownership.yml`.
128
+ 3) The `.github/CODEOWNERS` file is up to date. This is automatically corrected and staged unless specified otherwise with `bin/codeownership validate --skip-autocorrect --skip-stage`. You can turn this validation off by setting `skip_codeowners_validation: true` in `config/code_ownership.yml`.
129
129
 
130
130
  CodeOwnership also allows you to specify which globs and file extensions should be considered ownable.
131
131
 
@@ -47,10 +47,19 @@ module CodeOwnership
47
47
  override.params(cache: GlobsToOwningTeamMap, files: T::Array[String]).returns(GlobsToOwningTeamMap)
48
48
  end
49
49
  def update_cache(cache, files)
50
- cache.merge!(globs_to_owner(files))
50
+ # We map files to nil owners so that files whose annotation have been removed will be properly
51
+ # overwritten (i.e. removed) from the cache.
52
+ updated_cache_for_files = globs_to_owner(files)
53
+ cache.merge!(updated_cache_for_files)
54
+
51
55
  invalid_files = cache.keys.select do |file|
52
- !Private.file_tracked?(file)
56
+ # If a file is not tracked, it should be removed from the cache
57
+ !Private.file_tracked?(file) ||
58
+ # If a file no longer has a file annotation (i.e. `globs_to_owner` doesn't map it)
59
+ # it should be removed from the cache
60
+ !updated_cache_for_files.key?(file)
53
61
  end
62
+
54
63
  invalid_files.each do |invalid_file|
55
64
  cache.delete(invalid_file)
56
65
  end
@@ -18,6 +18,28 @@ module CodeOwnership
18
18
  raw_github['do_not_add_to_codeowners_file'] || false
19
19
  )
20
20
  end
21
+
22
+ sig { override.params(teams: T::Array[CodeTeams::Team]).returns(T::Array[String]) }
23
+ def self.validation_errors(teams)
24
+ all_github_teams = teams.flat_map { |team| self.for(team).github.team }
25
+
26
+ teams_used_more_than_once = all_github_teams.tally.select do |_team, count|
27
+ count > 1
28
+ end
29
+
30
+ errors = T.let([], T::Array[String])
31
+
32
+ if teams_used_more_than_once.any?
33
+ errors << <<~ERROR
34
+ The following teams are specified multiple times:
35
+ Each code team must have a unique GitHub team in order to write the CODEOWNERS file correctly.
36
+
37
+ #{teams_used_more_than_once.keys.join("\n")}
38
+ ERROR
39
+ end
40
+
41
+ errors
42
+ end
21
43
  end
22
44
  end
23
45
  end
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.14
4
+ version: 1.32.16
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-17 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams