module HerokuSan::Git

Public Instance Methods

git_active_branch() click to toggle source
# File lib/heroku_san/git.rb, line 14
def git_active_branch
  %x{git branch}.split("\n").select { |b| b =~ /^\*/ }.first.split(" ").last.strip
end
git_clone(repos, dir) click to toggle source
# File lib/heroku_san/git.rb, line 10
def git_clone(repos, dir)
  sh "git clone #{repos} #{dir}"
end
git_named_rev(ref) click to toggle source
# File lib/heroku_san/git.rb, line 47
def git_named_rev(ref)
  %x{git name-rev #{ref}}.chomp
end
git_parsed_tag(tag) click to toggle source
# File lib/heroku_san/git.rb, line 29
def git_parsed_tag(tag)
  git_rev_parse(git_tag(tag))
end
git_push(commit, repo, options = []) click to toggle source
# File lib/heroku_san/git.rb, line 18
def git_push(commit, repo, options = [])
  commit ||= "HEAD"
  options ||= []
  begin
    sh "git update-ref refs/heroku_san/deploy #{commit}^{commit}"
    sh "git push #{repo} #{options.join(' ')} refs/heroku_san/deploy:refs/heads/master"
  ensure
    sh "git update-ref -d refs/heroku_san/deploy"
  end
end
git_rev_parse(ref) click to toggle source
# File lib/heroku_san/git.rb, line 33
def git_rev_parse(ref)
  return nil if ref.nil?
  %x{git rev-parse #{ref}}.split("\n").first
end
git_revision(repo) click to toggle source
# File lib/heroku_san/git.rb, line 43
def git_revision(repo)
  %x{git ls-remote --heads #{repo} master}.split.first
end
git_tag(glob) click to toggle source
# File lib/heroku_san/git.rb, line 38
def git_tag(glob)
  return nil if glob.nil?
  %x{git tag -l '#{glob}'}.split("\n").last || (raise NoTagFoundError, "No tag found [#{glob}]")
end