Skip to content
Snippets Groups Projects
Commit 26323046 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Decorate Gitlab::Git::Commit with Commit

parent 9dc64463
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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|
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
@@ -7,8 +7,8 @@ module Gitlab
attr_accessor :raw_commit, :head, :refs
 
delegate :message, :authored_date, :committed_date, :parents, :sha,
:date, :committer, :author, :diffs, :tree, :id, :stats,
:to_patch, to: :raw_commit
:date, :committer, :author, :diffs, :tree, :id, :stats, :to_patch,
to: :raw_commit
 
class << self
def find_or_first(repo, commit_id = nil, root_ref)
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ describe GitlabMarkdownHelper do
let!(:project) { create(:project) }
 
let(:user) { create(:user, username: 'gfm') }
let(:commit) { CommitDecorator.decorate(project.repository.commit) }
let(:commit) { CommitDecorator.decorate(Commit.new(project.repository.commit)) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, project: project) }
let(:snippet) { create(:snippet, project: project) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment