diff --git a/.rubocop_todo/layout/argument_alignment.yml b/.rubocop_todo/layout/argument_alignment.yml index 09f403fccd4f5a306350a1cce907dc10c121e7d2..d64b76a82be1af9f1e979ad64258d1c99d21aa6f 100644 --- a/.rubocop_todo/layout/argument_alignment.yml +++ b/.rubocop_todo/layout/argument_alignment.yml @@ -193,19 +193,6 @@ Layout/ArgumentAlignment: - 'lib/api/ci/resource_groups.rb' - 'lib/api/ci/runner.rb' - 'lib/api/ci/runners.rb' - - 'lib/api/ci/triggers.rb' - - 'lib/api/commit_statuses.rb' - - 'lib/api/commits.rb' - - 'lib/api/concerns/packages/debian_distribution_endpoints.rb' - - 'lib/api/concerns/packages/npm_endpoints.rb' - - 'lib/api/container_repositories.rb' - - 'lib/api/dependency_proxy.rb' - - 'lib/api/deploy_keys.rb' - - 'lib/api/deploy_tokens.rb' - - 'lib/api/deployments.rb' - - 'lib/api/entities/application.rb' - - 'lib/api/entities/application_statistics.rb' - - 'lib/api/entities/branch.rb' - 'lib/api/entities/npm_package.rb' - 'lib/api/entities/nuget/dependency_group.rb' - 'lib/api/entities/nuget/package_metadata.rb' diff --git a/lib/api/ci/triggers.rb b/lib/api/ci/triggers.rb index 2ff5fae671a5b819244cabd31126417647e9f494..e1fa0061a6c7915a6c4a2c77917e5d9bf784dbac 100644 --- a/lib/api/ci/triggers.rb +++ b/lib/api/ci/triggers.rb @@ -12,7 +12,7 @@ class Triggers < ::API::Base params do requires :id, types: [String, Integer], desc: 'The ID or URL-encoded path of the project', - documentation: { example: 18 } + documentation: { example: 18 } end resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do desc 'Trigger a GitLab project pipeline' do @@ -26,11 +26,11 @@ class Triggers < ::API::Base end params do requires :ref, type: String, desc: 'The commit sha or name of a branch or tag', allow_blank: false, - documentation: { example: 'develop' } + documentation: { example: 'develop' } requires :token, type: String, desc: 'The unique token of trigger or job token', - documentation: { example: '6d056f63e50fe6f8c5f8f4aa10edb7' } + documentation: { example: '6d056f63e50fe6f8c5f8f4aa10edb7' } optional :variables, type: Hash, desc: 'The list of variables to be injected into build', - documentation: { example: { VAR1: "value1", VAR2: "value2" } } + documentation: { example: { VAR1: "value1", VAR2: "value2" } } end post ":id/(ref/:ref/)trigger/pipeline", requirements: { ref: /.+/ } do Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20758') @@ -111,7 +111,7 @@ class Triggers < ::API::Base end params do requires :description, type: String, desc: 'The trigger token description', - documentation: { example: 'my trigger token description' } + documentation: { example: 'my trigger token description' } end post ':id/triggers' do authenticate! diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index 62b2885f955984472ce6a4ba0394eaef0b70b37f..62badec6570d579f54e6d94774bbc81bae48e83f 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -59,21 +59,21 @@ class CommitStatuses < ::API::Base end params do requires :sha, type: String, desc: 'The commit hash', - documentation: { example: '18f3e63d05582537db6d183d9d557be09e1f90c8' } + documentation: { example: '18f3e63d05582537db6d183d9d557be09e1f90c8' } requires :state, type: String, desc: 'The state of the status', - values: %w[pending running success failed canceled], - documentation: { example: 'pending' } + values: %w[pending running success failed canceled], + documentation: { example: 'pending' } optional :ref, type: String, desc: 'The ref', - documentation: { example: 'develop' } + documentation: { example: 'develop' } optional :target_url, type: String, desc: 'The target URL to associate with this status', - documentation: { example: 'https://gitlab.example.com/janedoe/gitlab-foss/builds/91' } + documentation: { example: 'https://gitlab.example.com/janedoe/gitlab-foss/builds/91' } optional :description, type: String, desc: 'A short description of the status' optional :name, type: String, desc: 'A string label to differentiate this status from the status of other systems', - documentation: { example: 'coverage', default: 'default' } + documentation: { example: 'coverage', default: 'default' } optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems', - documentation: { example: 'coverage', default: 'default' } + documentation: { example: 'coverage', default: 'default' } optional :coverage, type: Float, desc: 'The total code coverage', - documentation: { example: 100.0 } + documentation: { example: 100.0 } optional :pipeline_id, type: Integer, desc: 'An existing pipeline ID, when multiple pipelines on the same commit SHA have been triggered' end # rubocop: disable CodeReuse/ActiveRecord diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 0612b41edf8c978a72d9244f67dbb4cca0e77e4d..433eb53e5b3a42e7863a699eb48372a14f2bbea1 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -63,25 +63,25 @@ def track_commit_events end params do optional :ref_name, - type: String, - desc: 'The name of a repository branch or tag, if not given the default branch is used', - documentation: { example: 'v1.1.0' } + type: String, + desc: 'The name of a repository branch or tag, if not given the default branch is used', + documentation: { example: 'v1.1.0' } optional :since, - type: DateTime, - desc: 'Only commits after or on this date will be returned', - documentation: { example: '2021-09-20T11:50:22.001' } + type: DateTime, + desc: 'Only commits after or on this date will be returned', + documentation: { example: '2021-09-20T11:50:22.001' } optional :until, - type: DateTime, - desc: 'Only commits before or on this date will be returned', - documentation: { example: '2021-09-20T11:50:22.001' } + type: DateTime, + desc: 'Only commits before or on this date will be returned', + documentation: { example: '2021-09-20T11:50:22.001' } optional :path, - type: String, - desc: 'The file path', - documentation: { example: 'README.md' } + type: String, + desc: 'The file path', + documentation: { example: 'README.md' } optional :author, - type: String, - desc: 'Search commits by commit author', - documentation: { example: 'John Smith' } + type: String, + desc: 'Search commits by commit author', + documentation: { example: 'John Smith' } 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' @@ -108,16 +108,16 @@ def track_commit_events author = params[:author] commits = user_project.repository.commits(ref, - path: path, - limit: limit, - offset: offset, - before: before, - after: after, - all: all, - first_parent: first_parent, - order: order, - author: author, - trailers: params[:trailers]) + path: path, + limit: limit, + offset: offset, + before: before, + after: after, + all: all, + first_parent: first_parent, + order: order, + author: author, + trailers: params[:trailers]) serializer = with_stats ? Entities::CommitWithStats : Entities::Commit @@ -143,49 +143,49 @@ def track_commit_events end params do requires :branch, - type: String, - desc: 'Name of the branch to commit into. To create a new branch, also provide either `start_branch` or `start_sha`, and optionally `start_project`.', - allow_blank: false, - documentation: { example: 'master' } + type: String, + desc: 'Name of the branch to commit into. To create a new branch, also provide either `start_branch` or `start_sha`, and optionally `start_project`.', + allow_blank: false, + documentation: { example: 'master' } requires :commit_message, - type: String, - desc: 'Commit message', - documentation: { example: 'initial commit' } + type: String, + desc: 'Commit message', + documentation: { example: 'initial commit' } requires :actions, - type: Array, - desc: 'Actions to perform in commit' do + type: Array, + desc: 'Actions to perform in commit' do requires :action, - type: String, - desc: 'The action to perform, `create`, `delete`, `move`, `update`, `chmod`', values: %w[create update move delete chmod].freeze, - allow_blank: false + type: String, + desc: 'The action to perform, `create`, `delete`, `move`, `update`, `chmod`', values: %w[create update move delete chmod].freeze, + allow_blank: false requires :file_path, - type: String, - desc: 'Full path to the file.', - documentation: { example: 'lib/class.rb' } + type: String, + desc: 'Full path to the file.', + documentation: { example: 'lib/class.rb' } given action: ->(action) { action == 'move' } do requires :previous_path, - type: String, - desc: 'Original full path to the file being moved.', - documentation: { example: 'lib/class.rb' } + type: String, + desc: 'Original full path to the file being moved.', + documentation: { example: 'lib/class.rb' } end given action: ->(action) { %w[create move].include? action } do optional :content, - type: String, - desc: 'File content', - documentation: { example: 'Some file content' } + type: String, + desc: 'File content', + documentation: { example: 'Some file content' } end given action: ->(action) { action == 'update' } do requires :content, - type: String, - desc: 'File content', - documentation: { example: 'Some file content' } + type: String, + desc: 'File content', + documentation: { example: 'Some file content' } end optional :encoding, type: String, desc: '`text` or `base64`', default: 'text', values: %w[text base64] given action: ->(action) { %w[update move delete].include? action } do optional :last_commit_id, - type: String, - desc: 'Last known file commit id', - documentation: { example: '2695effb5807a22ff3d138d593fd856244e155e7' } + type: String, + desc: 'Last known file commit id', + documentation: { example: '2695effb5807a22ff3d138d593fd856244e155e7' } end given action: ->(action) { action == 'chmod' } do requires :execute_filemode, type: Boolean, desc: 'When `true/false` enables/disables the execute flag on the file.' @@ -193,27 +193,27 @@ def track_commit_events end optional :start_branch, - type: String, - desc: 'Name of the branch to start the new branch from', - documentation: { example: 'staging' } + type: String, + desc: 'Name of the branch to start the new branch from', + documentation: { example: 'staging' } optional :start_sha, - type: String, - desc: 'SHA of the commit to start the new branch from', - documentation: { example: '2695effb5807a22ff3d138d593fd856244e155e7' } + type: String, + desc: 'SHA of the commit to start the new branch from', + documentation: { example: '2695effb5807a22ff3d138d593fd856244e155e7' } mutually_exclusive :start_branch, :start_sha optional :start_project, - types: [Integer, String], - desc: 'The ID or path of the project to start the new branch from', - documentation: { example: 1 } + types: [Integer, String], + desc: 'The ID or path of the project to start the new branch from', + documentation: { example: 1 } optional :author_email, - type: String, - desc: 'Author email for commit', - documentation: { example: 'janedoe@example.com' } + type: String, + desc: 'Author email for commit', + documentation: { example: 'janedoe@example.com' } optional :author_name, - type: String, - desc: 'Author name for commit', - documentation: { example: 'Jane Doe' } + type: String, + desc: 'Author name for commit', + documentation: { example: 'Jane Doe' } optional :stats, type: Boolean, default: true, desc: 'Include commit stats' optional :force, type: Boolean, default: false, desc: 'When `true` overwrites the target branch with a new commit based on the `start_branch` or `start_sha`' end @@ -342,15 +342,15 @@ def track_commit_events params do requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag to be cherry picked' requires :branch, - type: String, - desc: 'The name of the branch', - allow_blank: false, - documentation: { example: 'master' } + type: String, + desc: 'The name of the branch', + allow_blank: false, + documentation: { example: 'master' } optional :dry_run, type: Boolean, default: false, desc: "Does not commit any changes" optional :message, - type: String, - desc: 'A custom commit message to use for the picked commit', - documentation: { example: 'Initial commit' } + type: String, + desc: 'A custom commit message to use for the picked commit', + documentation: { example: 'Initial commit' } end post ':id/repository/commits/:sha/cherry_pick', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do authorize_push_to_branch!(params[:branch]) @@ -400,10 +400,10 @@ def track_commit_events params do requires :sha, type: String, desc: 'Commit SHA to revert' requires :branch, - type: String, - desc: 'Target branch name', - allow_blank: false, - documentation: { example: 'master' } + type: String, + desc: 'Target branch name', + allow_blank: false, + documentation: { example: 'master' } optional :dry_run, type: Boolean, default: false, desc: "Does not commit any changes" end post ':id/repository/commits/:sha/revert', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do @@ -478,18 +478,18 @@ def track_commit_events params do requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag on which to post a comment' requires :note, - type: String, - desc: 'The text of the comment', - documentation: { example: 'Nice code!' } + type: String, + desc: 'The text of the comment', + documentation: { example: 'Nice code!' } optional :path, - type: String, - desc: 'The file path', - documentation: { example: 'doc/update/5.4-to-6.0.md' } + type: String, + desc: 'The file path', + documentation: { example: 'doc/update/5.4-to-6.0.md' } given :path do requires :line, - type: Integer, - desc: 'The line number', - documentation: { example: 11 } + type: Integer, + desc: 'The line number', + documentation: { example: 11 } requires :line_type, type: String, values: %w[new old], default: 'new', desc: 'The type of the line' end end diff --git a/lib/api/concerns/packages/debian_distribution_endpoints.rb b/lib/api/concerns/packages/debian_distribution_endpoints.rb index 7aad3a5642286d915abb2b4ec3b235358a0ee37d..725c4c9f71f1fe286c01781f361ee5ab9fa6482e 100644 --- a/lib/api/concerns/packages/debian_distribution_endpoints.rb +++ b/lib/api/concerns/packages/debian_distribution_endpoints.rb @@ -33,15 +33,15 @@ def distribution optional :valid_time_duration_seconds, type: Integer, desc: 'The duration before the Release file should be considered expired by the client', documentation: { example: 604800 } optional :components, type: Array[String], - coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, - regexp: Gitlab::Regex.debian_component_regex, - desc: 'The list of Components', - documentation: { example: 'main' } + coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, + regexp: Gitlab::Regex.debian_component_regex, + desc: 'The list of Components', + documentation: { example: 'main' } optional :architectures, type: Array[String], - coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, - regexp: Gitlab::Regex.debian_architecture_regex, - desc: 'The list of Architectures', - documentation: { example: 'amd64' } + coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, + regexp: Gitlab::Regex.debian_architecture_regex, + desc: 'The list of Architectures', + documentation: { example: 'amd64' } end end diff --git a/lib/api/concerns/packages/npm_endpoints.rb b/lib/api/concerns/packages/npm_endpoints.rb index 69d23c408ab8a8f488371e0aeda793c9ed7325dc..24503f2e33e86721373028470c969651a2db2117 100644 --- a/lib/api/concerns/packages/npm_endpoints.rb +++ b/lib/api/concerns/packages/npm_endpoints.rb @@ -83,7 +83,7 @@ def metadata_cache tags %w[npm_packages] end route_setting :authentication, job_token_allowed: true, deploy_token_allowed: true, - authenticate_non_public: true + authenticate_non_public: true get 'dist-tags', format: false, requirements: ::API::Helpers::Packages::Npm::NPM_ENDPOINT_REQUIREMENTS do package_name = params[:package_name] @@ -198,7 +198,7 @@ def metadata_cache use :package_name end route_setting :authentication, job_token_allowed: true, deploy_token_allowed: true, - authenticate_non_public: true + authenticate_non_public: true get '*package_name', format: false, requirements: ::API::Helpers::Packages::Npm::NPM_ENDPOINT_REQUIREMENTS do package_name = params[:package_name] available_packages = diff --git a/lib/api/container_repositories.rb b/lib/api/container_repositories.rb index b6b5fe1033276db6e91fd98aee451ac475868e70..1d4d36ac3cf6d7ea80f56dd65807e1eaf9a412e5 100644 --- a/lib/api/container_repositories.rb +++ b/lib/api/container_repositories.rb @@ -35,11 +35,11 @@ class ContainerRepositories < ::API::Base authorize!(:read_container_image, repository) present repository, - with: Entities::ContainerRegistry::Repository, - tags: params[:tags], - tags_count: params[:tags_count], - size: params[:size], - user: current_user + with: Entities::ContainerRegistry::Repository, + tags: params[:tags], + tags_count: params[:tags_count], + size: params[:size], + user: current_user end end end diff --git a/lib/api/dependency_proxy.rb b/lib/api/dependency_proxy.rb index 9ab96d4463a150726461fad502e7506bb680d827..5e6d33fbd9839c9b7cb3bc9f5a490d10b74632fb 100644 --- a/lib/api/dependency_proxy.rb +++ b/lib/api/dependency_proxy.rb @@ -13,7 +13,7 @@ class DependencyProxy < ::API::Base params do requires :id, types: [String, Integer], - desc: 'The ID or URL-encoded path of the group owned by the authenticated user' + desc: 'The ID or URL-encoded path of the group owned by the authenticated user' end resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do desc 'Purge the dependency proxy for a group' do diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 1cf1228b21081c59c38dc4d9264c9a14f64d0a81..c238300af74bc11194e6e900297bd09fe12baf43 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -199,7 +199,7 @@ def find_by_deploy_key(project, key_id) end post ":id/deploy_keys/:key_id/enable" do key = ::Projects::EnableDeployKeyService.new(user_project, - current_user, declared_params).execute + current_user, declared_params).execute if key present key, with: Entities::DeployKey diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb index 975a65af28599be5c1d52b67c348aa6bf80ccd02..78f55d188bc84dc81ce3df65aa7ded570a90c27c 100644 --- a/lib/api/deploy_tokens.rb +++ b/lib/api/deploy_tokens.rb @@ -87,10 +87,10 @@ def scope_params params do requires :name, type: String, desc: "New deploy token's name" requires :scopes, - type: Array[String], - coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, - values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s), - desc: 'Indicates the deploy token scopes. Must be at least one of `read_repository`, `read_registry`, `write_registry`, `read_package_registry`, or `write_package_registry`.' + type: Array[String], + coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, + values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s), + desc: 'Indicates the deploy token scopes. Must be at least one of `read_repository`, `read_registry`, `write_registry`, `read_package_registry`, or `write_package_registry`.' optional :expires_at, type: DateTime, desc: 'Expiration date for the deploy token. Does not expire if no value is provided. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`).' optional :username, type: String, desc: 'Username for deploy token. Default is `gitlab+deploy-token-{n}`' end @@ -194,10 +194,10 @@ def scope_params params do requires :name, type: String, desc: "New deploy token's name" requires :scopes, - type: Array[String], - coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, - values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s), - desc: 'Indicates the deploy token scopes. Must be at least one of `read_repository`, `read_registry`, `write_registry`, `read_package_registry`, or `write_package_registry`' + type: Array[String], + coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, + values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s), + desc: 'Indicates the deploy token scopes. Must be at least one of `read_repository`, `read_registry`, `write_registry`, `read_package_registry`, or `write_package_registry`' optional :expires_at, type: DateTime, desc: 'Expiration date for the deploy token. Does not expire if no value is provided. Expected in ISO 8601 format (`2019-03-15T08:00:00Z`)' optional :username, type: String, desc: 'Username for deploy token. Default is `gitlab+deploy-token-{n}`' end diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb index 1468164081c17bebfe72b38e3997ca291c7148db..ad67038584f9165983731186ec6f1aed0338e15f 100644 --- a/lib/api/deployments.rb +++ b/lib/api/deployments.rb @@ -176,9 +176,9 @@ class Deployments < ::API::Base end params do requires :status, - type: String, - desc: 'The new status of the deployment. One of `running`, `success`, `failed`, or `canceled`', - values: %w[running success failed canceled] + type: String, + desc: 'The new status of the deployment. One of `running`, `success`, `failed`, or `canceled`', + values: %w[running success failed canceled] end route_setting :authentication, job_token_allowed: true put ':id/deployments/:deployment_id' do diff --git a/lib/api/entities/application.rb b/lib/api/entities/application.rb index c3d8f9667c377310e7566c0dc44e7856fa324f79..4eacb7d8c15eab27c32b0540954e4e0f0548aade 100644 --- a/lib/api/entities/application.rb +++ b/lib/api/entities/application.rb @@ -5,8 +5,8 @@ module Entities class Application < Grape::Entity expose :id expose :uid, as: :application_id, - documentation: { type: 'string', - example: '5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737' } + documentation: { type: 'string', + example: '5832fc6e14300a0d962240a8144466eef4ee93ef0d218477e55f11cf12fc3737' } expose :name, as: :application_name, documentation: { type: 'string', example: 'MyApplication' } expose :redirect_uri, as: :callback_url, documentation: { type: 'string', example: 'https://redirect.uri' } expose :confidential, documentation: { type: 'boolean', example: true } diff --git a/lib/api/entities/application_statistics.rb b/lib/api/entities/application_statistics.rb index 7e75ef236752f719c22a04e28c9dfdd51c9afc1f..128da3eb3c101eddf3c8fbf92359b707268af829 100644 --- a/lib/api/entities/application_statistics.rb +++ b/lib/api/entities/application_statistics.rb @@ -7,37 +7,37 @@ class ApplicationStatistics < Grape::Entity include CountHelper expose :forks, - documentation: { type: 'integer', example: 6, desc: 'Approximate number of repo forks' } do |counts| + documentation: { type: 'integer', example: 6, desc: 'Approximate number of repo forks' } do |counts| approximate_fork_count_with_delimiters(counts) end expose :issues, - documentation: { type: 'integer', example: 121, desc: 'Approximate number of issues' } do |counts| + documentation: { type: 'integer', example: 121, desc: 'Approximate number of issues' } do |counts| approximate_count_with_delimiters(counts, ::Issue) end expose :merge_requests, - documentation: { type: 'integer', example: 49, desc: 'Approximate number of merge requests' } do |counts| + documentation: { type: 'integer', example: 49, desc: 'Approximate number of merge requests' } do |counts| approximate_count_with_delimiters(counts, ::MergeRequest) end expose :notes, - documentation: { type: 'integer', example: 6, desc: 'Approximate number of notes' } do |counts| + documentation: { type: 'integer', example: 6, desc: 'Approximate number of notes' } do |counts| approximate_count_with_delimiters(counts, ::Note) end expose :snippets, - documentation: { type: 'integer', example: 4, desc: 'Approximate number of snippets' } do |counts| + documentation: { type: 'integer', example: 4, desc: 'Approximate number of snippets' } do |counts| approximate_count_with_delimiters(counts, ::Snippet) end expose :ssh_keys, - documentation: { type: 'integer', example: 11, desc: 'Approximate number of SSH keys' } do |counts| + documentation: { type: 'integer', example: 11, desc: 'Approximate number of SSH keys' } do |counts| approximate_count_with_delimiters(counts, ::Key) end expose :milestones, - documentation: { type: 'integer', example: 3, desc: 'Approximate number of milestones' } do |counts| + documentation: { type: 'integer', example: 3, desc: 'Approximate number of milestones' } do |counts| approximate_count_with_delimiters(counts, ::Milestone) end @@ -46,17 +46,17 @@ class ApplicationStatistics < Grape::Entity end expose :projects, - documentation: { type: 'integer', example: 4, desc: 'Approximate number of projects' } do |counts| + documentation: { type: 'integer', example: 4, desc: 'Approximate number of projects' } do |counts| approximate_count_with_delimiters(counts, ::Project) end expose :groups, - documentation: { type: 'integer', example: 1, desc: 'Approximate number of projects' } do |counts| + documentation: { type: 'integer', example: 1, desc: 'Approximate number of projects' } do |counts| approximate_count_with_delimiters(counts, ::Group) end expose :active_users, - documentation: { type: 'integer', example: 21, desc: 'Number of active users' } do |_| + documentation: { type: 'integer', example: 21, desc: 'Number of active users' } do |_| number_with_delimiter(::User.active.count) end end diff --git a/lib/api/entities/branch.rb b/lib/api/entities/branch.rb index 01eaf5c8d31ffa4f4305c0f8d39283a60fc01967..7a6a3da6e696ca72cdbaad74c2b267342994869f 100644 --- a/lib/api/entities/branch.rb +++ b/lib/api/entities/branch.rb @@ -12,10 +12,10 @@ class Branch < Grape::Entity end expose :merged, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| if options[:merged_branch_names] options[:merged_branch_names].include?(repo_branch.name) else @@ -24,50 +24,50 @@ class Branch < Grape::Entity end expose :protected, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| ::ProtectedBranch.protected?(options[:project], repo_branch.name) end expose :developers_can_push, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| ::ProtectedBranch.developers_can?(:push, repo_branch.name, protected_refs: options[:project].protected_branches) end expose :developers_can_merge, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| ::ProtectedBranch.developers_can?(:merge, repo_branch.name, protected_refs: options[:project].protected_branches) end expose :can_push, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| Gitlab::UserAccess.new(options[:current_user], container: options[:project]).can_push_to_branch?(repo_branch.name) end expose :default, - documentation: { - type: 'boolean', - example: true - } do |repo_branch, options| + documentation: { + type: 'boolean', + example: true + } do |repo_branch, options| options[:project].default_branch == repo_branch.name end expose :web_url, - documentation: { - type: 'string', - example: 'https://gitlab.example.com/Commit921/the-dude/-/tree/master' - } do |repo_branch| + documentation: { + type: 'string', + example: 'https://gitlab.example.com/Commit921/the-dude/-/tree/master' + } do |repo_branch| project_tree_url(options[:project], repo_branch.name) end end