Class: SourceTree

Inherits:
Object
  • Object
show all
Defined in:
lib/source_tree.rb

Instance Method Summary collapse

Instance Method Details

#merge_collapse(commits) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# 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