2013-02-26 05:28:11 +01:00
|
|
|
require "grit"
|
|
|
|
|
2013-03-07 07:42:30 +01:00
|
|
|
module Network
|
2013-02-26 05:28:11 +01:00
|
|
|
class Commit
|
|
|
|
include ActionView::Helpers::TagHelper
|
|
|
|
|
2013-03-07 09:56:01 +01:00
|
|
|
attr_reader :refs
|
|
|
|
attr_accessor :time, :spaces, :parent_spaces
|
2013-02-26 05:28:11 +01:00
|
|
|
|
2013-03-07 09:56:01 +01:00
|
|
|
def initialize(raw_commit, refs)
|
|
|
|
@commit = ::Commit.new(raw_commit)
|
2013-02-26 05:28:11 +01:00
|
|
|
@time = -1
|
2013-02-27 14:37:38 +01:00
|
|
|
@spaces = []
|
2013-02-26 05:28:11 +01:00
|
|
|
@parent_spaces = []
|
2013-03-07 09:56:01 +01:00
|
|
|
@refs = refs || []
|
2013-02-26 05:28:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(m, *args, &block)
|
2013-03-07 09:56:01 +01:00
|
|
|
@commit.send(m, *args, &block)
|
2013-02-26 05:28:11 +01:00
|
|
|
end
|
2013-02-27 14:37:38 +01:00
|
|
|
|
|
|
|
def space
|
|
|
|
if @spaces.size > 0
|
|
|
|
@spaces.first
|
|
|
|
else
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
2013-03-07 12:36:40 +01:00
|
|
|
|
|
|
|
def parents(map)
|
|
|
|
@commit.parents.map do |p|
|
|
|
|
if map.include?(p.id)
|
|
|
|
map[p.id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
.compact
|
|
|
|
end
|
2013-02-26 05:28:11 +01:00
|
|
|
end
|
|
|
|
end
|