9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/stencil/branches.rb', line 9
def read(path, type=:all)
key = "#{type}:#{path}"
if type == :all
(read(path, :remote) + read(path, :local)).uniq
elsif type == :remote && !@@branches[key]
branches = Cmd.run path, 'git branch -a'
@@branches[key] = branches.scan(/origin\/([\w-]+\b$)/).flatten.uniq
elsif type == :remote
@@branches[key]
elsif !@@branches[key]
branches = Cmd.run path, 'git branch'
branches = branches.split(/[\s\*]+/)
branches.delete ''
branches.sort!
@@branches[key] = branches
else
@@branches[key]
end
end
|