debian-mirror-gitlab/app/graphql/resolvers/projects/fork_details_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
826 B
Ruby
Raw Normal View History

2023-03-04 22:38:38 +05:30
# frozen_string_literal: true
module Resolvers
module Projects
class ForkDetailsResolver < BaseResolver
type Types::Projects::ForkDetailsType, null: true
argument :ref, GraphQL::Types::String,
required: false,
description: 'Ref of the fork. Default value is HEAD.'
alias_method :project, :object
def resolve(**args)
return unless project.forked?
2023-05-27 22:25:52 +05:30
return unless authorized_fork_source?
return unless project.repository.branch_exists?(args[:ref])
return unless Feature.enabled?(:fork_divergence_counts, project)
2023-03-04 22:38:38 +05:30
2023-05-27 22:25:52 +05:30
::Projects::Forks::Details.new(project, args[:ref])
end
private
def authorized_fork_source?
Ability.allowed?(current_user, :read_code, project.fork_source)
2023-03-04 22:38:38 +05:30
end
end
end
end