Class: Overcommit::HookContext::PostCheckout

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook_context/post_checkout.rb

Overview

Contains helpers related to contextual information used by post-checkout hooks.

Instance Method Summary collapse

Methods inherited from Base

#all_files, #cleanup_environment, #execute_hook, #hook_class_name, #hook_script_name, #hook_type_name, #initialize, #input_lines, #input_string, #post_fail_message, #setup_environment

Constructor Details

This class inherits a constructor from Overcommit::HookContext::Base

Instance Method Details

#branch_checkout?Boolean

Returns whether this checkout was the result of changing/updating a branch.


17
18
19
# File 'lib/overcommit/hook_context/post_checkout.rb', line 17

def branch_checkout?
  @args[2].to_i == 1
end

#file_checkout?Boolean

Returns whether this checkout was for a single file.


22
23
24
# File 'lib/overcommit/hook_context/post_checkout.rb', line 22

def file_checkout?
  !branch_checkout?
end

#modified_filesObject

Get a list of files that have been added or modified between `previous_head` and `new_head`. Renames and deletions are ignored, since there should be nothing to check.


29
30
31
32
# File 'lib/overcommit/hook_context/post_checkout.rb', line 29

def modified_files
  @modified_files ||=
    Overcommit::GitRepo.modified_files(refs: "#{previous_head} #{new_head}")
end

#new_headObject

Returns the ref of the new current HEAD.


11
12
13
# File 'lib/overcommit/hook_context/post_checkout.rb', line 11

def new_head
  @args[1]
end

#previous_headObject

Returns the ref of the HEAD that we transitioned from.


6
7
8
# File 'lib/overcommit/hook_context/post_checkout.rb', line 6

def previous_head
  @args[0]
end