module Heroploy::Commands::Git

Public Instance Methods

current_branch() click to toggle source
# File lib/heroploy/commands/git.rb, line 10
def current_branch
  branch = Shell.eval "git rev-parse --abbrev-ref HEAD"
  branch.strip
end
git_clone(repository, destination) { || ... } click to toggle source
# File lib/heroploy/commands/git.rb, line 47
def git_clone(repository, destination)
  Dir.mktmpdir do |dir|
    Dir.chdir(dir) do
      Shell.exec("git clone #{repository} #{destination}")
      if block_given?
        yield
      end
    end
  end
end
git_fetch() click to toggle source
# File lib/heroploy/commands/git.rb, line 6
def git_fetch
  Shell.exec "git fetch"
end
git_push_tag(tag) click to toggle source
# File lib/heroploy/commands/git.rb, line 43
def git_push_tag(tag)
  Shell.exec("git push origin #{tag}")
end
git_push_to_master(remote, local_branch) click to toggle source
# File lib/heroploy/commands/git.rb, line 15
def git_push_to_master(remote, local_branch)
  if ENV['force'] == 'true' then opts = "--force " end
  Shell.exec "git push #{opts}#{remote} #{local_branch}:master"
end
git_remote_behind?(remote, remote_branch_name, local_branch_name = nil) click to toggle source
# File lib/heroploy/commands/git.rb, line 30
def git_remote_behind?(remote, remote_branch_name, local_branch_name = nil)
  if local_branch_name.nil? then local_branch_name = remote_branch_name end
  !Shell.eval("git log #{remote}/#{remote_branch_name}..#{local_branch_name}").empty?
end
git_remote_exists?(name) click to toggle source
# File lib/heroploy/commands/git.rb, line 20
def git_remote_exists?(name)
  remotes = Shell.eval("git remote").strip.split(/\s+/)
  remotes.include?(name)
end
git_remote_has_branch?(remote, branch_name) click to toggle source
# File lib/heroploy/commands/git.rb, line 25
def git_remote_has_branch?(remote, branch_name)
  branches = Shell.eval("git branch -r").strip.split(/\s+/)
  branches.include?("#{remote}/#{branch_name}")
end
git_staged?(remote, local_branch) click to toggle source
# File lib/heroploy/commands/git.rb, line 35
def git_staged?(remote, local_branch)
  !git_remote_behind?(remote, 'master', local_branch)
end
git_tag(tag, message) click to toggle source
# File lib/heroploy/commands/git.rb, line 39
def git_tag(tag, message)
  Shell.exec("git tag -a #{tag} -m \"#{message}\"")
end