code_ownership 1.32.4 → 1.32.5

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: f304bfe47eb64942fd8bb38849942a508c37fb9a531397071fea5375fd7430cb
4
- data.tar.gz: 9f24b0084e84b9856f50a119178f661d7b09c50c4c5e2ff48a078dd4276674fd
3
+ metadata.gz: 18268f7457aeb632f100ea698349530dc29a4be7ae62611f416fe43782705a5b
4
+ data.tar.gz: 937353d0f07b1ff21ddf813dff047e59d4029c8ff6b08a29f75f31db61e342bb
5
5
  SHA512:
6
- metadata.gz: 384aa25cbb2b268bf9b820de2065783c506b46b560efdec3cc7dc2761dbeab0755d6a5bdc6c8c19b5932f9e36ce581ea13d4f14bfbf138d787977e78e7fa95e1
7
- data.tar.gz: 5917554485514a031239bc110b5ce99f4e84ef9b9a1af69df0564e552889be4fb5d7081d4708961f28ff497607e678c72e0ca19ceda573b6e75b81f85ac675e0
6
+ metadata.gz: 33c6f36e7a037a8495a370b738715cc2eb557912d4cb2f14df9184b329a6cc18e2c8e0a3f56fc0afd86d028ea321c2737043b8f94a88e5b3ea7c3486ff026216
7
+ data.tar.gz: 1665092ef4a69c4eecd08039fa1315be6bca38aaec17ead77573ede1c408c4b1e4a9c5a1746505310abaebe07f14c95cb088b691d71ee66b35eaa84ef40db8bd
@@ -13,7 +13,16 @@ module CodeOwnership
13
13
 
14
14
  sig { returns(T::Array[String]) }
15
15
  def self.actual_contents_lines
16
- (path.exist? ? path.read : "").split("\n")
16
+ if !path.exist?
17
+ [""]
18
+ else
19
+ content = path.read
20
+ lines = path.read.split("\n")
21
+ if content.end_with?("\n")
22
+ lines << ""
23
+ end
24
+ lines
25
+ end
17
26
  end
18
27
 
19
28
  sig { returns(T::Array[T.nilable(String)]) }
@@ -64,9 +73,9 @@ module CodeOwnership
64
73
 
65
74
  [
66
75
  *header.split("\n"),
67
- nil, # For line between header and codeowners_file_lines
76
+ "", # For line between header and codeowners_file_lines
68
77
  *codeowners_file_lines,
69
- nil, # For end-of-file newline
78
+ "", # For end-of-file newline
70
79
  ]
71
80
  end
72
81
 
@@ -14,8 +14,10 @@ module CodeOwnership
14
14
 
15
15
  actual_content_lines = CodeownersFile.actual_contents_lines
16
16
  expected_content_lines = CodeownersFile.expected_contents_lines
17
- codeowners_up_to_date = actual_content_lines == expected_content_lines
17
+ missing_lines = expected_content_lines - actual_content_lines
18
+ extra_lines = actual_content_lines - expected_content_lines
18
19
 
20
+ codeowners_up_to_date = !missing_lines.any? && !extra_lines.any?
19
21
  errors = T.let([], T::Array[String])
20
22
 
21
23
  if !codeowners_up_to_date
@@ -26,8 +28,6 @@ module CodeOwnership
26
28
  end
27
29
  else
28
30
  # If there is no current file or its empty, display a shorter message.
29
- missing_lines = expected_content_lines - actual_content_lines
30
- extra_lines = actual_content_lines - expected_content_lines
31
31
 
32
32
  missing_lines_text = if missing_lines.any?
33
33
  <<~COMMENT
@@ -53,7 +53,7 @@ module CodeOwnership
53
53
  ""
54
54
  end
55
55
 
56
- if actual_content_lines == []
56
+ if actual_content_lines == [""]
57
57
  errors << <<~CODEOWNERS_ERROR
58
58
  CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
59
59
  CODEOWNERS_ERROR
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_ownership
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.32.4
4
+ version: 1.32.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers