File: blobs_remove.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (42 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Mutations
  module Projects
    class BlobsRemove < BaseMutation
      graphql_name 'projectBlobsRemove'

      include FindsProject

      EMPTY_BLOBS_OIDS_ARG = <<~ERROR
        Argument 'blobOids' on InputObject 'projectBlobsRemoveInput' is required. Expected type [String!]!
      ERROR

      authorize :owner_access

      argument :project_path, GraphQL::Types::ID,
        required: true,
        description: 'Full path of the project to replace.'

      argument :blob_oids, [GraphQL::Types::String],
        required: true,
        description: 'List of blob oids.',
        prepare: ->(blob_oids, _ctx) do
          blob_oids.reject!(&:blank?)

          break blob_oids if blob_oids.present?

          raise GraphQL::ExecutionError, EMPTY_BLOBS_OIDS_ARG
        end

      def resolve(project_path:, blob_oids:)
        project = authorized_find!(project_path)

        result = Repositories::RewriteHistoryService.new(project, current_user).async_execute(blob_oids: blob_oids)

        return { errors: result.errors } if result.error?

        { errors: [] }
      end
    end
  end
end