forked from rcoder/ohloh_scm
/
commit.rb
49 lines (43 loc) · 1.94 KB
/
commit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module OhlohScm
# A commit is a collection of diffs united by a single timestamp, author, and
# message.
#
# Ohloh's internal data model assumes that commits are immutable, and exist
# in a singly-linked list. That is, commits can be nicely numbered a la
# Subversion, and new commits are always added to the end of the list.
#
# This works for CVS and Subversion, but unfortunately, does not at all map
# to the DAG used by Git, which allows a commit to have multiple parents and
# children, and which allows new commits to appear during a pull which have
# timestamps older than previously known commits.
#
# This means that Ohloh's support for systems like Git is crude at best. For
# the near future, it is the job of the adapter to make the Git commit chain
# appear as much like a single array as possible.
#
class Commit
# This object supports the idea of distinct authors and committers, a la
# Git. However, Ohloh will retain only one of them in its database. It
# prefers author, but will fall back to committer if no author is given.
attr_accessor :author_name, :author_email, :author_date, :committer_name, :committer_email, :committer_date
attr_accessor :message
attr_accessor :diffs
# The token is used to uniquely identify a commit, and can be any type of
# adapter-specific data.
#
# For Subversion, the token is the revision number.
# For Git, the token is the commit SHA1 hash.
# For CVS, which does not support atomic commits with unique IDs, we use
# the approximate timestamp of the change.
attr_accessor :token
# A pointer back to the adapter that contains this commit.
attr_accessor :scm
# Hack. To optimize CVS updates, we will store the names of all the
# directories that require updating during this commit. Ohloh itself never
# actually sees this.
attr_accessor :directories
def initialize(params={})
params.each { |k,v| send(k.to_s + '=', v) if respond_to?(k.to_s + '=') }
end
end
end