2011-11-20 21:32:12 +01:00
|
|
|
class Commit
|
2012-01-28 15:47:55 +01:00
|
|
|
include ActiveModel::Conversion
|
|
|
|
extend ActiveModel::Naming
|
2011-11-28 10:46:41 +01:00
|
|
|
|
2011-11-27 16:35:49 +01:00
|
|
|
attr_accessor :commit
|
|
|
|
attr_accessor :head
|
2012-01-04 07:17:41 +01:00
|
|
|
attr_accessor :refs
|
2011-11-27 16:35:49 +01:00
|
|
|
|
|
|
|
delegate :message,
|
2012-01-12 00:12:49 +01:00
|
|
|
:authored_date,
|
2011-11-27 16:35:49 +01:00
|
|
|
:committed_date,
|
|
|
|
:parents,
|
|
|
|
:sha,
|
|
|
|
:date,
|
2012-01-12 00:12:49 +01:00
|
|
|
:committer,
|
2011-11-27 16:35:49 +01:00
|
|
|
:author,
|
|
|
|
:message,
|
|
|
|
:diffs,
|
|
|
|
:tree,
|
|
|
|
:id,
|
|
|
|
:to => :commit
|
|
|
|
|
2012-01-28 15:47:55 +01:00
|
|
|
def persisted?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2011-11-27 16:35:49 +01:00
|
|
|
def initialize(raw_commit, head = nil)
|
|
|
|
@commit = raw_commit
|
|
|
|
@head = head
|
|
|
|
end
|
|
|
|
|
|
|
|
def safe_message
|
2011-12-30 14:41:39 +01:00
|
|
|
message
|
2011-11-27 16:35:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def created_at
|
|
|
|
committed_date
|
|
|
|
end
|
|
|
|
|
|
|
|
def author_email
|
2011-12-30 14:41:39 +01:00
|
|
|
author.email
|
2011-11-27 16:35:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def author_name
|
2012-02-18 13:12:48 +01:00
|
|
|
author.name.force_encoding("UTF-8")
|
2011-11-27 16:35:49 +01:00
|
|
|
end
|
2011-11-29 19:06:37 +01:00
|
|
|
|
2012-01-12 00:12:49 +01:00
|
|
|
def committer_name
|
|
|
|
committer.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def committer_email
|
|
|
|
committer.email
|
|
|
|
end
|
|
|
|
|
2011-11-29 19:06:37 +01:00
|
|
|
def prev_commit
|
|
|
|
parents.first
|
|
|
|
end
|
2012-02-29 22:34:06 +01:00
|
|
|
|
|
|
|
def prev_commit_id
|
|
|
|
prev_commit.id
|
|
|
|
end
|
2011-11-20 21:32:12 +01:00
|
|
|
end
|