Module: Owners
- Defined in:
- lib/owners.rb,
lib/owners/cli.rb,
lib/owners/tree.rb,
lib/owners/owner.rb,
lib/owners/config.rb,
lib/owners/search.rb,
lib/owners/version.rb,
lib/owners/subscription.rb
Defined Under Namespace
Classes: CLI, Config, Owner, Search, Subscription, Tree
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.file ⇒ Object
The name of the file used to store ownership subscriptions.
Class Method Summary collapse
-
.for(*files) ⇒ Object
Accepts a list of file paths and returns an array of owners that have subscribed to the specified files.
-
.for_diff(ref, base = "master") ⇒ Object
Accepts a git ref and an optional base ref and returns an array of owners that have subscribed to the changes.
-
.missing_for(*files) ⇒ Object
Accepts a list of file paths and returns an array of the ones that do not have subscribed owners.
Class Attribute Details
.file ⇒ Object
The name of the file used to store ownership subscriptions. Defaults to OWNERS.
23 24 25 |
# File 'lib/owners.rb', line 23 def file @file ||= "OWNERS" end |
Class Method Details
.for(*files) ⇒ Object
Accepts a list of file paths and returns an array of owners that have subscribed to the specified files.
31 32 33 |
# File 'lib/owners.rb', line 31 def for(*files) Search.new(files).owners end |
.for_diff(ref, base = "master") ⇒ Object
Accepts a git ref and an optional base ref and returns an array of owners that have subscribed to the changes.
The base ref defaults to “master”.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/owners.rb', line 41 def for_diff(ref, base = "master") files = `git diff --name-only #{base}...#{ref}`.split("\n") # TODO: why doesn't this work? It works in the command line... # blobs = `git ls-tree -r #{ref} | **/#{file}`.split("\n") blobs = `git ls-tree -r #{ref} | egrep "(^|/)#{file}$"`.split("\n") configs = blobs.reduce({}) do |hash, line| _, _, sha, file = line.split(/\s+/, 4) contents = `git show #{sha}` hash.update(file => contents) end Search.new(files, configs).owners end |