Sha256: f41a0cbf9e6fe38d2f6c17e59275862ab53e7d7a52ea89a7f427079ae9b7d38d

Contents?: true

Size: 689 Bytes

Versions: 5

Compression:

Stored size: 689 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 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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bard-1.0.1 lib/bard/git.rb
bard-1.0.0 lib/bard/git.rb
bard-0.69.2 lib/bard/git.rb
bard-0.69.1 lib/bard/git.rb
bard-0.69.0 lib/bard/git.rb