Commit a43eb8dd authored by Jose Ivan Vargas Lopez's avatar Jose Ivan Vargas Lopez

Merge branch 'gitaly-9-5-patch' into '9-5-stable-patch-1'

Ensure Rugged methods are called with a Rugged Commit

See merge request !13723
parents 77bfdacd a16dc5cd
......@@ -763,7 +763,7 @@ class Repository
index = Gitlab::Git::Index.new(raw_repository)
if start_commit
index.read_tree(start_commit.raw_commit.tree)
index.read_tree(start_commit.rugged_commit.tree)
parents = [start_commit.sha]
else
parents = []
......
......@@ -77,8 +77,8 @@ EOM
def initialize(merge_request, project)
@merge_request = merge_request
@our_commit = merge_request.source_branch_head.raw.raw_commit
@their_commit = merge_request.target_branch_head.raw.raw_commit
@our_commit = merge_request.source_branch_head.raw.rugged_commit
@their_commit = merge_request.target_branch_head.raw.rugged_commit
@project = project
end
end
......
......@@ -14,7 +14,7 @@ module Gitlab
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
delegate :tree, to: :raw_commit
delegate :tree, to: :rugged_commit
def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit)
......@@ -287,7 +287,7 @@ module Gitlab
# empty repo. See Repository#diff for keys allowed in the +options+
# hash.
def diff_from_parent(options = {})
Commit.diff_from_parent(raw_commit, options)
Commit.diff_from_parent(rugged_commit, options)
end
def deltas
......@@ -335,7 +335,7 @@ module Gitlab
def to_patch(options = {})
begin
raw_commit.to_mbox(options)
rugged_commit.to_mbox(options)
rescue Rugged::InvalidError => ex
if ex.message =~ /commit \w+ is a merge commit/i
'Patch format is not currently supported for merge commits.'
......@@ -383,6 +383,14 @@ module Gitlab
encode! @committer_email
end
def rugged_commit
@rugged_commit ||= if raw_commit.is_a?(Rugged::Commit)
raw_commit
else
@repository.rev_parse_target(id)
end
end
private
def init_from_hash(hash)
......
......@@ -6,7 +6,7 @@ require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_
describe MigrateProcessCommitWorkerJobs do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:commit) { project.commit.raw.raw_commit }
let(:commit) { project.commit.raw.rugged_commit }
describe 'Project' do
describe 'find_including_path' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment