summaryrefslogtreecommitdiff
path: root/lib/gitlab/git
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /lib/gitlab/git
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r--lib/gitlab/git/repository.rb28
-rw-r--r--lib/gitlab/git/user.rb19
-rw-r--r--lib/gitlab/git/wiki.rb7
3 files changed, 38 insertions, 16 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index e38c7b516ee..70d072e8082 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -354,9 +354,13 @@ module Gitlab
end
end
- def new_commits(newrev)
+ def new_commits(newrevs)
wrapped_gitaly_errors do
- gitaly_ref_client.list_new_commits(newrev)
+ if Feature.enabled?(:list_commits)
+ gitaly_commit_client.list_commits(Array.wrap(newrevs) + %w[--not --all])
+ else
+ Array.wrap(newrevs).flat_map { |newrev| gitaly_ref_client.list_new_commits(newrev) }
+ end
end
end
@@ -370,6 +374,20 @@ module Gitlab
end
end
+ # List blobs reachable via a set of revisions. Supports the
+ # pseudo-revisions `--not` and `--all`. Uses the minimum of
+ # GitalyClient.medium_timeout and dynamic timeout if the dynamic
+ # timeout is set, otherwise it'll always use the medium timeout.
+ def blobs(revisions, dynamic_timeout: nil)
+ revisions = revisions.reject { |rev| rev.blank? || rev == ::Gitlab::Git::BLANK_SHA }
+
+ return [] if revisions.blank?
+
+ wrapped_gitaly_errors do
+ gitaly_blob_client.list_blobs(revisions, limit: REV_LIST_COMMIT_LIMIT, dynamic_timeout: dynamic_timeout)
+ end
+ end
+
def count_commits(options)
options = process_count_commits_options(options.dup)
@@ -869,12 +887,6 @@ module Gitlab
end
end
- def rebase_in_progress?(rebase_id)
- wrapped_gitaly_errors do
- gitaly_repository_client.rebase_in_progress?(rebase_id)
- end
- end
-
def squash(user, squash_id, start_sha:, end_sha:, author:, message:)
wrapped_gitaly_errors do
gitaly_operation_client.user_squash(user, squash_id, start_sha, end_sha, author, message)
diff --git a/lib/gitlab/git/user.rb b/lib/gitlab/git/user.rb
index 2c798844798..05ae3391040 100644
--- a/lib/gitlab/git/user.rb
+++ b/lib/gitlab/git/user.rb
@@ -3,10 +3,10 @@
module Gitlab
module Git
class User
- attr_reader :username, :name, :email, :gl_id
+ attr_reader :username, :name, :email, :gl_id, :timezone
def self.from_gitlab(gitlab_user)
- new(gitlab_user.username, gitlab_user.name, gitlab_user.commit_email, Gitlab::GlId.gl_id(gitlab_user))
+ new(gitlab_user.username, gitlab_user.name, gitlab_user.commit_email, Gitlab::GlId.gl_id(gitlab_user), gitlab_user.timezone)
end
def self.from_gitaly(gitaly_user)
@@ -14,23 +14,30 @@ module Gitlab
gitaly_user.gl_username,
Gitlab::EncodingHelper.encode!(gitaly_user.name),
Gitlab::EncodingHelper.encode!(gitaly_user.email),
- gitaly_user.gl_id
+ gitaly_user.gl_id,
+ gitaly_user.timezone
)
end
- def initialize(username, name, email, gl_id)
+ def initialize(username, name, email, gl_id, timezone)
@username = username
@name = name
@email = email
@gl_id = gl_id
+
+ @timezone = if Feature.enabled?(:add_timezone_to_web_operations)
+ timezone
+ else
+ Time.zone.tzinfo.name
+ end
end
def ==(other)
- [username, name, email, gl_id] == [other.username, other.name, other.email, other.gl_id]
+ [username, name, email, gl_id, timezone] == [other.username, other.name, other.email, other.gl_id, other.timezone]
end
def to_gitaly
- Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name.b, email: email.b)
+ Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name.b, email: email.b, timezone: timezone)
end
end
end
diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb
index 5616b61de07..194f5da0a5c 100644
--- a/lib/gitlab/git/wiki.rb
+++ b/lib/gitlab/git/wiki.rb
@@ -54,8 +54,11 @@ module Gitlab
attr_reader :repository
- def self.default_ref
- 'master'
+ # TODO remove argument when issue
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/329190
+ # is closed.
+ def self.default_ref(container = nil)
+ Gitlab::DefaultBranch.value(object: container)
end
# Initialize with a Gitlab::Git::Repository instance