Sha256: 21d8ba7673e5015f21ccc0fe02b62500599974cb43d9e897723912d873e36a8b

Contents?: true

Size: 969 Bytes

Versions: 31

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

module Overcommit::HookContext
  # Contains helpers related to contextual information used by post-checkout
  # hooks.
  class PostCheckout < Base
    # Returns the ref of the HEAD that we transitioned from.
    def previous_head
      @args[0]
    end

    # Returns the ref of the new current HEAD.
    def new_head
      @args[1]
    end

    # Returns whether this checkout was the result of changing/updating a
    # branch.
    def branch_checkout?
      @args[2].to_i == 1
    end

    # Returns whether this checkout was for a single file.
    def file_checkout?
      !branch_checkout?
    end

    # 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.
    def modified_files
      @modified_files ||=
        Overcommit::GitRepo.modified_files(refs: "#{previous_head} #{new_head}")
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
overcommit-0.67.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.66.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.65.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.64.1 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.64.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.63.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.62.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.61.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.60.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.59.1 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.59.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.58.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.57.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.56.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.55.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.54.1 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.54.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook_context/post_checkout.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook_context/post_checkout.rb