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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b742a1fbaa41ae70ad7acc4f258ce685517c74d91855fe554ce29fbb02ca9d99
4
- data.tar.gz: 9535aa63120da63e000b8fee5500d696e9d0ee097a12a9bfb052aab5f6b2fb00
3
+ metadata.gz: cd7998397d45dc60a1fb77fad414a119a9df181a61f5aa7b135ee674ebce9008
4
+ data.tar.gz: 3c3e4a62f8fb6a7650c90c7ac1975faf93edb91503092fa4f9a3092687e34587
5
5
  SHA512:
6
- metadata.gz: f2bed6c4f9a8991d6319b31b9d41e6fddc63bdb9cb584a6629106f90514944384f9d67a18134a0afd3c68ff13fb46c8c994af08ad8a1cfebec040d360343ca4f
7
- data.tar.gz: bad817126846774d0e62706229351b2abd189bfeb570d16d994d2e01cdc7998bee78dab90979f41fcb3546824f744714a644c28fcc09fe0e8bfb78a2ba29d2b0
6
+ metadata.gz: c635ae7dbc19ee970e7d8701545839437c20b8121af692d43c1b835693d53163f70fe5291984d28cbe4e41aecb9ce59dd43d75d33f3994b0e810e05dc87d26c9
7
+ data.tar.gz: fa2c93f8181119b3dc6a5d08ebaba882c9875c92835917de40a6e6650ec6e108aaedfb028d1843d695da537eaaf2a7f877828c3d0383003730ec512ca140a020
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code_owners (1.0.6)
4
+ code_owners (1.0.7)
5
5
  rake
6
6
 
7
7
  GEM
@@ -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)
@@ -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: "UNOWNED", line: nil, pattern: nil }
26
+ { file: file, owner: NO_OWNER, line: nil, pattern: nil }
25
27
  else
26
28
  {
27
29
  file: file,
@@ -1,3 +1,3 @@
1
1
  module CodeOwners
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  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.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Cheatham