9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/repo_dependency_graph.rb', line 9
def dependencies(options)
if options[:map] && options[:external]
raise ArgumentError, "Map only makes sense when searching for internal repos"
end
all = OrganizationAudit::Repo.all(options).sort_by(&:name)
all.select!(&:private?) if options[:private]
all.select! { |r| r.name =~ options[:select] } if options[:select]
all.reject! { |r| r.name =~ options[:reject] } if options[:reject]
possible = all.map(&:name)
possible.map! { |p| p.sub(options[:map][0], options[:map][1].to_s) } if options[:map]
dependencies = all.map do |repo|
found = dependent_repos(repo, options)
found.select! { |f| possible.include?(f.first) } unless options[:external]
next if found.empty?
puts "#{repo.name}: #{found.map { |n,v| "#{n}: #{v}" }.join(", ")}"
[repo.name, found]
end.compact
Hash[dependencies]
end
|