class SourceTree

Public Instance Methods

merge_collapse(commits) click to toggle source
# File lib/source_tree.rb, line 3
def merge_collapse(commits)
  indexed_commits = commits.reduce({}, &method(:index_commits))

  graph = []
  head = commits.first
  while head
    graph << head
    commit_id = head.children.first
    head = indexed_commits[commit_id]
  end

  graph
end

Private Instance Methods

index_commits(acc, commit) click to toggle source
# File lib/source_tree.rb, line 19
def index_commits(acc, commit)
  acc[commit.id] = commit
  acc
end