diff options
author | Sean McGivern <sean@gitlab.com> | 2019-03-04 12:22:44 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-04 12:22:44 +0300 |
commit | fd50ba4240469615458d5554e24613b432b6c6c0 (patch) | |
tree | e94346e0c16b5dea928653f54dc5288689886393 /lib/gitlab/git/commit.rb | |
parent | d4a2cd793992f96a24170a4d356f7849cf10e9cb (diff) | |
parent | fb6a4e21d4a5142e72ac5864fae29192cfc59d64 (diff) |
Merge branch 'sh-rugged-find-commit' into 'master'
Bring back Rugged implementation of find_commit
See merge request gitlab-org/gitlab-ce!25477
Diffstat (limited to 'lib/gitlab/git/commit.rb')
-rw-r--r-- | lib/gitlab/git/commit.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 5863815ca85..c5688cda565 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -5,6 +5,7 @@ module Gitlab module Git class Commit include Gitlab::EncodingHelper + prepend Gitlab::Git::RuggedImpl::Commit extend Gitlab::Git::WrapsGitalyErrors attr_accessor :raw_commit, :head @@ -62,15 +63,19 @@ module Gitlab # This saves us an RPC round trip. return nil if commit_id.include?(':') - commit = wrapped_gitaly_errors do - repo.gitaly_commit_client.find_commit(commit_id) - end + commit = find_commit(repo, commit_id) decorate(repo, commit) if commit rescue Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, ArgumentError nil end + def find_commit(repo, commit_id) + wrapped_gitaly_errors do + repo.gitaly_commit_client.find_commit(commit_id) + end + end + # Get last commit for HEAD # # Ex. @@ -185,6 +190,10 @@ module Gitlab @repository = repository @head = head + init_commit(raw_commit) + end + + def init_commit(raw_commit) case raw_commit when Hash init_from_hash(raw_commit) @@ -400,3 +409,5 @@ module Gitlab end end end + +Gitlab::Git::Commit.singleton_class.prepend Gitlab::Git::RuggedImpl::Commit::ClassMethods |