code_ownership 1.23.0 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/code_ownership/cli.rb +63 -2
- data/lib/code_ownership/private.rb +1 -1
- data/sorbet/rbi/manual.rbi +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 988c067afbabcc65d5b697aea162ba1c288787e4d7d9a84a261b00f76859aa6b
|
4
|
+
data.tar.gz: 6a504214d4470cfd2d1ab103f201069367e39962a390d34382410587a6067e40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b3e48c3cb734857dd66cf03f9d43d89bb92ee3ab92abfc0550004274531e03eef4abc9157fab33e25d815dd5b5c6f055d65987e7526dcb4952212930935678
|
7
|
+
data.tar.gz: 0f0cc9f4a1b8938e088bc258d5b247d633beaac3c68ddf37ea269fa3740d27d796b9773354e47855e79ecd5e958b49d97fd9f231f42502e62eab508d1d8ea9a1
|
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
@@ -6,12 +6,24 @@ require 'pathname'
|
|
6
6
|
module CodeOwnership
|
7
7
|
class Cli
|
8
8
|
def self.run!(argv)
|
9
|
-
# Someday we might support other subcommands. When we do that, we can call
|
10
|
-
# argv.shift to get the first argument and check if it's a given subcommand.
|
11
9
|
command = argv.shift
|
12
10
|
if command == 'validate'
|
13
11
|
validate!(argv)
|
12
|
+
elsif command == 'for_file'
|
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)
|
@@ -55,6 +67,55 @@ module CodeOwnership
|
|
55
67
|
)
|
56
68
|
end
|
57
69
|
|
70
|
+
# For now, this just returns team ownership
|
71
|
+
# Later, this could also return code ownership errors about that file.
|
72
|
+
def self.for_file(argv)
|
73
|
+
options = {}
|
74
|
+
|
75
|
+
# Long-term, we probably want to use something like `thor` so we don't have to implement logic
|
76
|
+
# like this. In the short-term, this is a simple way for us to use the built-in OptionParser
|
77
|
+
# while having an ergonomic CLI.
|
78
|
+
files = argv.select { |arg| !arg.start_with?('--') }
|
79
|
+
|
80
|
+
parser = OptionParser.new do |opts|
|
81
|
+
opts.banner = 'Usage: bin/codeownership for_file [options]'
|
82
|
+
|
83
|
+
opts.on('--json', 'Output as JSON') do
|
84
|
+
options[:json] = true
|
85
|
+
end
|
86
|
+
|
87
|
+
opts.on('--help', 'Shows this prompt') do
|
88
|
+
puts opts
|
89
|
+
exit
|
90
|
+
end
|
91
|
+
end
|
92
|
+
args = parser.order!(argv) {}
|
93
|
+
parser.parse!(args)
|
94
|
+
|
95
|
+
if files.count != 1
|
96
|
+
raise "Please pass in one file. Use `bin/codeownership for_file --help` for more info"
|
97
|
+
end
|
98
|
+
|
99
|
+
team = CodeOwnership.for_file(files.first)
|
100
|
+
|
101
|
+
team_name = team&.name || "Unowned"
|
102
|
+
team_yml = team&.config_yml || "Unowned"
|
103
|
+
|
104
|
+
if options[:json]
|
105
|
+
json = {
|
106
|
+
team_name: team_name,
|
107
|
+
team_yml: team_yml,
|
108
|
+
}
|
109
|
+
|
110
|
+
puts json.to_json
|
111
|
+
else
|
112
|
+
puts <<~MSG
|
113
|
+
Team: #{team_name}
|
114
|
+
Team YML: #{team_yml}
|
115
|
+
MSG
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
58
119
|
private_class_method :validate!
|
59
120
|
end
|
60
121
|
end
|
@@ -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.26.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-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigrails-teams
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- sorbet/config
|
152
152
|
- sorbet/rbi/gems/bigrails-teams@0.1.0.rbi
|
153
153
|
- sorbet/rbi/gems/parse_packwerk@0.7.0.rbi
|
154
|
+
- sorbet/rbi/manual.rbi
|
154
155
|
- sorbet/rbi/todo.rbi
|
155
156
|
homepage: https://github.com/bigrails/code_ownership
|
156
157
|
licenses:
|