Class: Overcommit::HookContext::PreRebase
- Defined in:
- lib/overcommit/hook_context/pre_rebase.rb
Overview
Contains helpers related to contextual information used by pre-rebase hooks.
Instance Method Summary collapse
-
#detached_head? ⇒ Boolean
Returns whether we are rebasing a detached HEAD rather than a branch.
-
#fast_forward? ⇒ Boolean
Returns whether this rebase is a fast-forward.
-
#rebased_branch ⇒ Object
Returns the name of the branch being rebased.
-
#rebased_commits ⇒ Object
Returns the SHA1-sums of the series of commits to be rebased in reverse topological order.
-
#upstream_branch ⇒ Object
Returns the name of the branch we are rebasing onto.
Methods inherited from Base
#cleanup_environment, #execute_hook, #hook_class_name, #hook_script_name, #hook_type_name, #initialize, #input_lines, #input_string, #modified_files, #setup_environment
Constructor Details
This class inherits a constructor from Overcommit::HookContext::Base
Instance Method Details
#detached_head? ⇒ Boolean
Returns whether we are rebasing a detached HEAD rather than a branch
18 19 20 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 18 def detached_head? rebased_branch.empty? end |
#fast_forward? ⇒ Boolean
Returns whether this rebase is a fast-forward
23 24 25 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 23 def fast_forward? rebased_commits.empty? end |
#rebased_branch ⇒ Object
Returns the name of the branch being rebased. Empty if rebasing a detached HEAD.
12 13 14 15 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 12 def rebased_branch @rebased_branch ||= @args[1] || `git symbolic-ref --short --quiet HEAD`.chomp end |
#rebased_commits ⇒ Object
Returns the SHA1-sums of the series of commits to be rebased in reverse topological order.
29 30 31 32 33 34 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 29 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 ⇒ Object
Returns the name of the branch we are rebasing onto.
6 7 8 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 6 def upstream_branch @args[0] end |