diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-09-01 23:39:28 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-09-02 13:40:07 -0400 |
commit | 8db2a59d0b6959a78ea7be4663dd9a858dff9f98 (patch) | |
tree | f93ac13153e00c20cf66331827f7fa19b4fb1a00 /app/models/commit.rb | |
parent | 877aa5458627d42d03a7f204d02db9d326af006c (diff) | |
download | gitlab-ce-8db2a59d0b6959a78ea7be4663dd9a858dff9f98.tar.gz |
Add StaticModel role, and add it to Commit model
Instead of doing this:
link_to(commit.id, project_commit_path(project, id: commit.id))
Note.create(noteable_id: commit.id, noteable_type: "Commit", ...)
It lets us do this:
link_to(commit.id, project_commit_path(project, commit))
Note.create(noteable: commit, ...)
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 5c6b4d88d96..15afedcb101 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,6 +1,7 @@ class Commit include ActiveModel::Conversion include Gitlab::Encode + include StaticModel extend ActiveModel::Naming attr_accessor :commit @@ -22,8 +23,7 @@ class Commit :to_patch, to: :commit - - class << self + class << self def find_or_first(repo, commit_id = nil, root_ref) commit = if commit_id repo.commit(commit_id) @@ -85,7 +85,7 @@ class Commit first = project.commit(to.try(:strip)) last = project.commit(from.try(:strip)) - result = { + result = { commits: [], diffs: [], commit: nil @@ -105,10 +105,6 @@ class Commit end end - def persisted? - false - end - def initialize(raw_commit, head = nil) @commit = raw_commit @head = head @@ -155,7 +151,7 @@ class Commit prev_commit.try :id end - def parents_count + def parents_count parents && parents.count || 0 end end |