Module: Zizu::Gitlib
- Defined in:
- lib/zizu/gitlib.rb
Class Method Summary collapse
Class Method Details
.clone(url, dest = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/zizu/gitlib.rb', line 49 def self.clone( url, dest=nil ) r = cmd("git clone #{url} #{dest}") if r[:status] Zizu::success(r[:stdout]) else Zizu::fatal(r[:stderr]) end return r[:status] end |
.cmd(str) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/zizu/gitlib.rb', line 5 def self.cmd(str) stdin, stdout, stderr = Open3.popen3(str) err = stderr.read.chomp return { :stdout => stdout.read.chomp, :stderr => err, :status => err.length > 0 ? false : true } end |
.config ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zizu/gitlib.rb', line 24 def self.config configs = Hash.new r = cmd("git config -l") if r[:status] # TODO windows and mac support params = r[:stdout].split("\n") params.each do |p| key, value = p.split("=") configs[key.strip] = value.strip end return configs else Zizu::fatal("command failed") return nil end end |
.version ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/zizu/gitlib.rb', line 16 def self.version r = cmd("git --version") tokens = r[:stdout].split(" ") return tokens[-1] end |