Decorate Gitlab::Git::Commit with Commit
This commit is contained in:
parent
9dc644635f
commit
26323046fd
5 changed files with 13 additions and 3 deletions
|
@ -12,6 +12,7 @@ class CommitLoadContext < BaseContext
|
|||
commit = project.repository.commit(params[:id])
|
||||
|
||||
if commit
|
||||
commit = Commit.new(commit)
|
||||
commit = CommitDecorator.decorate(commit)
|
||||
line_notes = project.notes.for_commit_id(commit.id).inline
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class CommitsController < ProjectResourceController
|
|||
@limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
|
||||
|
||||
@commits = @repo.commits(@ref, @path, @limit, @offset)
|
||||
@commits = Commit.decorate(@commits)
|
||||
@commits = CommitDecorator.decorate_collection(@commits)
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -10,12 +10,20 @@ class Commit
|
|||
|
||||
attr_accessor :raw
|
||||
|
||||
def self.decorate(commits)
|
||||
commits.map { |c| Commit.new(c) }
|
||||
end
|
||||
|
||||
def initialize(raw_commit)
|
||||
raise "Nil as raw commit passed" unless raw_commit
|
||||
|
||||
@raw = raw_commit
|
||||
end
|
||||
|
||||
def id
|
||||
@raw.id
|
||||
end
|
||||
|
||||
def method_missing(m, *args, &block)
|
||||
@raw.send(m, *args, &block)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue