Class: ASF::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/whimsy/asf/git.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



29
30
31
# File 'lib/whimsy/asf/git.rb', line 29

def self.[](name)
  self.find!(name)
end

.[]=(name, path) ⇒ Object



25
26
27
# File 'lib/whimsy/asf/git.rb', line 25

def self.[]=(name, path)
  @testdata[name] = File.expand_path(path).untaint
end

.find(name) ⇒ Object



33
34
35
# File 'lib/whimsy/asf/git.rb', line 33

def self.find(name)
  repos[name]
end

.find!(name) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/whimsy/asf/git.rb', line 37

def self.find!(name)
  result = self.find(name)

  if not result
    raise Exception.new("Unable to find git clone for #{name}")
  end

  result
end

.reposObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/whimsy/asf/git.rb', line 9

def self.repos
  @semaphore.synchronize do
    git = Array(ASF::Config.get(:git)).map {|dir| dir.untaint}
    @repos ||= Hash[Dir[*git].map { |name| 
      next unless Dir.exist? name.untaint
      Dir.chdir name.untaint do
        out, err, status = 
          Open3.capture3(*%(git config --get remote.origin.url))
        if status.success?
          [File.basename(out.chomp, '.git'), Dir.pwd.untaint]
        end
      end
    }.compact]
  end
end