genki (owner)

Revisions

gist: 148510 Download_button fork
public
Public Clone URL: git://gist.github.com/148510.git
Embed All Files: show embed
git.rb #
1
2
3
4
5
6
7
8
9
10
11
12
def git(uri, sha1, options = {})
  require "tmpdir"
  basename = File.basename(uri)
  outdir = File.join(Dir.tmpdir, basename, sha1)
  unless File.exist?(outdir)
    sh = proc{|command| IO.popen("#{command} 2>&1"){|io| io.read}}
    sh["git clone #{uri} #{outdir}"]
    sh["cd #{outdir}; git checkout #{sha1}"]
  end
  $:.unshift File.join(outdir, 'lib')
  require options[:require_as] || basename.split(/\.git$/)[0]
end