class GitHelper

Attributes

git[R]
path[R]

Public Class Methods

new(path, git) click to toggle source
# File lib/git_chain/git_helper.rb, line 5
def initialize(path, git)
  @path = path
  @git = git
end

Public Instance Methods

clean?() click to toggle source
# File lib/git_chain/git_helper.rb, line 26
def clean?
  # status = git.status

  # status.added.empty? &&
  #   status.changed.empty? &&
  #   status.deleted.empty? &&
  #   status.untracked.empty?
  git_command("status -s").empty?
end
current_branch() click to toggle source
# File lib/git_chain/git_helper.rb, line 14
def current_branch
  git_command "rev-parse --abbrev-ref HEAD"
end
merge_base(branch_1, branch_2) click to toggle source
# File lib/git_chain/git_helper.rb, line 18
def merge_base(branch_1, branch_2)
  git_command "merge-base #{branch_1} #{branch_2}"
end
method_missing(method, *args) click to toggle source
# File lib/git_chain/git_helper.rb, line 10
def method_missing(method, *args)
  git.send(method, *args)
end
rebase_onto(new_base:, old_base:, branch:) click to toggle source
# File lib/git_chain/git_helper.rb, line 22
def rebase_onto(new_base:, old_base:, branch:)
  git_command "rebase --onto #{new_base} #{old_base} #{branch}"
end

Private Instance Methods

git_command(cmd) click to toggle source
# File lib/git_chain/git_helper.rb, line 40
def git_command(cmd)
  %x{cd #{path}; git #{cmd}}.strip
end