owners 0.0.7 → 0.0.8
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 +34 -4
- data/example/OWNERS +7 -0
- data/example/db/migrate.rb +0 -0
- data/lib/owners/config.rb +16 -4
- data/lib/owners/version.rb +1 -1
- data/spec/owners_cli_spec.rb +1 -1
- data/spec/owners_spec.rb +20 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6b42791dcd2801448725619a34e70091c5d84b
|
4
|
+
data.tar.gz: dca77d4996a6a2e9e0fedf15a4b86308f37b5187
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c40ac244b5ff0bf3aa6c7a465a09291a784bfd97a9f8c5c3cdd8719581e6d9e6583defe885a1d69819a16d75daf7eaeda5fef755a597a4f52b1cab490585c94
|
7
|
+
data.tar.gz: 124a7bfa90f7aa4b59cc241d9b9da38053aca59e41735768972aca871fe21a936097dabef27af8b7d12134e3d0a96a09ba8c8e5bb856133ba8f9ddac06c09b8b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,18 +34,42 @@ jane@your-org.com
|
|
34
34
|
#some_slack_channel
|
35
35
|
```
|
36
36
|
|
37
|
-
The `OWNERS` file also supports
|
37
|
+
The `OWNERS` file also supports filtering paths with regular expressions. Any whitespace between these filters and their corresponding subscribers is ignored.
|
38
38
|
|
39
39
|
```
|
40
40
|
@data app/models/.*
|
41
41
|
@ui \.(css|haml|js|scss)$
|
42
42
|
bob@demo.com lib/bobs_special_file.rb
|
43
|
+
#whitespace path/with spaces/is all part/of the filter.txt
|
44
|
+
```
|
45
|
+
|
46
|
+
Subscribers can be listed multiple times in an `OWNERS` file.
|
47
|
+
|
48
|
+
```
|
49
|
+
@data app/models
|
50
|
+
@data db
|
51
|
+
```
|
52
|
+
|
53
|
+
Multiple comma separated subscribers can be listed for the same filter.
|
54
|
+
|
55
|
+
```
|
56
|
+
@data,@team-leads db
|
57
|
+
```
|
58
|
+
|
59
|
+
Comments are supported by prefixing lines with `//`.
|
60
|
+
|
61
|
+
```
|
62
|
+
// this comment will be ignored
|
63
|
+
//// this one two
|
64
|
+
// even this one with whitespace
|
65
|
+
|
66
|
+
@data,@team-leads db
|
43
67
|
```
|
44
68
|
|
45
69
|
Find the owners for specific files by passing them to the `Owners.for` method.
|
46
70
|
|
47
71
|
```ruby
|
48
|
-
Owners.for("
|
72
|
+
Owners.for("app/models/user.rb", "db/schema.rb") #=> ["@data", "@team-leads"]
|
49
73
|
```
|
50
74
|
|
51
75
|
To find the owners for files changed with `git diff` use the `Owners.for_diff` method.
|
@@ -54,8 +78,6 @@ To find the owners for files changed with `git diff` use the `Owners.for_diff` m
|
|
54
78
|
Owners.for_diff("your-feature-branch-or-ref", "optional-base-ref-defaults-to-master")
|
55
79
|
```
|
56
80
|
|
57
|
-
This method returns a unique array of all the owners who have subscribed to changes for the specified files. These subscribers can then be notified however you see fit!
|
58
|
-
|
59
81
|
|
60
82
|
## CLI
|
61
83
|
|
@@ -65,6 +87,14 @@ This gem also comes with a convenient `owners` command line interface. Each owne
|
|
65
87
|
owners for .env app/controllers/posts_controller.rb app/models/user.rb
|
66
88
|
```
|
67
89
|
|
90
|
+
```
|
91
|
+
@infrastructure
|
92
|
+
@api
|
93
|
+
@data
|
94
|
+
```
|
95
|
+
|
96
|
+
The `git diff` integration works in the command line as well.
|
97
|
+
|
68
98
|
```bash
|
69
99
|
owners for_diff my-feature-branch
|
70
100
|
```
|
data/example/OWNERS
CHANGED
File without changes
|
data/lib/owners/config.rb
CHANGED
@@ -4,6 +4,8 @@ module Owners
|
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
class Config
|
7
|
+
COMMENT = /^\s*\/\//
|
8
|
+
|
7
9
|
def initialize(file, contents = nil)
|
8
10
|
@contents = contents || file.read
|
9
11
|
@root = File.dirname(file.to_s)
|
@@ -14,9 +16,8 @@ module Owners
|
|
14
16
|
relative = path.sub(prefix, "")
|
15
17
|
|
16
18
|
search do |subscription, results|
|
17
|
-
|
18
|
-
|
19
|
-
results << owner if regex =~ relative
|
19
|
+
owners = subscribers(relative, subscription)
|
20
|
+
results.push(*owners)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -32,7 +33,18 @@ module Owners
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def subscriptions
|
35
|
-
@contents.split("\n").reject
|
36
|
+
@contents.split("\n").reject do |subscription|
|
37
|
+
subscription.empty? || subscription =~ COMMENT
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def subscribers(path, subscription)
|
42
|
+
subscribers, pattern = subscription.split(/\s+/, 2)
|
43
|
+
regex = Regexp.new(pattern || ".*")
|
44
|
+
|
45
|
+
subscribers.split(",").tap do |owners|
|
46
|
+
owners.clear unless regex =~ path
|
47
|
+
end
|
36
48
|
end
|
37
49
|
end
|
38
50
|
end
|
data/lib/owners/version.rb
CHANGED
data/spec/owners_cli_spec.rb
CHANGED
data/spec/owners_spec.rb
CHANGED
@@ -60,14 +60,30 @@ RSpec.describe Owners do
|
|
60
60
|
expect(subject).to eq(["@duplicate", "@org/blog", "@owner", "data@example.com"])
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
context "with multiple comma separated owners" do
|
65
|
+
let(:paths) { ["example/db/schema.rb"] }
|
66
|
+
|
67
|
+
it "parses owners correctly" do
|
68
|
+
expect(subject).to eq(["@multiple", "@org/blog", "@owners"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "with comments" do
|
73
|
+
let(:paths) { ["example/comment"] }
|
74
|
+
|
75
|
+
it "parses owners correctly" do
|
76
|
+
expect(subject).to eq(["@org/blog"])
|
77
|
+
end
|
78
|
+
end
|
63
79
|
end
|
64
80
|
|
65
81
|
describe ".for_diff" do
|
66
82
|
subject { described_class.for_diff(ref, base_ref) }
|
67
83
|
|
68
84
|
context "when comparing one commit" do
|
69
|
-
let(:ref) { "
|
70
|
-
let(:base_ref) { "
|
85
|
+
let(:ref) { "781b3b2" }
|
86
|
+
let(:base_ref) { "6f4f89a" }
|
71
87
|
|
72
88
|
it "parses owners correctly" do
|
73
89
|
expect(subject).to eq(["@org/blog"])
|
@@ -75,8 +91,8 @@ RSpec.describe Owners do
|
|
75
91
|
end
|
76
92
|
|
77
93
|
context "when comparing multiple commits" do
|
78
|
-
let(:ref) { "
|
79
|
-
let(:base_ref) { "
|
94
|
+
let(:ref) { "781b3b2" }
|
95
|
+
let(:base_ref) { "ba7cd78" }
|
80
96
|
|
81
97
|
it "parses owners correctly" do
|
82
98
|
expect(subject).to eq(["@org/blog", "@whitespace", "data@example.com"])
|
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.0.
|
4
|
+
version: 0.0.8
|
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-
|
11
|
+
date: 2016-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- example/app/models/comment.rb
|
65
65
|
- example/app/models/post.rb
|
66
66
|
- example/app/models/user.rb
|
67
|
+
- example/db/migrate.rb
|
67
68
|
- lib/owners.rb
|
68
69
|
- lib/owners/cli.rb
|
69
70
|
- lib/owners/config.rb
|