Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 09:08:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 09:08:33 +0300
commitef19a5c55c0f38b29f7ac98119041b054c6579c7 (patch)
treea622280b300c5d17a2af0a59ea9b2fa6a663d13c /app
parentaed2039d57b51847981e160cf7a1915f3ef490aa (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/pipelines/application_controller.rb24
-rw-r--r--app/graphql/types/project_type.rb3
-rw-r--r--app/graphql/types/release_assets_type.rb3
-rw-r--r--app/graphql/types/release_link_type.rb1
-rw-r--r--app/graphql/types/release_source_type.rb3
-rw-r--r--app/graphql/types/release_type.rb12
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/policies/releases/source_policy.rb6
-rw-r--r--app/presenters/release_presenter.rb14
9 files changed, 53 insertions, 17 deletions
diff --git a/app/controllers/projects/pipelines/application_controller.rb b/app/controllers/projects/pipelines/application_controller.rb
new file mode 100644
index 00000000000..92887750813
--- /dev/null
+++ b/app/controllers/projects/pipelines/application_controller.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+# Abstract class encapsulating common logic for creating new controllers in a pipeline context
+
+module Projects
+ module Pipelines
+ class ApplicationController < Projects::ApplicationController
+ include Gitlab::Utils::StrongMemoize
+
+ before_action :pipeline
+ before_action :authorize_read_pipeline!
+
+ private
+
+ def pipeline
+ strong_memoize(:pipeline) do
+ project.all_pipelines.find(params[:pipeline_id]).tap do |pipeline|
+ render_404 unless can?(current_user, :read_pipeline, pipeline)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb
index bbfb7fc4f20..f83faa36396 100644
--- a/app/graphql/types/project_type.rb
+++ b/app/graphql/types/project_type.rb
@@ -251,7 +251,8 @@ module Types
null: true,
description: 'A single release of the project',
resolver: Resolvers::ReleasesResolver.single,
- feature_flag: :graphql_release_data
+ feature_flag: :graphql_release_data,
+ authorize: :download_code
field :container_expiration_policy,
Types::ContainerExpirationPolicyType,
diff --git a/app/graphql/types/release_assets_type.rb b/app/graphql/types/release_assets_type.rb
index 58ad05b5365..45bfe5fe06f 100644
--- a/app/graphql/types/release_assets_type.rb
+++ b/app/graphql/types/release_assets_type.rb
@@ -3,6 +3,7 @@
module Types
class ReleaseAssetsType < BaseObject
graphql_name 'ReleaseAssets'
+ description 'A container for all assets associated with a release'
authorize :read_release
@@ -10,7 +11,7 @@ module Types
present_using ReleasePresenter
- field :assets_count, GraphQL::INT_TYPE, null: true,
+ field :count, GraphQL::INT_TYPE, null: true, method: :assets_count,
description: 'Number of assets of the release'
field :links, Types::ReleaseLinkType.connection_type, null: true,
description: 'Asset links of the release'
diff --git a/app/graphql/types/release_link_type.rb b/app/graphql/types/release_link_type.rb
index 070f14a90df..00fd05f6f7e 100644
--- a/app/graphql/types/release_link_type.rb
+++ b/app/graphql/types/release_link_type.rb
@@ -3,6 +3,7 @@
module Types
class ReleaseLinkType < BaseObject
graphql_name 'ReleaseLink'
+ description 'Represents an asset link associated with a release'
authorize :read_release
diff --git a/app/graphql/types/release_source_type.rb b/app/graphql/types/release_source_type.rb
index 0ec1ad85a39..891da472116 100644
--- a/app/graphql/types/release_source_type.rb
+++ b/app/graphql/types/release_source_type.rb
@@ -3,8 +3,9 @@
module Types
class ReleaseSourceType < BaseObject
graphql_name 'ReleaseSource'
+ description 'Represents the source code attached to a release in a particular format'
- authorize :read_release_sources
+ authorize :download_code
field :format, GraphQL::STRING_TYPE, null: true,
description: 'Format of the source'
diff --git a/app/graphql/types/release_type.rb b/app/graphql/types/release_type.rb
index 3d8e5a93c68..f900b476da9 100644
--- a/app/graphql/types/release_type.rb
+++ b/app/graphql/types/release_type.rb
@@ -3,6 +3,7 @@
module Types
class ReleaseType < BaseObject
graphql_name 'Release'
+ description 'Represents a release'
authorize :read_release
@@ -10,10 +11,12 @@ module Types
present_using ReleasePresenter
- field :tag_name, GraphQL::STRING_TYPE, null: false, method: :tag,
- description: 'Name of the tag associated with the release'
+ field :tag_name, GraphQL::STRING_TYPE, null: true, method: :tag,
+ description: 'Name of the tag associated with the release',
+ authorize: :download_code
field :tag_path, GraphQL::STRING_TYPE, null: true,
- description: 'Relative web path to the tag associated with the release'
+ description: 'Relative web path to the tag associated with the release',
+ authorize: :download_code
field :description, GraphQL::STRING_TYPE, null: true,
description: 'Description (also known as "release notes") of the release'
markdown_field :description_html, null: true
@@ -39,8 +42,7 @@ module Types
field :commit, Types::CommitType, null: true,
complexity: 10, calls_gitaly: true,
- description: 'The commit associated with the release',
- authorize: :reporter_access
+ description: 'The commit associated with the release'
def commit
return if release.sha.nil?
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 1bf7e257114..3e80456a6f2 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -27,7 +27,7 @@ module Ci
upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? },
refspecs: -> (build) { build.merge_request_ref? },
artifacts_exclude: -> (build) { build.supports_artifacts_exclude? },
- release_steps: -> (build) { build.release_steps? }
+ multi_build_steps: -> (build) { build.multi_build_steps? }
}.freeze
DEFAULT_RETRIES = {
@@ -890,7 +890,7 @@ module Ci
Gitlab::Ci::Features.artifacts_exclude_enabled?
end
- def release_steps?
+ def multi_build_steps?
options.dig(:release)&.any? &&
Gitlab::Ci::Features.release_generation_enabled?
end
diff --git a/app/policies/releases/source_policy.rb b/app/policies/releases/source_policy.rb
index 8b86b925589..3b11c661237 100644
--- a/app/policies/releases/source_policy.rb
+++ b/app/policies/releases/source_policy.rb
@@ -3,11 +3,5 @@
module Releases
class SourcePolicy < BasePolicy
delegate { @subject.project }
-
- rule { can?(:public_access) | can?(:reporter_access) }.policy do
- enable :read_release_sources
- end
-
- rule { ~can?(:read_release) }.prevent :read_release_sources
end
end
diff --git a/app/presenters/release_presenter.rb b/app/presenters/release_presenter.rb
index 7b0a3d1e7b9..4393ca05f48 100644
--- a/app/presenters/release_presenter.rb
+++ b/app/presenters/release_presenter.rb
@@ -5,7 +5,7 @@ class ReleasePresenter < Gitlab::View::Presenter::Delegated
presents :release
- delegate :project, :tag, :assets_count, to: :release
+ delegate :project, :tag, to: :release
def commit_path
return unless release.commit && can_download_code?
@@ -43,6 +43,18 @@ class ReleasePresenter < Gitlab::View::Presenter::Delegated
edit_project_release_url(project, release)
end
+ def assets_count
+ if can_download_code?
+ release.assets_count
+ else
+ release.assets_count(except: [:sources])
+ end
+ end
+
+ def name
+ can_download_code? ? release.name : "Release-#{release.id}"
+ end
+
private
def can_download_code?