Sha256: af840b8754f797f0735b662fd34f32a633e980cfc99c4bacec7251f3dc81e37c

Contents?: true

Size: 639 Bytes

Versions: 20

Compression:

Stored size: 639 Bytes

Contents

module Bard
  module 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 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
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bard-1.3.9 lib/bard/git.rb
bard-1.3.8 lib/bard/git.rb
bard-1.3.7 lib/bard/git.rb
bard-1.3.6 lib/bard/git.rb
bard-1.3.5 lib/bard/git.rb
bard-1.3.4 lib/bard/git.rb
bard-1.3.3 lib/bard/git.rb
bard-1.3.2 lib/bard/git.rb
bard-1.3.1 lib/bard/git.rb
bard-1.3.0 lib/bard/git.rb
bard-1.2.0 lib/bard/git.rb
bard-1.1.2 lib/bard/git.rb
bard-1.1.1 lib/bard/git.rb
bard-1.1.0 lib/bard/git.rb
bard-1.0.8 lib/bard/git.rb
bard-1.0.7 lib/bard/git.rb
bard-1.0.6 lib/bard/git.rb
bard-1.0.5 lib/bard/git.rb
bard-1.0.4 lib/bard/git.rb
bard-1.0.3 lib/bard/git.rb