code_owners 1.0.6 → 1.0.7
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/bin/code_owners +20 -0
- data/lib/code_owners.rb +3 -1
- data/lib/code_owners/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd7998397d45dc60a1fb77fad414a119a9df181a61f5aa7b135ee674ebce9008
|
4
|
+
data.tar.gz: 3c3e4a62f8fb6a7650c90c7ac1975faf93edb91503092fa4f9a3092687e34587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c635ae7dbc19ee970e7d8701545839437c20b8121af692d43c1b835693d53163f70fe5291984d28cbe4e41aecb9ce59dd43d75d33f3994b0e810e05dc87d26c9
|
7
|
+
data.tar.gz: fa2c93f8181119b3dc6a5d08ebaba882c9875c92835917de40a6e6650ec6e108aaedfb028d1843d695da537eaaf2a7f877828c3d0383003730ec512ca140a020
|
data/Gemfile.lock
CHANGED
data/bin/code_owners
CHANGED
@@ -2,9 +2,29 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
4
|
require 'code_owners'
|
5
|
+
require 'optparse'
|
5
6
|
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "usage: code_owners [options]"
|
10
|
+
opts.on('-u', '--unowned', TrueClass, 'Display unowned files only') do |u|
|
11
|
+
options[:unowned] = u
|
12
|
+
end
|
13
|
+
opts.on('-e', '--error-unowned', TrueClass, 'Exit with error status if any files are unowned') do |e|
|
14
|
+
options[:error_unowned] = e
|
15
|
+
end
|
16
|
+
end.parse!
|
17
|
+
|
18
|
+
unowned_error = false
|
6
19
|
CodeOwners.ownerships.each do |ownership_status|
|
7
20
|
owner_info = ownership_status[:owner].dup
|
21
|
+
if owner_info != CodeOwners::NO_OWNER
|
22
|
+
next if options[:unowned]
|
23
|
+
else
|
24
|
+
unowned_error ||= options[:error_unowned]
|
25
|
+
end
|
8
26
|
owner_info += " per line #{ownership_status[:line]}, #{ownership_status[:pattern]}" if owner_info != "UNOWNED"
|
9
27
|
puts "#{ownership_status[:file].ljust(100,' ')} #{owner_info}"
|
10
28
|
end
|
29
|
+
|
30
|
+
exit(unowned_error && 1 || 0)
|
data/lib/code_owners.rb
CHANGED
@@ -2,7 +2,9 @@ require "code_owners/version"
|
|
2
2
|
require "tempfile"
|
3
3
|
|
4
4
|
module CodeOwners
|
5
|
+
NO_OWNER = 'UNOWNED'
|
5
6
|
class << self
|
7
|
+
|
6
8
|
# github's CODEOWNERS rules (https://help.github.com/articles/about-codeowners/) are allegedly based on the gitignore format.
|
7
9
|
# but you can't tell ls-files to ignore tracked files via an arbitrary pattern file
|
8
10
|
# so we need to jump through some hacky git-fu hoops
|
@@ -21,7 +23,7 @@ module CodeOwners
|
|
21
23
|
patterns = pattern_owners
|
22
24
|
git_owner_info(patterns.map { |p| p[0] }).map do |line, pattern, file|
|
23
25
|
if line.empty?
|
24
|
-
{ file: file, owner:
|
26
|
+
{ file: file, owner: NO_OWNER, line: nil, pattern: nil }
|
25
27
|
else
|
26
28
|
{
|
27
29
|
file: file,
|
data/lib/code_owners/version.rb
CHANGED