Sha256: d38a717466b624fcc9c076dffc560541cdf747a71aea2731abad69b9904ba174

Contents?: true

Size: 638 Bytes

Versions: 19

Compression:

Stored size: 638 Bytes

Contents

module Bard::CLI::Git
  module_function

  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

  def current_sha
    sha_of("HEAD")
  end

  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

  def up_to_date_with_remote? branch
    sha_of(branch) == sha_of("origin/#{branch}")
  end

  def sha_of ref
    `git rev-parse #{ref}`.chomp
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bard-0.68.0 lib/bard/git.rb
bard-0.67.0 lib/bard/git.rb
bard-0.66.0 lib/bard/git.rb
bard-0.65.0 lib/bard/git.rb
bard-0.64.1 lib/bard/git.rb
bard-0.64.0 lib/bard/git.rb
bard-0.63.0 lib/bard/git.rb
bard-0.62.2 lib/bard/git.rb
bard-0.62.1 lib/bard/git.rb
bard-0.62.0 lib/bard/git.rb
bard-0.61.0 lib/bard/git.rb
bard-0.60.0 lib/bard/git.rb
bard-0.59.3 lib/bard/git.rb
bard-0.59.2 lib/bard/git.rb
bard-0.59.1 lib/bard/git.rb
bard-0.59.0 lib/bard/git.rb
bard-0.58.0 lib/bard/git.rb
bard-0.57.0 lib/bard/git.rb
bard-0.56.0 lib/bard/git.rb