diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /lib/gitlab/git | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/commit.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/git/diff.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/git/wiki.rb | 4 |
4 files changed, 31 insertions, 20 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 17d0a62ba8c..8db73ecc480 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -90,14 +90,15 @@ module Gitlab # # Commit.last_for_path(repo, 'master', 'Gemfile') # - def last_for_path(repo, ref, path = nil) + def last_for_path(repo, ref, path = nil, literal_pathspec: false) # rubocop: disable Rails/FindBy # This is not where..first from ActiveRecord where( repo: repo, ref: ref, path: path, - limit: 1 + limit: 1, + literal_pathspec: literal_pathspec ).first # rubocop: enable Rails/FindBy end diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index bb845f11181..09a49b6c1ca 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -224,18 +224,18 @@ module Gitlab end end - def init_from_gitaly(diff) - @diff = diff.respond_to?(:patch) ? encode!(diff.patch) : '' - @new_path = encode!(diff.to_path.dup) - @old_path = encode!(diff.from_path.dup) - @a_mode = diff.old_mode.to_s(8) - @b_mode = diff.new_mode.to_s(8) - @new_file = diff.from_id == BLANK_SHA - @renamed_file = diff.from_path != diff.to_path - @deleted_file = diff.to_id == BLANK_SHA - @too_large = diff.too_large if diff.respond_to?(:too_large) - - collapse! if diff.respond_to?(:collapsed) && diff.collapsed + def init_from_gitaly(gitaly_diff) + @diff = gitaly_diff.respond_to?(:patch) ? encode!(gitaly_diff.patch) : '' + @new_path = encode!(gitaly_diff.to_path.dup) + @old_path = encode!(gitaly_diff.from_path.dup) + @a_mode = gitaly_diff.old_mode.to_s(8) + @b_mode = gitaly_diff.new_mode.to_s(8) + @new_file = gitaly_diff.from_id == BLANK_SHA + @renamed_file = gitaly_diff.from_path != gitaly_diff.to_path + @deleted_file = gitaly_diff.to_id == BLANK_SHA + @too_large = gitaly_diff.too_large if gitaly_diff.respond_to?(:too_large) + + collapse! if gitaly_diff.respond_to?(:collapsed) && gitaly_diff.collapsed end def prune_diff_if_eligible diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index ed746163748..ea7a6e84195 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -127,9 +127,9 @@ module Gitlab end end - def local_branches(sort_by: nil) + def local_branches(sort_by: nil, pagination_params: nil) wrapped_gitaly_errors do - gitaly_ref_client.local_branches(sort_by: sort_by) + gitaly_ref_client.local_branches(sort_by: sort_by, pagination_params: pagination_params) end end @@ -1002,15 +1002,21 @@ module Gitlab end end - def list_last_commits_for_tree(sha, path, offset: 0, limit: 25) + def list_last_commits_for_tree(sha, path, offset: 0, limit: 25, literal_pathspec: false) wrapped_gitaly_errors do - gitaly_commit_client.list_last_commits_for_tree(sha, path, offset: offset, limit: limit) + gitaly_commit_client.list_last_commits_for_tree(sha, path, offset: offset, limit: limit, literal_pathspec: literal_pathspec) end end - def last_commit_for_path(sha, path) + def list_commits_by_ref_name(refs) wrapped_gitaly_errors do - gitaly_commit_client.last_commit_for_path(sha, path) + gitaly_commit_client.list_commits_by_ref_name(refs) + end + end + + def last_commit_for_path(sha, path, literal_pathspec: false) + wrapped_gitaly_errors do + gitaly_commit_client.last_commit_for_path(sha, path, literal_pathspec: literal_pathspec) end end diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb index 3025fc6bfdb..76771f0417b 100644 --- a/lib/gitlab/git/wiki.rb +++ b/lib/gitlab/git/wiki.rb @@ -101,6 +101,10 @@ module Gitlab wrapped_gitaly_errors do gitaly_find_page(title: title, version: version, dir: dir) end + rescue Gitlab::Git::CommandError + # Return nil for invalid versions. + # This can be removed with https://gitlab.com/gitlab-org/gitaly/-/merge_requests/2323 in place. + nil end def file(name, version) |