code_owners 1.0.8 → 1.0.9
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/code_owners/version.rb +1 -1
- data/lib/code_owners.rb +5 -1
- data/spec/code_owners_spec.rb +26 -2
- data/spec/files/file name.txt +1 -0
- 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: add8d9474667ea07ea6ad3e207e9a0e085109ac9
|
4
|
+
data.tar.gz: 86f55b021ef6314614ac2e5f2a59dfec43adbcd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc09a62ef1d0b86e7a9be070b27c5ed0e21be5b797f29b2597b3c06ffecc8210fd50906319f67028bc8e8a4df3aa2b575ab5ae49a083f2af029f43182d9d074
|
7
|
+
data.tar.gz: 62e13f5c44667eff192eabb510dca677a2088e58ce123e3dbaf4ccd16c8ebf9eb1dffa8125d5524161de36df730b9eea83093776ea6a55fb40c72df6f741eec3
|
data/Gemfile.lock
CHANGED
data/lib/code_owners/version.rb
CHANGED
data/lib/code_owners.rb
CHANGED
@@ -19,6 +19,10 @@ module CodeOwners
|
|
19
19
|
puts message
|
20
20
|
end
|
21
21
|
|
22
|
+
def file_ownerships
|
23
|
+
Hash[ ownerships.map { |o| [o[:file], o] } ]
|
24
|
+
end
|
25
|
+
|
22
26
|
def ownerships
|
23
27
|
patterns = pattern_owners
|
24
28
|
git_owner_info(patterns.map { |p| p[0] }).map do |line, pattern, file|
|
@@ -77,7 +81,7 @@ module CodeOwners
|
|
77
81
|
Tempfile.open('codeowner_patterns') do |file|
|
78
82
|
file.write(patterns.join("\n"))
|
79
83
|
file.rewind
|
80
|
-
`cd #{current_repo_path} && git -c \"core.quotepath=off\" ls-files | xargs -- git -c \"core.quotepath=off\" -c \"core.excludesfile=#{file.path}\" check-ignore --no-index -v -n`
|
84
|
+
`cd #{current_repo_path} && git -c \"core.quotepath=off\" ls-files -z | xargs -0 -- git -c \"core.quotepath=off\" -c \"core.excludesfile=#{file.path}\" check-ignore --no-index -v -n`
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
data/spec/code_owners_spec.rb
CHANGED
@@ -2,6 +2,23 @@ require 'code_owners'
|
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
4
|
RSpec.describe CodeOwners do |rspec|
|
5
|
+
describe ".file_ownerships" do
|
6
|
+
it "returns a hash of ownerships keyed by file path" do
|
7
|
+
expect(CodeOwners).to receive(:ownerships).and_return(
|
8
|
+
[
|
9
|
+
{ file: "pat2file", owner: "own2", line: "2", pattern: "pat2*" },
|
10
|
+
{ file: "unowned/file", owner: "UNOWNED", line: nil, pattern: nil }
|
11
|
+
]
|
12
|
+
)
|
13
|
+
expect(CodeOwners.file_ownerships).to eq(
|
14
|
+
{
|
15
|
+
"pat2file" => { file: "pat2file", owner: "own2", line: "2", pattern: "pat2*" },
|
16
|
+
"unowned/file" => { file: "unowned/file", owner: "UNOWNED", line: nil, pattern: nil }
|
17
|
+
}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
5
22
|
describe ".ownerships" do
|
6
23
|
it "assigns owners to things" do
|
7
24
|
expect(CodeOwners).to receive(:pattern_owners).and_return([["pat1", "own1"], ["pat2*", "own2"], ["pat3", "own3"]])
|
@@ -29,7 +46,7 @@ RSpec.describe CodeOwners do |rspec|
|
|
29
46
|
lib/* @jcheatham
|
30
47
|
some/path/** @someoneelse
|
31
48
|
other/path/* @someoneelse @anotherperson
|
32
|
-
invalid/
|
49
|
+
invalid/code owners/line
|
33
50
|
@AnotherInvalidLine
|
34
51
|
#comment-line (empty line next)
|
35
52
|
|
@@ -60,7 +77,7 @@ CODEOWNERS
|
|
60
77
|
|
61
78
|
it "prints validation errors and skips lines that aren't the expected format" do
|
62
79
|
expect(CodeOwners).to receive(:current_repo_path).and_return(@d)
|
63
|
-
expect(CodeOwners).to receive(:log).with("Parse error line 4: \"invalid/
|
80
|
+
expect(CodeOwners).to receive(:log).with("Parse error line 4: \"invalid/code owners/line\"")
|
64
81
|
expect(CodeOwners).to receive(:log).with("Parse error line 5: \" @AnotherInvalidLine\"")
|
65
82
|
pattern_owners = CodeOwners.pattern_owners
|
66
83
|
expect(pattern_owners).not_to include(["", "@AnotherInvalidLine"])
|
@@ -86,6 +103,13 @@ CODEOWNERS
|
|
86
103
|
expect(raw_ownership.size).to be >= 1
|
87
104
|
expect(raw_ownership).to match(/^(?:.*:\d*:.*\t.*\n)+$/)
|
88
105
|
end
|
106
|
+
|
107
|
+
context "when path includes a space" do
|
108
|
+
it "returns the path in single line" do
|
109
|
+
raw_ownership = CodeOwners.raw_git_owner_info(["/spec/files/*"])
|
110
|
+
expect(raw_ownership).to match(/.+:\d+:.+\tspec\/files\/file name\.txt\n/)
|
111
|
+
end
|
112
|
+
end
|
89
113
|
end
|
90
114
|
|
91
115
|
describe "code_owners" do
|
@@ -0,0 +1 @@
|
|
1
|
+
This file's name includes a space.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_owners
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Cheatham
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/code_owners.rb
|
58
58
|
- lib/code_owners/version.rb
|
59
59
|
- spec/code_owners_spec.rb
|
60
|
+
- spec/files/file name.txt
|
60
61
|
- spec/files/☃.txt
|
61
62
|
homepage: https://github.com/jcheatham/code_owners
|
62
63
|
licenses:
|
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.6.14.4
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: ".github/CODEOWNERS introspection utility gem"
|