code_ownership 1.23.0 → 1.24.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: c664c64c94e083083f3187002fc77ffb7d40cbc7c5c76ae0291b9d5c11cd224f
4
- data.tar.gz: cf6dcc613f67a6e7723fa73a079dabfa8782ddba886441afd8e5608eaa9249ec
3
+ metadata.gz: 159aa45c6ffe9f310d507c4d06499d69120e0476e4963153e7868360e84c5a55
4
+ data.tar.gz: d75353d8bfc1acb396fb3f5038869276edfda3344dcd696d101ba06486bcb191
5
5
  SHA512:
6
- metadata.gz: 54373f777f534bd2f600510e1ee94b85151bc5016d076d35ef5ed7d140a1d8b53d1bcea24a1af2badebc5939c52c1e2660e066eb49fcbcc4fb7a330cf227664f
7
- data.tar.gz: c94fd3d689b09a27b8db89b339e3037ec8e6c1fe76413226b22662ce068599ecd30a6aa80e0f90e389a0d1a17bb58afebd650ed4c8bd57523336bd688517f819
6
+ metadata.gz: 850c1fe50565aba5a2dd7c907d90fe1143a2a8c9a375b9234044811782eb7d01ce8a83197539d4026d70df6a3321c1c814d3e2dcb20290c11bf375317f41297d
7
+ data.tar.gz: 2bcedfdc8a6339a47994ed60379971e2518118a4b22dc1a998d3935878e47e37306693547b162c53b608161672821dab599216bab72c47df45efce57b675b404
@@ -6,11 +6,11 @@ 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
14
  end
15
15
  end
16
16
 
@@ -55,6 +55,55 @@ module CodeOwnership
55
55
  )
56
56
  end
57
57
 
58
+ # For now, this just returns team ownership
59
+ # Later, this could also return code ownership errors about that file.
60
+ def self.for_file(argv)
61
+ options = {}
62
+
63
+ # Long-term, we probably want to use something like `thor` so we don't have to implement logic
64
+ # like this. In the short-term, this is a simple way for us to use the built-in OptionParser
65
+ # while having an ergonomic CLI.
66
+ files = argv.select { |arg| !arg.start_with?('--') }
67
+
68
+ parser = OptionParser.new do |opts|
69
+ opts.banner = 'Usage: bin/codeownership for_file [options]'
70
+
71
+ opts.on('--json', 'Output as JSON') do
72
+ options[:json] = true
73
+ end
74
+
75
+ opts.on('--help', 'Shows this prompt') do
76
+ puts opts
77
+ exit
78
+ end
79
+ end
80
+ args = parser.order!(argv) {}
81
+ parser.parse!(args)
82
+
83
+ if files.count != 1
84
+ raise "Please pass in one file. Use `bin/codeownership for_file --help` for more info"
85
+ end
86
+
87
+ team = CodeOwnership.for_file(files.first)
88
+
89
+ team_name = team&.name || "Unowned"
90
+ team_yml = team&.config_yml || "Unowned"
91
+
92
+ if options[:json]
93
+ json = {
94
+ team_name: team_name,
95
+ team_yml: team_yml,
96
+ }
97
+
98
+ puts json.to_json
99
+ else
100
+ puts <<~MSG
101
+ Team: #{team_name}
102
+ Team YML: #{team_yml}
103
+ MSG
104
+ end
105
+ end
106
+
58
107
  private_class_method :validate!
59
108
  end
60
109
  end
@@ -0,0 +1,3 @@
1
+ class Hash
2
+ def to_json; end
3
+ 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.23.0
4
+ version: 1.24.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-05-09 00:00:00.000000000 Z
11
+ date: 2022-05-10 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: