Class: Branch

Inherits:
Object
  • Object
show all
Includes:
BranchCommon
Defined in:
lib/git/stash/sclib/branch.rb

Overview

通常ブランチ

Instance Attribute Summary

Attributes included from BranchCommon

#name

Instance Method Summary collapse

Methods included from BranchCommon

#cherryPickNoCommit, #initialize

Instance Method Details

#checkoutObject



57
58
59
# File 'lib/git/stash/sclib/branch.rb', line 57

def checkout
  Cmd::execQuiet "git checkout \"#{@name}\""
end

#commit(mode = CommitMode::ALL, _msg = '', &onFail) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/git/stash/sclib/branch.rb', line 87

def commit(mode=CommitMode::ALL, _msg='', &onFail)
  msg = (_msg != '') ? "-m \"#{_msg}\"" : ''
  begin
    checkout
    puts "[#{@name}]: git commit #{mode} ..."
    Cmd::exec "git commit #{mode} #{msg}"
  rescue => e
    onFail.call if block_given?
    raise e
  end
end

#delete(deletedBranch = '', force = false) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/git/stash/sclib/branch.rb', line 60

def delete(deletedBranch='', force=false)
  if deletedBranch != ''
    Cmd::execQuiet "git checkout \"#{deletedBranch}\""
  end
  opt = (force == true) ? '-D' : '-d'
  revision = Cmd::revision @name
  Cmd::execQuiet "git branch #{opt} \"#{@name}\""
  puts "Deleted detached branch #{@name} (was #{revision})"
end

#rebase(upstream) ⇒ Object



69
70
71
72
# File 'lib/git/stash/sclib/branch.rb', line 69

def rebase(upstream)
  puts "[#{@name}]: git rebase \"#{upstream}\""
  Cmd::execForRebase @name, "git rebase \"#{upstream}\" \"#{@name}\""
end

#rebaseOnto(newbase, upstream) ⇒ Object



73
74
75
76
# File 'lib/git/stash/sclib/branch.rb', line 73

def rebaseOnto(newbase, upstream)
  puts "[#{@name}]: git rebase --onto \"#{newbase}\" \"#{upstream}\" <SELF>"
  Cmd::execForRebase @name, "git rebase --onto \"#{newbase}\" \"#{upstream}\" \"#{@name}\""
end

#reset(target = '') ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/git/stash/sclib/branch.rb', line 77

def reset(target='')
  if target != ''
    checkout
    puts "[#{@name}]: git reset \"#{target}\""
    Cmd::exec "git reset \"#{target}\""
  else
    puts "[#{@name}]: git reset"
    Cmd::exec 'git reset'
  end
end