code_ownership 1.32.4 → 1.32.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a1c1b52a35af9d0c7c7a48101ccd18cd120577bfd038ce83e6552e8b40e878
|
4
|
+
data.tar.gz: dc7ed2634d7adf107d59b4a4d9480429894e168b203c9ddc12767743ba52e12e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa8dd88901d526386ea1f3aae175f013e32e77cbfe7e36b2113ea8c3efccc4e8950f12f09bb01f9b3756a8de9cbe03ae470eee8de5a8bf64d599e8dab1eebf1
|
7
|
+
data.tar.gz: be6d7103274d1c628db0d28d1497b62364b5998540ba5e69bcd6ba0d9c2a5d5f834fe3b7aaa70654db7cfb9bbbd3af88c3c1ac9b055de0cf8475d1a9971f1435
|
@@ -13,7 +13,16 @@ module CodeOwnership
|
|
13
13
|
|
14
14
|
sig { returns(T::Array[String]) }
|
15
15
|
def self.actual_contents_lines
|
16
|
-
|
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
|
-
|
76
|
+
"", # For line between header and codeowners_file_lines
|
68
77
|
*codeowners_file_lines,
|
69
|
-
|
78
|
+
"", # For end-of-file newline
|
70
79
|
]
|
71
80
|
end
|
72
81
|
|
@@ -10,22 +10,19 @@ module CodeOwnership
|
|
10
10
|
|
11
11
|
sig { override.params(files: T::Array[String], autocorrect: T::Boolean, stage_changes: T::Boolean).returns(T::Array[String]) }
|
12
12
|
def validation_errors(files:, autocorrect: true, stage_changes: true)
|
13
|
-
allow_list = Dir.glob(Private.configuration.unowned_globs)
|
14
13
|
files_by_mapper = Private.glob_cache.files_by_mapper
|
15
14
|
|
16
15
|
files_not_mapped_at_all = files.select do |file|
|
17
16
|
files_by_mapper.fetch(file, []).count == 0
|
18
17
|
end
|
19
18
|
|
20
|
-
files_without_owners = files_not_mapped_at_all - allow_list
|
21
|
-
|
22
19
|
errors = T.let([], T::Array[String])
|
23
20
|
|
24
|
-
if
|
21
|
+
if files_not_mapped_at_all.any?
|
25
22
|
errors << <<~MSG
|
26
23
|
Some files are missing ownership:
|
27
24
|
|
28
|
-
#{
|
25
|
+
#{files_not_mapped_at_all.map { |file| "- #{file}" }.join("\n")}
|
29
26
|
MSG
|
30
27
|
end
|
31
28
|
|
@@ -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
|
-
|
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
|
@@ -76,7 +76,7 @@ module CodeOwnership
|
|
76
76
|
sig { returns(T::Array[String]) }
|
77
77
|
def self.tracked_files
|
78
78
|
@tracked_files ||= T.let(@tracked_files, T.nilable(T::Array[String]))
|
79
|
-
@tracked_files ||= Dir.glob(configuration.owned_globs)
|
79
|
+
@tracked_files ||= Dir.glob(configuration.owned_globs) - Dir.glob(configuration.unowned_globs)
|
80
80
|
end
|
81
81
|
|
82
82
|
sig { params(team_name: String, location_of_reference: String).returns(CodeTeams::Team) }
|