class Gub::Git
Attributes
default_options[RW]
Public Instance Methods
clone(repo, *args)
click to toggle source
Due to clone being a Ruby magic method, we have to override it
# File lib/gub/clients/git.rb, line 19 def clone repo, *args self.run('clone', repo, *args) end
method_missing(meth, *args, &block)
click to toggle source
# File lib/gub/clients/git.rb, line 23 def method_missing meth, *args, &block self.run(meth, *args) end
remotes()
click to toggle source
# File lib/gub/clients/git.rb, line 14 def remotes `git remote -v | grep fetch | awk '{print $2}' | cut -d ':' -f 2`.split("\n").split(' ').map(&:chop) end
run(command, *args)
click to toggle source
# File lib/gub/clients/git.rb, line 28 def run command, *args command = command.to_s default_options = [] default_options << '-q' cmd = [] cmd << 'git' cmd << command if args.any? arguments = args unless ['clone', 'remote', 'checkout'].include?(command) arguments = arguments.zip(default_options).flatten! end cmd << arguments.join(' ').to_s end cmd_line = cmd.join(' ') Gub.log.debug "Running git command: #{cmd_line}" out = `#{cmd_line}`.split("\n").map(&:strip) out end
sync(remote)
click to toggle source
# File lib/gub/clients/git.rb, line 7 def sync remote self.checkout('master') self.fetch(remote) self.merge("#{remote}/master") self.push('origin', '--all') end