Sha256: 1ff670132064282d19ac807193dcc445732d059704b7179108309a4bfe4a050a

Contents?: true

Size: 938 Bytes

Versions: 29

Compression:

Stored size: 938 Bytes

Contents

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

29 entries across 27 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_checkout.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_checkout.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_checkout.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_checkout.rb
overcommit-0.46.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.45.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.44.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.43.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.42.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.41.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.40.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.39.1 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.39.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.38.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.37.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.36.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.35.0 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.34.2 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.34.1 lib/overcommit/hook_context/post_checkout.rb
overcommit-0.34.0 lib/overcommit/hook_context/post_checkout.rb