code_owners 1.0.2 → 1.0.3
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/lib/code_owners.rb +20 -5
- data/lib/code_owners/version.rb +1 -1
- data/spec/code_owners_spec.rb +18 -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: bddfbbd4ec9f5016192c995b8660325dae24b9aa
|
4
|
+
data.tar.gz: f04bbd2618f16253fba02cd8a40c8ba1483d7a66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df7b7005d293e25b5ae35d32d450c69a2c2cafd51294dc7292eb0814a67f5126673b7511860d824d9db724145f33e6c15172cc052068d7fd79f76515df666e23
|
7
|
+
data.tar.gz: b51c33cb99006e79035e30dec7cfd5546bbd8188e48fd9dea8d47dc97b8cb58724348ce444d6bdffc1723be4d9d352ddbbce70c95e4d1c8f425d0e623617fc91
|
data/Gemfile.lock
CHANGED
data/lib/code_owners.rb
CHANGED
@@ -16,8 +16,7 @@ module CodeOwners
|
|
16
16
|
def ownerships
|
17
17
|
patterns, owners = pattern_owners.transpose
|
18
18
|
|
19
|
-
|
20
|
-
_, _exfile, line, pattern, file = status.match(/^(.*):(\d*):(.*)\t(.*)$/).to_a
|
19
|
+
git_owner_info(patterns).map do |line, pattern, file|
|
21
20
|
if line.empty?
|
22
21
|
{ file: file, owner: "UNOWNED" }
|
23
22
|
else
|
@@ -35,15 +34,31 @@ module CodeOwners
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
37
|
+
def git_owner_info(patterns)
|
38
|
+
make_utf8(raw_git_owner_info(patterns)).lines.map do |info|
|
39
|
+
_, _exfile, line, pattern, file = info.strip.match(/^(.*):(\d*):(.*)\t(.*)$/).to_a
|
40
|
+
[line, pattern, file]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
38
44
|
# expects an array of gitignore compliant patterns
|
39
45
|
# generates a check-ignore formatted string for each file in the repo
|
40
|
-
def
|
46
|
+
def raw_git_owner_info(patterns)
|
41
47
|
Tempfile.open('codeowner_patterns') do |file|
|
42
48
|
file.write(patterns.join("\n"))
|
43
49
|
file.rewind
|
44
|
-
|
45
|
-
`#{cmd}`.lines.map(&:strip)
|
50
|
+
`git ls-files | xargs -- git -c \"core.excludesfile=#{file.path}\" check-ignore --no-index -v -n`
|
46
51
|
end
|
47
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def make_utf8(input)
|
57
|
+
input.force_encoding(Encoding::UTF_8)
|
58
|
+
return input if input.valid_encoding?
|
59
|
+
input.encode!(Encoding::UTF_16, invalid: :replace, replace: '�')
|
60
|
+
input.encode!(Encoding::UTF_8, Encoding::UTF_16)
|
61
|
+
input
|
62
|
+
end
|
48
63
|
end
|
49
64
|
end
|
data/lib/code_owners/version.rb
CHANGED
data/spec/code_owners_spec.rb
CHANGED
@@ -4,10 +4,10 @@ RSpec.describe CodeOwners do
|
|
4
4
|
describe ".ownerships" do
|
5
5
|
it "assigns owners to things" do
|
6
6
|
expect(CodeOwners).to receive(:pattern_owners).and_return([["pat1", "own1"], ["pat2", "own2"], ["pat3", "own3"]])
|
7
|
-
expect(CodeOwners).to receive(:
|
7
|
+
expect(CodeOwners).to receive(:git_owner_info).and_return(
|
8
8
|
[
|
9
|
-
"
|
10
|
-
"
|
9
|
+
["2", "whatever/pattern/thing", "this/is/a/file"],
|
10
|
+
["", "", "unowned/file"]
|
11
11
|
]
|
12
12
|
)
|
13
13
|
expect(CodeOwners.ownerships).to eq(
|
@@ -35,11 +35,23 @@ RSpec.describe CodeOwners do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe ".
|
38
|
+
describe ".git_owner_info" do
|
39
|
+
it "returns a massaged list of git ownership info" do
|
40
|
+
expect(CodeOwners).to receive(:raw_git_owner_info).and_return("this_gets_discarded:2:whatever/pattern/thing\tthis/is/a/file\n::\tBad\xEF\xEF\xEF\xEF chars\xC3\xA5\xE2\x88\x86\xC6\x92.txt" )
|
41
|
+
expect(CodeOwners.git_owner_info(["/lib/*"])).to eq(
|
42
|
+
[
|
43
|
+
["2", "whatever/pattern/thing", "this/is/a/file"],
|
44
|
+
["", "", "Bad���� charså∆ƒ.txt"]
|
45
|
+
]
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".raw_git_owner_info" do
|
39
51
|
it "establishes code owners from a list of patterns" do
|
40
|
-
raw_ownership = CodeOwners.
|
52
|
+
raw_ownership = CodeOwners.raw_git_owner_info(["/lib/*"])
|
41
53
|
expect(raw_ownership.size).to be >= 1
|
42
|
-
expect(raw_ownership).to
|
54
|
+
expect(raw_ownership).to match(/^(?:.*:\d*:.*\t.*\n)+$/)
|
43
55
|
end
|
44
56
|
end
|
45
57
|
end
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Cheatham
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.5.1
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: ".github/CODEOWNERS introspection utility gem"
|