gitlab-org--gitlab-foss/lib/gitlab/submodule_links.rb
Igor 0f46886880 Added submodule links to Submodule type in GraphQL API
This is part of migration of Folder View to Vue
2019-07-17 13:06:19 +00:00

26 lines
565 B
Ruby

# frozen_string_literal: true
module Gitlab
class SubmoduleLinks
include Gitlab::Utils::StrongMemoize
def initialize(repository)
@repository = repository
end
def for(submodule, sha)
submodule_url = submodule_url_for(sha)[submodule.path]
SubmoduleHelper.submodule_links_for_url(submodule.id, submodule_url, repository)
end
private
attr_reader :repository
def submodule_url_for(sha)
strong_memoize(:"submodule_links_for_#{sha}") do
repository.submodule_urls_for(sha)
end
end
end
end