module Bard::Git

Public Instance Methods

current_branch() click to toggle source
# File lib/bard/git.rb, line 5
def current_branch
  ref = `git symbolic-ref HEAD 2>&1`.chomp
  return false if ref =~ /^fatal:/
  ref.sub(/refs\/heads\//, '') # refs/heads/master ... we want "master"
end
fast_forward_merge?(root, branch) click to toggle source
# File lib/bard/git.rb, line 11
def fast_forward_merge?(root, branch)
  root_head = sha_of(root)
  branch_head = sha_of(branch)
  common_ancestor = `git merge-base #{root_head} #{branch_head}`.chomp
  common_ancestor == root_head
end
sha_of(ref) click to toggle source
# File lib/bard/git.rb, line 22
def sha_of ref
  `git rev-parse #{ref}`.chomp
end
up_to_date_with_remote?(branch) click to toggle source
# File lib/bard/git.rb, line 18
def up_to_date_with_remote? branch
  sha_of(branch) == sha_of("origin/#{branch}")
end