code_ownership 1.32.17 → 1.32.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aea9ab810bdf433b824ae72f06c4f33773139e6a5613a67ac29b5ff92e38ba70
4
- data.tar.gz: 898b6d683ca5f3a4100eae345f2ff06ffff8024b63e8985b49ce86644d5401e3
3
+ metadata.gz: 994693da06866743ce4cf2fa3b6bee1df754ac26e10884c999f0c37c9b72c23c
4
+ data.tar.gz: 5b2643e5ecd989f8ea15984a59b0b0a2522dbc614441228e10f7e25958141af0
5
5
  SHA512:
6
- metadata.gz: 1294593e12fccc2cdbbc9946652dd5e80c75fd862cfbc2fc1fc0b5d7fb5632d1870da55cb639ea969efb7ff8fa9202c06b82d0c257ef4eda83f40c972d791cd4
7
- data.tar.gz: 5160484ffc1919619082c13793cea928155743b6319fe69606f8a4f7447fbebc62bca78f714d947ee9a293b1543cf5dbfc719e861c4a14d43d68eba5dea86a9b
6
+ metadata.gz: e832b86888eb90bb0beaff6410565f20c9224029af7d434698238039422ca67a6e34a0629a4441ab428fe73dddfac2bf606200191c621836989bbf67daff05a6
7
+ data.tar.gz: 2e5b208eb94ff9cc870e53d3673cc794f87af20f7d78c80a1493e3b9edfd2c2403285731b6b5b07292df5855ddf6e55c4f0b16d102bcb65c1dc6844ed39dfcf1
data/README.md CHANGED
@@ -96,7 +96,7 @@ See `code_ownership_spec.rb` for an example.
96
96
  `CodeOwnership.for_class` can be given a class and will either return `nil`, or a `CodeTeams::Team`.
97
97
 
98
98
  ```ruby
99
- CodeOwnership.for_class(MyClass.name)
99
+ CodeOwnership.for_class(MyClass)
100
100
  ```
101
101
 
102
102
  Under the hood, this finds the file where the class is defined and returns the owner of that file.
@@ -12,16 +12,16 @@ module CodeOwnership
12
12
  class << self
13
13
  extend T::Sig
14
14
 
15
- sig { params(base: Class).void }
15
+ sig { params(base: T::Class[Mapper]).void }
16
16
  def included(base)
17
- @mappers ||= T.let(@mappers, T.nilable(T::Array[Class]))
17
+ @mappers ||= T.let(@mappers, T.nilable(T::Array[T::Class[Mapper]]))
18
18
  @mappers ||= []
19
19
  @mappers << base
20
20
  end
21
21
 
22
22
  sig { returns(T::Array[Mapper]) }
23
23
  def all
24
- T.unsafe(@mappers).map(&:new)
24
+ (@mappers || []).map(&:new)
25
25
  end
26
26
  end
27
27
 
@@ -53,7 +53,10 @@ module CodeOwnership
53
53
 
54
54
  cache.each do |mapper_description, ownership_map_cache|
55
55
  ownership_entries = []
56
- ownership_map_cache.each do |path, code_team|
56
+ sorted_ownership_map_cache = ownership_map_cache.sort_by do |glob, team|
57
+ glob
58
+ end
59
+ sorted_ownership_map_cache.to_h.each do |path, code_team|
57
60
  team_mapping = github_team_map[code_team.name]
58
61
  next if team_mapping.nil?
59
62
 
@@ -14,10 +14,8 @@ module CodeOwnership
14
14
 
15
15
  actual_content_lines = CodeownersFile.actual_contents_lines
16
16
  expected_content_lines = CodeownersFile.expected_contents_lines
17
- missing_lines = expected_content_lines - actual_content_lines
18
- extra_lines = actual_content_lines - expected_content_lines
19
17
 
20
- codeowners_up_to_date = !missing_lines.any? && !extra_lines.any?
18
+ codeowners_up_to_date = actual_content_lines == expected_content_lines
21
19
  errors = T.let([], T::Array[String])
22
20
 
23
21
  if !codeowners_up_to_date
@@ -26,8 +24,14 @@ module CodeOwnership
26
24
  if stage_changes
27
25
  `git add #{CodeownersFile.path}`
28
26
  end
27
+ # If there is no current file or its empty, display a shorter message.
28
+ elsif actual_content_lines == [""]
29
+ errors << <<~CODEOWNERS_ERROR
30
+ CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
31
+ CODEOWNERS_ERROR
29
32
  else
30
- # If there is no current file or its empty, display a shorter message.
33
+ missing_lines = expected_content_lines - actual_content_lines
34
+ extra_lines = actual_content_lines - expected_content_lines
31
35
 
32
36
  missing_lines_text = if missing_lines.any?
33
37
  <<~COMMENT
@@ -50,20 +54,19 @@ module CodeOwnership
50
54
  elsif extra_lines_text
51
55
  extra_lines_text
52
56
  else
53
- ""
57
+ <<~TEXT
58
+ There may be extra lines, or lines are out of order.
59
+ You can try to regenerate the CODEOWNERS file from scratch:
60
+ 1) `rm .github/CODEOWNERS`
61
+ 2) `bin/codeownership validate`
62
+ TEXT
54
63
  end
55
64
 
56
- if actual_content_lines == [""]
57
- errors << <<~CODEOWNERS_ERROR
58
- CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
59
- CODEOWNERS_ERROR
60
- else
61
- errors << <<~CODEOWNERS_ERROR
62
- CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
65
+ errors << <<~CODEOWNERS_ERROR
66
+ CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
63
67
 
64
- #{diff_text.chomp}
65
- CODEOWNERS_ERROR
66
- end
68
+ #{diff_text.chomp}
69
+ CODEOWNERS_ERROR
67
70
  end
68
71
  end
69
72
 
@@ -14,16 +14,16 @@ module CodeOwnership
14
14
  class << self
15
15
  extend T::Sig
16
16
 
17
- sig { params(base: Class).void }
17
+ sig { params(base: T::Class[Validator]).void }
18
18
  def included(base)
19
- @validators ||= T.let(@validators, T.nilable(T::Array[Class]))
19
+ @validators ||= T.let(@validators, T.nilable(T::Array[T::Class[Validator]]))
20
20
  @validators ||= []
21
21
  @validators << base
22
22
  end
23
23
 
24
24
  sig { returns(T::Array[Validator]) }
25
25
  def all
26
- T.unsafe(@validators).map(&:new)
26
+ (@validators || []).map(&:new)
27
27
  end
28
28
  end
29
29
  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.17
4
+ version: 1.32.19
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-05-01 00:00:00.000000000 Z
11
+ date: 2023-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.5.10821
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.5.10821
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement