Commit 2db75f8d authored by Douwe Maan's avatar Douwe Maan
Browse files

Make methods private that don't need to be public

parent 228d2a4c
......@@ -65,42 +65,36 @@ def first_commit
def base_commit
return unless self.base_commit_sha
merge_request.target_project.commit(self.base_commit_sha)
project.commit(self.base_commit_sha)
end
def start_commit
return unless self.start_commit_sha
merge_request.target_project.commit(self.start_commit_sha)
project.commit(self.start_commit_sha)
end
def head_commit
return last_commit unless self.head_commit_sha
merge_request.target_project.commit(self.head_commit_sha)
project.commit(self.head_commit_sha)
end
def dump_commits(commits)
commits.map(&:to_hash)
end
def load_commits(array)
array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash), merge_request.source_project) }
end
def compare
@compare ||=
begin
# Update ref for merge request
merge_request.fetch_ref
def dump_diffs(diffs)
if diffs.respond_to?(:map)
diffs.map(&:to_hash)
end
Gitlab::Git::Compare.new(
self.repository.raw_repository,
self.target_branch_sha,
self.source_branch_sha
)
end
end
def load_diffs(raw, options)
if raw.respond_to?(:each)
Gitlab::Git::DiffCollection.new(raw, options)
else
Gitlab::Git::DiffCollection.new([])
end
end
private
# Collect array of Git::Commit objects
# between target and source branches
......@@ -114,6 +108,14 @@ def unmerged_commits
commits
end
def dump_commits(commits)
commits.map(&:to_hash)
end
def load_commits(array)
array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash), merge_request.source_project) }
end
# Reload all commits related to current merge request from repo
# and save it as array of hashes in st_commits db field
def reload_commits
......@@ -128,6 +130,26 @@ def reload_commits
update_columns_serialized(new_attributes)
end
# Collect array of Git::Diff objects
# between target and source branches
def unmerged_diffs
compare.diffs(Commit.max_diff_options)
end
def dump_diffs(diffs)
if diffs.respond_to?(:map)
diffs.map(&:to_hash)
end
end
def load_diffs(raw, options)
if raw.respond_to?(:each)
Gitlab::Git::DiffCollection.new(raw, options)
else
Gitlab::Git::DiffCollection.new([])
end
end
# Reload diffs between branches related to current merge request from repo
# and save it as array of hashes in st_diffs db field
def reload_diffs
......@@ -164,42 +186,24 @@ def reload_diffs
keep_around_commits
end
# Collect array of Git::Diff objects
# between target and source branches
def unmerged_diffs
compare.diffs(Commit.max_diff_options)
def project
merge_request.target_project
end
def repository
merge_request.target_project.repository
project.repository
end
def branch_base_commit
return unless self.source_branch_sha && self.target_branch_sha
merge_request.target_project.merge_base_commit(self.source_branch_sha, self.target_branch_sha)
project.merge_base_commit(self.source_branch_sha, self.target_branch_sha)
end
def branch_base_sha
branch_base_commit.try(:sha)
end
def compare
@compare ||=
begin
# Update ref for merge request
merge_request.fetch_ref
Gitlab::Git::Compare.new(
self.repository.raw_repository,
self.target_branch_sha,
self.source_branch_sha
)
end
end
private
#
# #save or #update_attributes providing changes on serialized attributes do a lot of
# serialization and deserialization calls resulting in bad performance.
......
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