diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:08:59 +0300 |
commit | d466ee5042520ad078fe050cb078d81dc2ebe196 (patch) | |
tree | 5648eb1aee8aeff5b5c5ff4669a184fd7676f778 /lib | |
parent | 6a9d7c009e4e5975a89bcc3e458da4b3ec484bd1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
39 files changed, 490 insertions, 267 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 9dcf9b015aa..4e04a99e97c 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -38,6 +38,7 @@ module API optional :all, type: Boolean, desc: 'Every commit will be returned' optional :with_stats, type: Boolean, desc: 'Stats about each commit will be added to the response' optional :first_parent, type: Boolean, desc: 'Only include the first parent of merges' + optional :order, type: String, desc: 'List commits in order', values: %w[topo] use :pagination end get ':id/repository/commits' do @@ -49,6 +50,7 @@ module API all = params[:all] with_stats = params[:with_stats] first_parent = params[:first_parent] + order = params[:order] commits = user_project.repository.commits(ref, path: path, @@ -57,7 +59,8 @@ module API before: before, after: after, all: all, - first_parent: first_parent) + first_parent: first_parent, + order: order) commit_count = if all || path || before || after || first_parent diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5128ffa6a1f..b9805973c54 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -129,40 +129,6 @@ module API end end - class Namespace < NamespaceBasic - expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _| - namespace.users_with_descendants.count - end - - def expose_members_count_with_descendants?(namespace, opts) - namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace) - end - end - - class MemberAccess < Grape::Entity - expose :access_level - expose :notification_level do |member, options| - if member.notification_setting - ::NotificationSetting.levels[member.notification_setting.level] - end - end - end - - class ProjectAccess < MemberAccess - end - - class GroupAccess < MemberAccess - end - - class NotificationSetting < Grape::Entity - expose :level - expose :events, if: ->(notification_setting, _) { notification_setting.custom? } do - ::NotificationSetting.email_events.each do |event| - expose event - end - end - end - class Trigger < Grape::Entity include ::API::Helpers::Presentable @@ -204,39 +170,6 @@ module API expose :variables, using: Entities::Variable end - class EnvironmentBasic < Grape::Entity - expose :id, :name, :slug, :external_url - end - - class Deployment < Grape::Entity - expose :id, :iid, :ref, :sha, :created_at, :updated_at - expose :user, using: Entities::UserBasic - expose :environment, using: Entities::EnvironmentBasic - expose :deployable, using: Entities::Job - expose :status - end - - class Environment < EnvironmentBasic - expose :project, using: Entities::BasicProjectDetails - expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true } - expose :state - end - - class LicenseBasic < Grape::Entity - expose :key, :name, :nickname - expose :url, as: :html_url - expose(:source_url) { |license| license.meta['source'] } - end - - class License < LicenseBasic - expose :popular?, as: :popular - expose(:description) { |license| license.meta['description'] } - expose(:conditions) { |license| license.meta['conditions'] } - expose(:permissions) { |license| license.meta['permissions'] } - expose(:limitations) { |license| license.meta['limitations'] } - expose :content - end - class ImpersonationToken < PersonalAccessToken expose :impersonation end @@ -267,93 +200,6 @@ module API end end - module JobRequest - class JobInfo < Grape::Entity - expose :name, :stage - expose :project_id, :project_name - end - - class GitInfo < Grape::Entity - expose :repo_url, :ref, :sha, :before_sha - expose :ref_type - expose :refspecs - expose :git_depth, as: :depth - end - - class RunnerInfo < Grape::Entity - expose :metadata_timeout, as: :timeout - expose :runner_session_url - end - - class Step < Grape::Entity - expose :name, :script, :timeout, :when, :allow_failure - end - - class Port < Grape::Entity - expose :number, :protocol, :name - end - - class Image < Grape::Entity - expose :name, :entrypoint - expose :ports, using: JobRequest::Port - end - - class Service < Image - expose :alias, :command - end - - class Artifacts < Grape::Entity - expose :name - expose :untracked - expose :paths - expose :when - expose :expire_in - expose :artifact_type - expose :artifact_format - end - - class Cache < Grape::Entity - expose :key, :untracked, :paths, :policy - end - - class Credentials < Grape::Entity - expose :type, :url, :username, :password - end - - class Dependency < Grape::Entity - expose :id, :name, :token - expose :artifacts_file, using: JobArtifactFile, if: ->(job, _) { job.artifacts? } - end - - class Response < Grape::Entity - expose :id - expose :token - expose :allow_git_fetch - - expose :job_info, using: JobInfo do |model| - model - end - - expose :git_info, using: GitInfo do |model| - model - end - - expose :runner_info, using: RunnerInfo do |model| - model - end - - expose :variables - expose :steps, using: Step - expose :image, using: Image - expose :services, using: Service - expose :artifacts, using: Artifacts - expose :cache, using: Cache - expose :credentials, using: Credentials - expose :all_dependencies, as: :dependencies, using: Dependency - expose :features - end - end - class UserAgentDetail < Grape::Entity expose :user_agent expose :ip_address @@ -370,45 +216,6 @@ module API expose :expiration end - class PagesDomainCertificate < Grape::Entity - expose :subject - expose :expired?, as: :expired - expose :certificate - expose :certificate_text - end - - class PagesDomainBasic < Grape::Entity - expose :domain - expose :url - expose :project_id - expose :verified?, as: :verified - expose :verification_code, as: :verification_code - expose :enabled_until - expose :auto_ssl_enabled - - expose :certificate, - as: :certificate_expiration, - if: ->(pages_domain, _) { pages_domain.certificate? }, - using: PagesDomainCertificateExpiration do |pages_domain| - pages_domain - end - end - - class PagesDomain < Grape::Entity - expose :domain - expose :url - expose :verified?, as: :verified - expose :verification_code, as: :verification_code - expose :enabled_until - expose :auto_ssl_enabled - - expose :certificate, - if: ->(pages_domain, _) { pages_domain.certificate? }, - using: PagesDomainCertificate do |pages_domain| - pages_domain - end - end - class Application < Grape::Entity expose :id expose :uid, as: :application_id @@ -437,49 +244,6 @@ module API expose :project_id end - class BasicBadgeDetails < Grape::Entity - expose :name - expose :link_url - expose :image_url - expose :rendered_link_url do |badge, options| - badge.rendered_link_url(options.fetch(:project, nil)) - end - expose :rendered_image_url do |badge, options| - badge.rendered_image_url(options.fetch(:project, nil)) - end - end - - class Badge < BasicBadgeDetails - expose :id - expose :kind do |badge| - badge.type == 'ProjectBadge' ? 'project' : 'group' - end - end - - class ResourceLabelEvent < Grape::Entity - expose :id - expose :user, using: Entities::UserBasic - expose :created_at - expose :resource_type do |event, options| - event.issuable.class.name - end - expose :resource_id do |event, options| - event.issuable.id - end - expose :label, using: Entities::LabelBasic - expose :action - end - - class Suggestion < Grape::Entity - expose :id - expose :from_line - expose :to_line - expose :appliable?, as: :appliable - expose :applied - expose :from_content - expose :to_content - end - module Platform class Kubernetes < Grape::Entity expose :api_url @@ -501,23 +265,6 @@ module API end end - class Cluster < Grape::Entity - expose :id, :name, :created_at, :domain - expose :provider_type, :platform_type, :environment_scope, :cluster_type - expose :user, using: Entities::UserBasic - expose :platform_kubernetes, using: Entities::Platform::Kubernetes - expose :provider_gcp, using: Entities::Provider::Gcp - expose :management_project, using: Entities::ProjectIdentity - end - - class ClusterProject < Cluster - expose :project, using: Entities::BasicProjectDetails - end - - class ClusterGroup < Cluster - expose :group, using: Entities::BasicGroupDetails - end - module InternalPostReceive class Message < Grape::Entity expose :message diff --git a/lib/api/entities/badge.rb b/lib/api/entities/badge.rb new file mode 100644 index 00000000000..1e3e2ec469a --- /dev/null +++ b/lib/api/entities/badge.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class Badge < Entities::BasicBadgeDetails + expose :id + expose :kind do |badge| + badge.type == 'ProjectBadge' ? 'project' : 'group' + end + end + end +end diff --git a/lib/api/entities/basic_badge_details.rb b/lib/api/entities/basic_badge_details.rb new file mode 100644 index 00000000000..273dc57fe67 --- /dev/null +++ b/lib/api/entities/basic_badge_details.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module API + module Entities + class BasicBadgeDetails < Grape::Entity + expose :name + expose :link_url + expose :image_url + expose :rendered_link_url do |badge, options| + badge.rendered_link_url(options.fetch(:project, nil)) + end + expose :rendered_image_url do |badge, options| + badge.rendered_image_url(options.fetch(:project, nil)) + end + end + end +end diff --git a/lib/api/entities/cluster.rb b/lib/api/entities/cluster.rb new file mode 100644 index 00000000000..4cb54e988ce --- /dev/null +++ b/lib/api/entities/cluster.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + class Cluster < Grape::Entity + expose :id, :name, :created_at, :domain + expose :provider_type, :platform_type, :environment_scope, :cluster_type + expose :user, using: Entities::UserBasic + expose :platform_kubernetes, using: Entities::Platform::Kubernetes + expose :provider_gcp, using: Entities::Provider::Gcp + expose :management_project, using: Entities::ProjectIdentity + end + end +end diff --git a/lib/api/entities/cluster_group.rb b/lib/api/entities/cluster_group.rb new file mode 100644 index 00000000000..8f71438cf3d --- /dev/null +++ b/lib/api/entities/cluster_group.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class ClusterGroup < Entities::Cluster + expose :group, using: Entities::BasicGroupDetails + end + end +end diff --git a/lib/api/entities/cluster_project.rb b/lib/api/entities/cluster_project.rb new file mode 100644 index 00000000000..2fd3e35e2a2 --- /dev/null +++ b/lib/api/entities/cluster_project.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class ClusterProject < Entities::Cluster + expose :project, using: Entities::BasicProjectDetails + end + end +end diff --git a/lib/api/entities/deployment.rb b/lib/api/entities/deployment.rb new file mode 100644 index 00000000000..3a97d3e3c09 --- /dev/null +++ b/lib/api/entities/deployment.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Entities + class Deployment < Grape::Entity + expose :id, :iid, :ref, :sha, :created_at, :updated_at + expose :user, using: Entities::UserBasic + expose :environment, using: Entities::EnvironmentBasic + expose :deployable, using: Entities::Job + expose :status + end + end +end diff --git a/lib/api/entities/environment.rb b/lib/api/entities/environment.rb new file mode 100644 index 00000000000..cb39ce1b13a --- /dev/null +++ b/lib/api/entities/environment.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + class Environment < Entities::EnvironmentBasic + expose :project, using: Entities::BasicProjectDetails + expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true } + expose :state + end + end +end diff --git a/lib/api/entities/environment_basic.rb b/lib/api/entities/environment_basic.rb new file mode 100644 index 00000000000..061d4739874 --- /dev/null +++ b/lib/api/entities/environment_basic.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class EnvironmentBasic < Grape::Entity + expose :id, :name, :slug, :external_url + end + end +end diff --git a/lib/api/entities/group_access.rb b/lib/api/entities/group_access.rb new file mode 100644 index 00000000000..5e53e9645c2 --- /dev/null +++ b/lib/api/entities/group_access.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module API + module Entities + class GroupAccess < MemberAccess + end + end +end diff --git a/lib/api/entities/job_request/artifacts.rb b/lib/api/entities/job_request/artifacts.rb new file mode 100644 index 00000000000..c6871fdd875 --- /dev/null +++ b/lib/api/entities/job_request/artifacts.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Artifacts < Grape::Entity + expose :name + expose :untracked + expose :paths + expose :when + expose :expire_in + expose :artifact_type + expose :artifact_format + end + end + end +end diff --git a/lib/api/entities/job_request/cache.rb b/lib/api/entities/job_request/cache.rb new file mode 100644 index 00000000000..a75affbaf84 --- /dev/null +++ b/lib/api/entities/job_request/cache.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Cache < Grape::Entity + expose :key, :untracked, :paths, :policy + end + end + end +end diff --git a/lib/api/entities/job_request/credentials.rb b/lib/api/entities/job_request/credentials.rb new file mode 100644 index 00000000000..cdac5566cbd --- /dev/null +++ b/lib/api/entities/job_request/credentials.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Credentials < Grape::Entity + expose :type, :url, :username, :password + end + end + end +end diff --git a/lib/api/entities/job_request/dependency.rb b/lib/api/entities/job_request/dependency.rb new file mode 100644 index 00000000000..64d779f6575 --- /dev/null +++ b/lib/api/entities/job_request/dependency.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Dependency < Grape::Entity + expose :id, :name, :token + expose :artifacts_file, using: Entities::JobArtifactFile, if: ->(job, _) { job.artifacts? } + end + end + end +end diff --git a/lib/api/entities/job_request/git_info.rb b/lib/api/entities/job_request/git_info.rb new file mode 100644 index 00000000000..e07099263b5 --- /dev/null +++ b/lib/api/entities/job_request/git_info.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class GitInfo < Grape::Entity + expose :repo_url, :ref, :sha, :before_sha + expose :ref_type + expose :refspecs + expose :git_depth, as: :depth + end + end + end +end diff --git a/lib/api/entities/job_request/image.rb b/lib/api/entities/job_request/image.rb new file mode 100644 index 00000000000..47f4542d2d5 --- /dev/null +++ b/lib/api/entities/job_request/image.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Image < Grape::Entity + expose :name, :entrypoint + expose :ports, using: Entities::JobRequest::Port + end + end + end +end diff --git a/lib/api/entities/job_request/job_info.rb b/lib/api/entities/job_request/job_info.rb new file mode 100644 index 00000000000..09c13aa8471 --- /dev/null +++ b/lib/api/entities/job_request/job_info.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class JobInfo < Grape::Entity + expose :name, :stage + expose :project_id, :project_name + end + end + end +end diff --git a/lib/api/entities/job_request/port.rb b/lib/api/entities/job_request/port.rb new file mode 100644 index 00000000000..ee427da8657 --- /dev/null +++ b/lib/api/entities/job_request/port.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Port < Grape::Entity + expose :number, :protocol, :name + end + end + end +end diff --git a/lib/api/entities/job_request/response.rb b/lib/api/entities/job_request/response.rb new file mode 100644 index 00000000000..fdacd3af2da --- /dev/null +++ b/lib/api/entities/job_request/response.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Response < Grape::Entity + expose :id + expose :token + expose :allow_git_fetch + + expose :job_info, using: Entities::JobRequest::JobInfo do |model| + model + end + + expose :git_info, using: Entities::JobRequest::GitInfo do |model| + model + end + + expose :runner_info, using: Entities::JobRequest::RunnerInfo do |model| + model + end + + expose :variables + expose :steps, using: Entities::JobRequest::Step + expose :image, using: Entities::JobRequest::Image + expose :services, using: Entities::JobRequest::Service + expose :artifacts, using: Entities::JobRequest::Artifacts + expose :cache, using: Entities::JobRequest::Cache + expose :credentials, using: Entities::JobRequest::Credentials + expose :all_dependencies, as: :dependencies, using: Entities::JobRequest::Dependency + expose :features + end + end + end +end diff --git a/lib/api/entities/job_request/runner_info.rb b/lib/api/entities/job_request/runner_info.rb new file mode 100644 index 00000000000..e6d2e8d9e85 --- /dev/null +++ b/lib/api/entities/job_request/runner_info.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class RunnerInfo < Grape::Entity + expose :metadata_timeout, as: :timeout + expose :runner_session_url + end + end + end +end diff --git a/lib/api/entities/job_request/service.rb b/lib/api/entities/job_request/service.rb new file mode 100644 index 00000000000..9ad5abf4e9e --- /dev/null +++ b/lib/api/entities/job_request/service.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Service < Entities::JobRequest::Image + expose :alias, :command + end + end + end +end diff --git a/lib/api/entities/job_request/step.rb b/lib/api/entities/job_request/step.rb new file mode 100644 index 00000000000..498dd017fb4 --- /dev/null +++ b/lib/api/entities/job_request/step.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + module JobRequest + class Step < Grape::Entity + expose :name, :script, :timeout, :when, :allow_failure + end + end + end +end diff --git a/lib/api/entities/license.rb b/lib/api/entities/license.rb new file mode 100644 index 00000000000..d7a414344c1 --- /dev/null +++ b/lib/api/entities/license.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + class License < Entities::LicenseBasic + expose :popular?, as: :popular + expose(:description) { |license| license.meta['description'] } + expose(:conditions) { |license| license.meta['conditions'] } + expose(:permissions) { |license| license.meta['permissions'] } + expose(:limitations) { |license| license.meta['limitations'] } + expose :content + end + end +end diff --git a/lib/api/entities/license_basic.rb b/lib/api/entities/license_basic.rb new file mode 100644 index 00000000000..08af68785a9 --- /dev/null +++ b/lib/api/entities/license_basic.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module API + module Entities + class LicenseBasic < Grape::Entity + expose :key, :name, :nickname + expose :url, as: :html_url + expose(:source_url) { |license| license.meta['source'] } + end + end +end diff --git a/lib/api/entities/member_access.rb b/lib/api/entities/member_access.rb new file mode 100644 index 00000000000..097c72bf617 --- /dev/null +++ b/lib/api/entities/member_access.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + class MemberAccess < Grape::Entity + expose :access_level + expose :notification_level do |member, options| + if member.notification_setting + ::NotificationSetting.levels[member.notification_setting.level] + end + end + end + end +end diff --git a/lib/api/entities/namespace.rb b/lib/api/entities/namespace.rb new file mode 100644 index 00000000000..b21dd29c7b4 --- /dev/null +++ b/lib/api/entities/namespace.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module API + module Entities + class Namespace < Entities::NamespaceBasic + expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _| + namespace.users_with_descendants.count + end + + def expose_members_count_with_descendants?(namespace, opts) + namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace) + end + end + end +end diff --git a/lib/api/entities/notification_setting.rb b/lib/api/entities/notification_setting.rb new file mode 100644 index 00000000000..cdff4f2f5c5 --- /dev/null +++ b/lib/api/entities/notification_setting.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + class NotificationSetting < Grape::Entity + expose :level + expose :events, if: ->(notification_setting, _) { notification_setting.custom? } do + ::NotificationSetting.email_events.each do |event| + expose event + end + end + end + end +end diff --git a/lib/api/entities/pages_domain.rb b/lib/api/entities/pages_domain.rb new file mode 100644 index 00000000000..87af8c7b0a4 --- /dev/null +++ b/lib/api/entities/pages_domain.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module API + module Entities + class PagesDomain < Grape::Entity + expose :domain + expose :url + expose :verified?, as: :verified + expose :verification_code, as: :verification_code + expose :enabled_until + expose :auto_ssl_enabled + + expose :certificate, + if: ->(pages_domain, _) { pages_domain.certificate? }, + using: Entities::PagesDomainCertificate do |pages_domain| + pages_domain + end + end + end +end diff --git a/lib/api/entities/pages_domain_basic.rb b/lib/api/entities/pages_domain_basic.rb new file mode 100644 index 00000000000..6f8901fe715 --- /dev/null +++ b/lib/api/entities/pages_domain_basic.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module API + module Entities + class PagesDomainBasic < Grape::Entity + expose :domain + expose :url + expose :project_id + expose :verified?, as: :verified + expose :verification_code, as: :verification_code + expose :enabled_until + expose :auto_ssl_enabled + + expose :certificate, + as: :certificate_expiration, + if: ->(pages_domain, _) { pages_domain.certificate? }, + using: Entities::PagesDomainCertificateExpiration do |pages_domain| + pages_domain + end + end + end +end diff --git a/lib/api/entities/pages_domain_certificate.rb b/lib/api/entities/pages_domain_certificate.rb new file mode 100644 index 00000000000..82c4729d454 --- /dev/null +++ b/lib/api/entities/pages_domain_certificate.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class PagesDomainCertificate < Grape::Entity + expose :subject + expose :expired?, as: :expired + expose :certificate + expose :certificate_text + end + end +end diff --git a/lib/api/entities/project_access.rb b/lib/api/entities/project_access.rb new file mode 100644 index 00000000000..29f85fda620 --- /dev/null +++ b/lib/api/entities/project_access.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module API + module Entities + class ProjectAccess < Entities::MemberAccess + end + end +end diff --git a/lib/api/entities/resource_label_event.rb b/lib/api/entities/resource_label_event.rb new file mode 100644 index 00000000000..890264abf93 --- /dev/null +++ b/lib/api/entities/resource_label_event.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module API + module Entities + class ResourceLabelEvent < Grape::Entity + expose :id + expose :user, using: Entities::UserBasic + expose :created_at + expose :resource_type do |event, options| + event.issuable.class.name + end + expose :resource_id do |event, options| + event.issuable.id + end + expose :label, using: Entities::LabelBasic + expose :action + end + end +end diff --git a/lib/api/entities/suggestion.rb b/lib/api/entities/suggestion.rb new file mode 100644 index 00000000000..59f94099d7f --- /dev/null +++ b/lib/api/entities/suggestion.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module API + module Entities + class Suggestion < Grape::Entity + expose :id + expose :from_line + expose :to_line + expose :appliable?, as: :appliable + expose :applied + expose :from_content + expose :to_content + end + end +end diff --git a/lib/gitlab/background_migration/recalculate_project_authorizations.rb b/lib/gitlab/background_migration/recalculate_project_authorizations.rb new file mode 100644 index 00000000000..3d2ce9fc10c --- /dev/null +++ b/lib/gitlab/background_migration/recalculate_project_authorizations.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # rubocop:disable Style/Documentation + class RecalculateProjectAuthorizations + def perform(user_ids) + user_ids.each do |user_id| + user = User.find_by(id: user_id) + + next unless user + + service = Users::RefreshAuthorizedProjectsService.new( + user, + incorrect_auth_found_callback: + ->(project_id, access_level) do + logger.info(message: 'Removing ProjectAuthorizations', + user_id: user.id, + project_id: project_id, + access_level: access_level) + end, + missing_auth_found_callback: + ->(project_id, access_level) do + logger.info(message: 'Creating ProjectAuthorizations', + user_id: user.id, + project_id: project_id, + access_level: access_level) + end + ) + + service.execute + end + end + + private + + def logger + @logger ||= Gitlab::BackgroundMigration::Logger.build + end + end + end +end diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index 17a7be311ca..4fc5bfddf0c 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -353,11 +353,7 @@ module Gitlab def fetch_blob(sha, path) return unless sha - # Load only patch_hard_limit_bytes number of bytes for the blob - # Because otherwise, it is too large to be displayed - Blob.lazy( - repository.project, sha, path, - blob_size_limit: Gitlab::Git::Diff.patch_hard_limit_bytes) + Blob.lazy(repository.project, sha, path) end def total_blob_lines(blob) diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 48da838366f..0b999197cd8 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -130,8 +130,7 @@ module Gitlab # :skip is the number of commits to skip # :order is the commits order and allowed value is :none (default), :date, # :topo, or any combination of them (in an array). Commit ordering types - # are documented here: - # http://www.rubydoc.info/github/libgit2/rugged/Rugged#SORT_NONE-constant) + # are documented here: https://git-scm.com/docs/git-log#_commit_ordering def find_all(repo, options = {}) wrapped_gitaly_errors do Gitlab::GitalyClient::CommitService.new(repo).find_all_commits(options) diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 15318bc817a..b981b9cf1bc 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -324,6 +324,7 @@ module Gitlab request.after = GitalyClient.timestamp(options[:after]) if options[:after] request.before = GitalyClient.timestamp(options[:before]) if options[:before] request.revision = encode_binary(options[:ref]) if options[:ref] + request.order = options[:order].upcase if options[:order].present? request.paths = encode_repeated(Array(options[:path])) if options[:path].present? diff --git a/lib/gitlab/project_authorizations.rb b/lib/gitlab/project_authorizations.rb index e2271b1492c..d65e8759ec9 100644 --- a/lib/gitlab/project_authorizations.rb +++ b/lib/gitlab/project_authorizations.rb @@ -68,12 +68,10 @@ module Gitlab .select([namespaces[:id], members[:access_level]]) .except(:order) - if Feature.enabled?(:share_group_with_group, default_enabled: true) - # Namespaces shared with any of the group - cte << Group.select([namespaces[:id], 'group_group_links.group_access AS access_level']) - .joins(join_group_group_links) - .joins(join_members_on_group_group_links) - end + # Namespaces shared with any of the group + cte << Group.select([namespaces[:id], 'group_group_links.group_access AS access_level']) + .joins(join_group_group_links) + .joins(join_members_on_group_group_links) # Sub groups of any groups the user is a member of. cte << Group.select([ @@ -114,6 +112,8 @@ module Gitlab members = Member.arel_table cond = group_group_links[:shared_with_group_id].eq(members[:source_id]) + .and(members[:source_type].eq('Namespace')) + .and(members[:requested_at].eq(nil)) .and(members[:user_id].eq(user.id)) Arel::Nodes::InnerJoin.new(members, Arel::Nodes::On.new(cond)) end |