code_ownership 1.32.13 → 1.32.15

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: ad23d35594c57c575faa7afa4bdd7133efc848319d7279b6b28c8d7f67b7d2c0
4
- data.tar.gz: 7e21f92921d9053820eaf3722d4ee7064e5af726ea6c9c4af653bc7330e777bb
3
+ metadata.gz: a8705b2519d1dda2e50bc2051864d8f41b16111b3ab3a47923ff2b1e1c22024e
4
+ data.tar.gz: 2dd240f0854303fbbfd080a23f3c37ee38c5c6912f04e445ce9bc6fd08d6996e
5
5
  SHA512:
6
- metadata.gz: cbb45989ddbd059ba89632015ee8dc345bfb38932d008fe8edd1ea687de16b97367625a84db7c550cdd7ae20d08fe86d876f3252574564f4a6374ae3fcb9e49b
7
- data.tar.gz: fc2ee0036fe2780910ae7a6fe290c738a7466fd3608f4b06ae3c9daa470160bca203106c51a90772365bfd6563c0b0651ecb8d47a3849550a04a91c1491599a9
6
+ metadata.gz: c0de295ef841c8d50edffa5d8dedfeace747160d0c368b0b919d2aa76f4d3b540d80cd91b8eeea8578230b596613705cd6ed2dc72d524d240de5bd48162184bc
7
+ data.tar.gz: 0f9da2508a46330de7a75a8bf8b7ee1117f4a7449a53cf3516bd5e608b07f07b59e207a109ea40c14af22b575f75fdc02c2ee93eca427072eef13d29f76974d2
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
 
@@ -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
@@ -96,7 +96,7 @@ module CodeOwnership
96
96
  File.fnmatch?(unowned_glob, file, File::FNM_PATHNAME | File::FNM_EXTGLOB)
97
97
  end
98
98
 
99
- in_owned_globs && !in_unowned_globs
99
+ in_owned_globs && !in_unowned_globs && File.exist?(file)
100
100
  end
101
101
 
102
102
  sig { params(team_name: String, location_of_reference: String).returns(CodeTeams::Team) }
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.13
4
+ version: 1.32.15
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-15 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams