owners 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/owners/cli.rb +22 -17
- data/lib/owners/owner.rb +0 -2
- data/lib/owners/subscription.rb +18 -0
- data/lib/owners/version.rb +1 -1
- data/spec/owner_spec.rb +1 -1
- data/spec/owners_cli_spec.rb +4 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b247236f150660b0597f6585ef18b9baaaf6d65
|
4
|
+
data.tar.gz: 1f4dec428c925c16a02e647748d34a60f99addb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28bf4ed8f9ad70007507faad897fd0e8a7af4e81d3a921ec1a039803521e449e5420a3e7d816018799b4867240312ab6e55b6906fb3a97c18352aa3cea838451
|
7
|
+
data.tar.gz: 3166205427b49ed54e99e302ac54f7707b189e25408f1750e4f8c83f7f3810a7740e35309e0f2f52310c23c3ef3511eff6bc55ebeb4353c177807085685355a4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -84,7 +84,7 @@ This returns an array of `Owner` objects which are simple wrappers around
|
|
84
84
|
owners = Owners.for("db/schema.rb", ".env") #=> ["@data", "#internal"]
|
85
85
|
```
|
86
86
|
|
87
|
-
The owner's `type` can be one of `%i(alert email group label mention
|
87
|
+
The owner's `type` can be one of `%i(alert email group label mention tag)`.
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
owners.first.type #=> :mention
|
data/lib/owners/cli.rb
CHANGED
@@ -14,12 +14,7 @@ module Owners
|
|
14
14
|
|
15
15
|
desc "for [FILES...]", "List owners for a set of files"
|
16
16
|
def for(*files)
|
17
|
-
|
18
|
-
|
19
|
-
Owners.file = options[:file] if options[:file]
|
20
|
-
Owners.for(*files).each do |owner|
|
21
|
-
output(owner)
|
22
|
-
end
|
17
|
+
run(:for, files)
|
23
18
|
end
|
24
19
|
|
25
20
|
desc "for_diff REF [BASE_REF]", "List owners for a set of git changes"
|
@@ -32,12 +27,7 @@ module Owners
|
|
32
27
|
|
33
28
|
desc "missing_for [FILES...]", "List files that don't have owners"
|
34
29
|
def missing_for(*files)
|
35
|
-
|
36
|
-
|
37
|
-
Owners.file = options[:file] if options[:file]
|
38
|
-
Owners.missing_for(*files).each do |owner|
|
39
|
-
output(owner)
|
40
|
-
end
|
30
|
+
run(:missing_for, files)
|
41
31
|
end
|
42
32
|
|
43
33
|
no_commands do
|
@@ -45,16 +35,31 @@ module Owners
|
|
45
35
|
say owner
|
46
36
|
|
47
37
|
if options[:debug]
|
48
|
-
|
38
|
+
last_sub = nil
|
49
39
|
|
50
40
|
owner.subscriptions.each do |path, subscriptions|
|
51
41
|
subscriptions.each do |sub|
|
52
|
-
|
53
|
-
|
54
|
-
|
42
|
+
if last_sub != sub
|
43
|
+
say if last_sub
|
44
|
+
say " #{sub}", :blue
|
45
|
+
end
|
55
46
|
|
56
|
-
|
47
|
+
say " #{path}", :red unless path == sub.source
|
48
|
+
last_sub = sub
|
49
|
+
end
|
57
50
|
end
|
51
|
+
|
52
|
+
say
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def run(method, files)
|
57
|
+
files = stdin_files unless files.any?
|
58
|
+
|
59
|
+
Owners.file = options[:file] if options[:file]
|
60
|
+
|
61
|
+
Owners.send(method, *files).each do |owner|
|
62
|
+
output(owner)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
data/lib/owners/owner.rb
CHANGED
data/lib/owners/subscription.rb
CHANGED
@@ -7,6 +7,8 @@ module Owners
|
|
7
7
|
#
|
8
8
|
# @api public
|
9
9
|
class Subscription
|
10
|
+
include Comparable
|
11
|
+
|
10
12
|
COMMENT = /^\s*\/\//
|
11
13
|
WILDCARD = /.*/
|
12
14
|
|
@@ -20,14 +22,26 @@ module Owners
|
|
20
22
|
@root = config.root
|
21
23
|
end
|
22
24
|
|
25
|
+
def <=>(other)
|
26
|
+
location <=> other.location
|
27
|
+
end
|
28
|
+
|
23
29
|
def filter
|
24
30
|
Regexp.new(@filter || WILDCARD)
|
25
31
|
end
|
26
32
|
|
33
|
+
def location
|
34
|
+
[file, line].join(":")
|
35
|
+
end
|
36
|
+
|
27
37
|
def metadata?
|
28
38
|
comment? || empty?
|
29
39
|
end
|
30
40
|
|
41
|
+
def source
|
42
|
+
filter.source
|
43
|
+
end
|
44
|
+
|
31
45
|
def subscribed?(path)
|
32
46
|
path =~ prefix && relative(path) =~ filter
|
33
47
|
end
|
@@ -36,6 +50,10 @@ module Owners
|
|
36
50
|
@subscribers.split(",").reject(&:empty?)
|
37
51
|
end
|
38
52
|
|
53
|
+
def to_s
|
54
|
+
[source, location].join(" ")
|
55
|
+
end
|
56
|
+
|
39
57
|
private
|
40
58
|
|
41
59
|
def comment?
|
data/lib/owners/version.rb
CHANGED
data/spec/owner_spec.rb
CHANGED
data/spec/owners_cli_spec.rb
CHANGED
@@ -42,14 +42,12 @@ RSpec.describe Owners::CLI do
|
|
42
42
|
it "parses owners correctly" do
|
43
43
|
expected = <<-OUTPUT
|
44
44
|
@org/auth
|
45
|
-
|
46
|
-
|
47
|
-
example/app/OWNERS:1 => (?-mix:user)
|
45
|
+
user example/app/OWNERS:1
|
46
|
+
example/app/controllers/users_controller.rb
|
48
47
|
|
49
48
|
@org/blog
|
50
|
-
|
51
|
-
|
52
|
-
example/OWNERS:2 => (?-mix:.*)
|
49
|
+
.* example/OWNERS:2
|
50
|
+
example/app/controllers/users_controller.rb
|
53
51
|
|
54
52
|
OUTPUT
|
55
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: owners
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|