owners 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 64c2797db569920e3c8203794993b523da633e2f
4
- data.tar.gz: 92e8420a4de1f80b20a62e1beb0564aba38fa58c
3
+ metadata.gz: 5b6b42791dcd2801448725619a34e70091c5d84b
4
+ data.tar.gz: dca77d4996a6a2e9e0fedf15a4b86308f37b5187
5
5
  SHA512:
6
- metadata.gz: 7b5b94331a57d20452c827b3adb5b64352f969533fb52fa14504810af5ca89071fa5a0c30f43b008a0f981d19c6cfff010798524bb2f526c96573429eb073d28
7
- data.tar.gz: 1b286d7dc02d0a0d15d841369bc443b6be22db1b5fa3c9d4a0e2cb632888dec2c6c48092a36be6da44fe72e6dcec1e9a493509e20bfb40ab03c82d30f4466791
6
+ metadata.gz: 1c40ac244b5ff0bf3aa6c7a465a09291a784bfd97a9f8c5c3cdd8719581e6d9e6583defe885a1d69819a16d75daf7eaeda5fef755a597a4f52b1cab490585c94
7
+ data.tar.gz: 124a7bfa90f7aa4b59cc241d9b9da38053aca59e41735768972aca871fe21a936097dabef27af8b7d12134e3d0a96a09ba8c8e5bb856133ba8f9ddac06c09b8b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- owners (0.0.7)
4
+ owners (0.0.8)
5
5
  thor
6
6
 
7
7
  GEM
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 limiting paths with regular expressions. Any whitespace that separates the subscriber from the path limiters is ignored.
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(".env", "app/controllers/posts_controller.rb", "app/models/user.rb")
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
  ```
@@ -1 +1,8 @@
1
+ // comment
1
2
  @org/blog
3
+ @multiple,@owners db
4
+ //comment
5
+
6
+ ////// comment
7
+
8
+ // comment
File without changes
@@ -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
- owner, pattern = subscription.split(/\s+/, 2)
18
- regex = Regexp.new(pattern || ".*")
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(&:empty?)
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
@@ -1,3 +1,3 @@
1
1
  module Owners
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -35,7 +35,7 @@ RSpec.describe Owners::CLI do
35
35
  end
36
36
 
37
37
  describe "for_diff" do
38
- let(:args) { ["for_diff", "0757297", "d0e67df"] }
38
+ let(:args) { ["for_diff", "781b3b2", "ba7cd78"] }
39
39
 
40
40
  context "without a specified file" do
41
41
  it "parses owners correctly" do
@@ -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) { "0757297" }
70
- let(:base_ref) { "6683118" }
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) { "0757297" }
79
- let(:base_ref) { "d0e67df" }
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.7
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-01-15 00:00:00.000000000 Z
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