code_ownership 1.24.0 → 1.27.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a58e46098c8c50b7888308dff49901380c69ccad8211946ff5c67d94bfd9c541
|
4
|
+
data.tar.gz: 68078aa4407fa01ad485574543dc47af49039d9b0b8a8e55af75a81ff4018ef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cbdffd0dc477b6ed6c69dd61df2d2f6f732b3ae90acb141193e3ec1f3bd6af364c199c3abf2b29f4faddf393e75f39438aacc9f51590b3cc20736fb7deeda3d
|
7
|
+
data.tar.gz: e9604ec12ccbe6e1ae14fec8222a7cc93887d7e1ababbbcf318b7a3bbd6277f98add5ff47ff3244b068b030364177460022a8a2419a398c819d227396d2d19ee
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@ Check out `lib/code_ownership.rb` to see the public API.
|
|
5
5
|
|
6
6
|
Check out `code_ownership_spec.rb` to see examples of how code ownership is used.
|
7
7
|
|
8
|
+
There is also a [companion VSCode Extension]([url](https://github.com/bigrails/code-ownership-vscode)) for this gem. Just search `Gusto.code-ownership-vscode` in the VSCode Extension Marketplace.
|
9
|
+
|
8
10
|
## Usage: Declaring Ownership
|
9
11
|
There are three ways to declare code ownership using this gem.
|
10
12
|
### Package-Based Ownership
|
data/lib/code_ownership/cli.rb
CHANGED
@@ -11,7 +11,19 @@ module CodeOwnership
|
|
11
11
|
validate!(argv)
|
12
12
|
elsif command == 'for_file'
|
13
13
|
for_file(argv)
|
14
|
+
elsif [nil, "help"].include?(command)
|
15
|
+
puts <<~USAGE
|
16
|
+
Usage: bin/codeownership <subcommand>
|
17
|
+
|
18
|
+
Subcommands:
|
19
|
+
validate - run all validations
|
20
|
+
for_file - find code ownership for a single file
|
21
|
+
help - display help information about code_ownership
|
22
|
+
USAGE
|
23
|
+
else
|
24
|
+
puts "'#{command}' is not a code_ownership command. See `bin/codeownership help`."
|
14
25
|
end
|
26
|
+
|
15
27
|
end
|
16
28
|
|
17
29
|
def self.validate!(argv)
|
@@ -25,24 +25,66 @@ module CodeOwnership
|
|
25
25
|
# https://help.github.com/en/articles/about-code-owners
|
26
26
|
HEADER
|
27
27
|
|
28
|
-
|
29
|
-
header,
|
28
|
+
expected_content_lines = [
|
29
|
+
*header.split("\n"),
|
30
|
+
nil, # For line between header and codeowners_file_lines
|
30
31
|
*codeowners_file_lines,
|
31
32
|
nil, # For end-of-file newline
|
32
|
-
]
|
33
|
+
]
|
34
|
+
|
35
|
+
expected_contents = expected_content_lines.join("\n")
|
36
|
+
actual_contents = codeowners_filepath.exist? ? codeowners_filepath.read : ""
|
37
|
+
actual_content_lines = actual_contents.split("\n")
|
33
38
|
|
34
|
-
codeowners_up_to_date =
|
39
|
+
codeowners_up_to_date = actual_contents == expected_contents
|
35
40
|
|
36
41
|
errors = T.let([], T::Array[String])
|
37
42
|
|
38
43
|
if !codeowners_up_to_date
|
39
44
|
if autocorrect
|
40
|
-
codeowners_filepath.write(
|
45
|
+
codeowners_filepath.write(expected_contents)
|
41
46
|
if stage_changes
|
42
47
|
`git add #{codeowners_filepath}`
|
43
48
|
end
|
44
49
|
else
|
45
|
-
|
50
|
+
# If there is no current file or its empty, display a shorter message.
|
51
|
+
missing_lines = expected_content_lines - actual_content_lines
|
52
|
+
extra_lines = actual_content_lines - expected_content_lines
|
53
|
+
missing_lines_text = if missing_lines.any?
|
54
|
+
<<~COMMENT
|
55
|
+
CODEOWNERS should contain the following lines, but does not:
|
56
|
+
#{(expected_content_lines - actual_content_lines).map { |line| "- \"#{line}\""}.join("\n")}
|
57
|
+
COMMENT
|
58
|
+
end
|
59
|
+
|
60
|
+
extra_lines_text = if extra_lines.any?
|
61
|
+
<<~COMMENT
|
62
|
+
CODEOWNERS should not contain the following lines, but it does:
|
63
|
+
#{(actual_content_lines - expected_content_lines).map { |line| "- \"#{line}\""}.join("\n")}
|
64
|
+
COMMENT
|
65
|
+
end
|
66
|
+
|
67
|
+
diff_text = if missing_lines_text && extra_lines_text
|
68
|
+
"#{missing_lines_text}\n#{extra_lines_text}".chomp
|
69
|
+
elsif missing_lines_text
|
70
|
+
missing_lines_text
|
71
|
+
elsif extra_lines_text
|
72
|
+
extra_lines_text
|
73
|
+
else
|
74
|
+
""
|
75
|
+
end
|
76
|
+
|
77
|
+
if actual_contents == ""
|
78
|
+
errors << <<~CODEOWNERS_ERROR
|
79
|
+
CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
|
80
|
+
CODEOWNERS_ERROR
|
81
|
+
else
|
82
|
+
errors << <<~CODEOWNERS_ERROR
|
83
|
+
CODEOWNERS out of date. Run `bin/codeownership validate` to update the CODEOWNERS file
|
84
|
+
|
85
|
+
#{diff_text.chomp}
|
86
|
+
CODEOWNERS_ERROR
|
87
|
+
end
|
46
88
|
end
|
47
89
|
end
|
48
90
|
|
@@ -50,7 +50,7 @@ module CodeOwnership
|
|
50
50
|
end
|
51
51
|
|
52
52
|
if errors.any?
|
53
|
-
errors << 'See https://github.com/bigrails/code_ownership
|
53
|
+
errors << 'See https://github.com/bigrails/code_ownership#README.md for more details'
|
54
54
|
raise InvalidCodeOwnershipConfigurationError.new(errors.join("\n")) # rubocop:disable Style/RaiseArgs
|
55
55
|
end
|
56
56
|
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.
|
4
|
+
version: 1.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigrails-teams
|