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
#all_files, #cleanup_environment, #execute_hook, #hook_class_name, #hook_script_name, #hook_type_name, #initialize, #input_lines, #input_string, #modified_files, #post_fail_message, #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
20 21 22 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 20 def detached_head? rebased_branch.empty? end |
#fast_forward? ⇒ Boolean
Returns whether this rebase is a fast-forward
25 26 27 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 25 def fast_forward? rebased_commits.empty? end |
#rebased_branch ⇒ Object
Returns the name of the branch being rebased. Empty if rebasing a detached HEAD.
14 15 16 17 |
# 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 ⇒ Object
Returns the SHA1-sums of the series of commits to be rebased in reverse topological order.
31 32 33 34 35 36 |
# 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 ⇒ Object
Returns the name of the branch we are rebasing onto.
8 9 10 |
# File 'lib/overcommit/hook_context/pre_rebase.rb', line 8 def upstream_branch @args[0] end |