diff options
author | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-07-25 16:48:17 -0400 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-08-07 22:34:34 -0400 |
commit | c21ae07e331ca14605410555d0582f14cb661bb6 (patch) | |
tree | 1eb80eec41f5d28a36976f411c4b1eb5ba27723b /app | |
parent | 942bd5b4112d90c66d637ef350b881574de45065 (diff) | |
download | gitlab-ce-c21ae07e331ca14605410555d0582f14cb661bb6.tar.gz |
Refactor Gitlab::Git::Commit to include a repository
Diffstat (limited to 'app')
-rw-r--r-- | app/models/commit.rb | 3 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 4 | ||||
-rw-r--r-- | app/models/repository.rb | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 7940733f557..96605c9168b 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -55,7 +55,8 @@ class Commit end def from_hash(hash, project) - new(Gitlab::Git::Commit.new(hash), project) + raw_commit = Gitlab::Git::Commit.new(project.repository.raw, hash) + new(raw_commit, project) end def valid_hash?(key) diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index d9d746ccf41..58050e1f438 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -282,9 +282,7 @@ class MergeRequestDiff < ActiveRecord::Base def load_commits commits = st_commits.presence || merge_request_diff_commits - commits.map do |commit| - Commit.new(Gitlab::Git::Commit.new(commit.to_hash), merge_request.source_project) - end + commits.map { |commit| Commit.from_hash(commit.to_hash, project) } end def save_diffs diff --git a/app/models/repository.rb b/app/models/repository.rb index f86a0869b01..3045db06af1 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -64,6 +64,8 @@ class Repository @raw_repository ||= initialize_raw_repository end + alias_method :raw, :raw_repository + # Return absolute path to repository def path_to_repo @path_to_repo ||= File.expand_path( |