class Crackin::Scm::Git

Attributes

git[R]

Public Class Methods

new(config={}) click to toggle source
Calls superclass method Crackin::Scm::Base::new
# File lib/crackin/scm/git.rb, line 8
def initialize(config={})
  super
  #@git = ::Git.open(@options[:working], log: Logger.new(STDOUT))
  o = {}
  o['log'] = Logger.new(STDOUT) if config['debug']
  @git = ::Git.open(@options[:working], o.deep_symbolize_keys)
end

Public Instance Methods

add(options={}) click to toggle source
# File lib/crackin/scm/git.rb, line 16
def add(options={})
  @git.add(options)
end
between(from, to) click to toggle source
# File lib/crackin/scm/git.rb, line 24
def between(from, to)
  @git.log.between(from, to)
end
change_branch(to) click to toggle source
# File lib/crackin/scm/git.rb, line 57
def change_branch(to)
  @git.checkout(to)
end
commit(message) click to toggle source
# File lib/crackin/scm/git.rb, line 32
def commit(message)
  @git.commit_all(message)
end
create_branch(name) click to toggle source
# File lib/crackin/scm/git.rb, line 61
def create_branch(name)
  branch = @git.branch(Shellwords.escape(name))
  branch.create
  branch.checkout
end
current_branch() click to toggle source
# File lib/crackin/scm/git.rb, line 53
def current_branch
  @git.branch_current
end
delete_branch(name) click to toggle source
# File lib/crackin/scm/git.rb, line 67
def delete_branch(name)
  @git.checkout
  @git.branch(Shellwords.escape(name)).delete
end
log() click to toggle source
# File lib/crackin/scm/git.rb, line 20
def log
  @git.log
end
merge_from(from) click to toggle source
# File lib/crackin/scm/git.rb, line 49
def merge_from(from)
  @git.branch(from).merge
end
pending() click to toggle source
# File lib/crackin/scm/git.rb, line 84
def pending
  s = @git.status
  d = {}
  d.merge! s.changed
  d.merge! s.added
  d.merge! s.deleted
  d.merge! s.untracked
  d
end
pending?() click to toggle source
# File lib/crackin/scm/git.rb, line 94
def pending?
  pending.count > 0
end
pull() click to toggle source
# File lib/crackin/scm/git.rb, line 72
def pull
  @git.pull
end
push(remote=@git.remote, branch=current_branch) click to toggle source
# File lib/crackin/scm/git.rb, line 76
def push(remote=@git.remote, branch=current_branch)
  @git.push(remote, branch)
end
push_tags(remote=@git.remote, branch=current_branch) click to toggle source
# File lib/crackin/scm/git.rb, line 80
def push_tags(remote=@git.remote, branch=current_branch)
  @git.push(remote, branch, true)
end
reset() click to toggle source
# File lib/crackin/scm/git.rb, line 40
def reset
  @git.checkout_file('--', '.')
  @git.clean(d: true, force: true)
  #pending.keys.each do |p|
  #  puts "pending: #{p}"
  #  @git.checkout_file('--', p)
  #end
end
tags() click to toggle source
# File lib/crackin/scm/git.rb, line 28
def tags
  Tags.new(@git)
end
uncommit() click to toggle source
# File lib/crackin/scm/git.rb, line 36
def uncommit
  @git.reset_hard('HEAD^')
end