Class: DetachBranch

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

Overview

detachedブランチ

Instance Attribute Summary

Attributes included from BranchCommon

#name

Instance Method Summary collapse

Methods included from BranchCommon

#cherryPickNoCommit, #initialize

Instance Method Details

#checkoutObject



113
114
115
# File 'lib/git/stash/sclib/branch.rb', line 113

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

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



143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/git/stash/sclib/branch.rb', line 143

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

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



116
117
118
119
120
121
122
123
# File 'lib/git/stash/sclib/branch.rb', line 116

def delete(deletedBranch='', dummy=false)
  if deletedBranch != ''
    Cmd::execQuiet "git checkout \"#{deletedBranch}\""
  end
  revision = Cmd::revision @name
  Cmd::execQuiet "git update-ref -d refs/#{@name}"
  puts "Deleted detached branch #{@name} (was #{revision})"
end

#rebase(upstream) ⇒ Object



124
125
126
127
# File 'lib/git/stash/sclib/branch.rb', line 124

def rebase(upstream)
  puts "[#{@name}]: git rebase \"#{upstream}\""
  Cmd::execForRebase @name, "git rebase \"#{upstream}\" \"#{@name}\" --exec \"git update-ref refs/#{@name} HEAD\""
end

#rebaseOnto(newbase, upstream) ⇒ Object



128
129
130
131
# File 'lib/git/stash/sclib/branch.rb', line 128

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

#reset(target = '') ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/git/stash/sclib/branch.rb', line 132

def reset(target='')
  if target != ''
    checkout
    puts "[#{@name}]: git reset \"#{target}\""
    Cmd::exec "git reset \"#{target}\""
    Cmd::execQuiet "git update-ref refs/#{@name} HEAD"
  else
    puts "[#{@name}]: git reset"
    Cmd::exec 'git reset'
  end
end