class Overcommit::HookContext::PreRebase
Contains helpers related to contextual information used by pre-rebase hooks.
Public Instance Methods
detached_head?()
click to toggle source
Returns whether we are rebasing a detached HEAD rather than a branch
# File lib/overcommit/hook_context/pre_rebase.rb, line 20 def detached_head? rebased_branch.empty? end
fast_forward?()
click to toggle source
Returns whether this rebase is a fast-forward
# File lib/overcommit/hook_context/pre_rebase.rb, line 25 def fast_forward? rebased_commits.empty? end
rebased_branch()
click to toggle source
Returns the name of the branch being rebased. Empty if rebasing a detached HEAD.
# File lib/overcommit/hook_context/pre_rebase.rb, line 14 def rebased_branch @rebased_branch ||= @args[1] || `git symbolic-ref --short --quiet HEAD`.chomp end
rebased_commits()
click to toggle source
Returns the SHA1-sums of the series of commits to be rebased in reverse topological order.
# File lib/overcommit/hook_context/pre_rebase.rb, line 31 def rebased_commits rebased_ref = detached_head? ? 'HEAD' : rebased_branch @rebased_commits ||= `git rev-list --topo-order --reverse #{upstream_branch}..#{rebased_ref}`. split("\n") end
upstream_branch()
click to toggle source
Returns the name of the branch we are rebasing onto.
# File lib/overcommit/hook_context/pre_rebase.rb, line 8 def upstream_branch @args[0] end