| ... | @@ -3,6 +3,7 @@ module Gitlab |
... | @@ -3,6 +3,7 @@ module Gitlab |
|
|
module Git
|
|
module Git
|
|
|
class Commit
|
|
class Commit
|
|
|
include Gitlab::EncodingHelper
|
|
include Gitlab::EncodingHelper
|
|
|
|
prepend Gitlab::Git::RuggedImpl::Commit
|
|
|
extend Gitlab::Git::WrapsGitalyErrors
|
|
extend Gitlab::Git::WrapsGitalyErrors
|
|
|
|
|
|
|
|
attr_accessor :raw_commit, :head
|
|
attr_accessor :raw_commit, :head
|
| ... | @@ -60,15 +61,19 @@ module Gitlab |
... | @@ -60,15 +61,19 @@ module Gitlab |
|
|
# This saves us an RPC round trip.
|
|
# This saves us an RPC round trip.
|
|
|
return nil if commit_id.include?(':')
|
|
return nil if commit_id.include?(':')
|
|
|
|
|
|
|
|
commit = wrapped_gitaly_errors do
|
|
commit = find_commit(repo, commit_id)
|
|
|
repo.gitaly_commit_client.find_commit(commit_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
decorate(repo, commit) if commit
|
|
decorate(repo, commit) if commit
|
|
|
rescue Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, ArgumentError
|
|
rescue Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, ArgumentError
|
|
|
nil
|
|
nil
|
|
|
end
|
|
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
|
|
# Get last commit for HEAD
|
|
|
#
|
|
#
|
|
|
# Ex.
|
|
# Ex.
|
| ... | @@ -199,6 +204,10 @@ module Gitlab |
... | @@ -199,6 +204,10 @@ module Gitlab |
|
|
@repository = repository
|
|
@repository = repository
|
|
|
@head = head
|
|
@head = head
|
|
|
|
|
|
|
|
|
init_commit(raw_commit)
|
|
|
|
end
|
|
|
|
|
|
|
|
def init_commit(raw_commit)
|
|
|
case raw_commit
|
|
case raw_commit
|
|
|
when Hash
|
|
when Hash
|
|
|
init_from_hash(raw_commit)
|
|
init_from_hash(raw_commit)
|
| ... | @@ -319,11 +328,16 @@ module Gitlab |
... | @@ -319,11 +328,16 @@ module Gitlab |
|
|
def tree_entry(path)
|
|
def tree_entry(path)
|
|
|
return unless path.present?
|
|
return unless path.present?
|
|
|
|
|
|
|
|
|
commit_tree_entry(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def commit_tree_entry(path)
|
|
|
# We're only interested in metadata, so limit actual data to 1 byte
|
|
# We're only interested in metadata, so limit actual data to 1 byte
|
|
|
# since Gitaly doesn't support "send no data" option.
|
|
# since Gitaly doesn't support "send no data" option.
|
|
|
entry = @repository.gitaly_commit_client.tree_entry(id, path, 1)
|
|
entry = @repository.gitaly_commit_client.tree_entry(id, path, 1)
|
|
|
return unless entry
|
|
return unless entry
|
|
|
|
|
|
|
|
|
# To be compatible with the rugged format
|
|
|
entry = entry.to_h
|
|
entry = entry.to_h
|
|
|
entry.delete(:data)
|
|
entry.delete(:data)
|
|
|
entry[:name] = File.basename(path)
|
|
entry[:name] = File.basename(path)
|
| ... | @@ -414,3 +428,5 @@ module Gitlab |
... | @@ -414,3 +428,5 @@ module Gitlab |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
Gitlab::Git::Commit.singleton_class.prepend Gitlab::Git::RuggedImpl::Commit::ClassMethods |