class GitLeadTime::FirstCommitFinder

Attributes

target_refs[R]

Public Class Methods

new(merge_target) click to toggle source
# File lib/git_lead_time/first_commit_finder.rb, line 6
def initialize(merge_target)
  @target_refs = Set.new(first_parents(merge_target))
end

Public Instance Methods

first_commit(ref) click to toggle source
# File lib/git_lead_time/first_commit_finder.rb, line 10
def first_commit(ref)
  first_commit = ref
  first_parents(ref) do |parent|
    break if target_refs.include? parent
    first_commit = parent
  end

  first_commit
end

Private Instance Methods

first_parents(ref) { |strip| ... } click to toggle source
# File lib/git_lead_time/first_commit_finder.rb, line 21
def first_parents(ref)
  return to_enum(__method__, ref) unless block_given?

  `git rev-list --first-parent #{ref}`.each_line do |line|
    yield line.strip
  end
end