Sha256: acb85c3a619089d5c9b66fcd19accec8ce40c7bded2201bced1ed5314f931b04

Contents?: true

Size: 1.02 KB

Versions: 32

Compression:

Stored size: 1.02 KB

Contents

module Overcommit::HookContext
  # Contains helpers related to contextual information used by pre-rebase
  # hooks.
  class PreRebase < Base
    # Returns the name of the branch we are rebasing onto.
    def upstream_branch
      @args[0]
    end

    # Returns the name of the branch being rebased. Empty if rebasing a
    # detached HEAD.
    def rebased_branch
      @rebased_branch ||=
        @args[1] || `git symbolic-ref --short --quiet HEAD`.chomp
    end

    # Returns whether we are rebasing a detached HEAD rather than a branch
    def detached_head?
      rebased_branch.empty?
    end

    # Returns whether this rebase is a fast-forward
    def fast_forward?
      rebased_commits.empty?
    end

    # Returns the SHA1-sums of the series of commits to be rebased
    # in reverse topological order.
    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
  end
end

Version data entries

32 entries across 30 versions & 2 rubygems

Version Path
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/pre_rebase.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/pre_rebase.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/pre_rebase.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/pre_rebase.rb
overcommit-0.46.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.45.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.44.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.43.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.42.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.41.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.40.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.39.1 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.39.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.38.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.37.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.36.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.35.0 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.34.2 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.34.1 lib/overcommit/hook_context/pre_rebase.rb
overcommit-0.34.0 lib/overcommit/hook_context/pre_rebase.rb