Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-02-20 21:08:48 +00:00
parent df2eda3f14
commit 4d0c47058a
11 changed files with 102 additions and 7 deletions

View File

@ -381,6 +381,14 @@ module ProjectsHelper
@project.grafana_integration&.enabled?
end
def project_license_name(project)
project.repository.license&.name
rescue GRPC::Unavailable, GRPC::DeadlineExceeded, Gitlab::Git::CommandError => e
Gitlab::ErrorTracking.track_exception(e)
nil
end
private
def get_project_nav_tabs(project, current_user)

View File

@ -14,6 +14,7 @@
- updated_tooltip = time_ago_with_tooltip(project.last_activity_date)
- css_controls_class = compact_mode ? [] : ["flex-lg-row", "justify-content-lg-between"]
- avatar_container_class = project.creator && use_creator_avatar ? '' : 'rect-avatar'
- license_name = project_license_name(project)
%li.project-row.d-flex{ class: css_class }
= cache(cache_key) do
@ -40,10 +41,10 @@
%span.metadata-info.visibility-icon.append-right-10.prepend-top-8.text-secondary.has-tooltip{ data: { container: 'body', placement: 'top' }, title: visibility_icon_description(project) }
= visibility_level_icon(project.visibility_level, fw: true)
- if explore_projects_tab? && project.repository.license
- if explore_projects_tab? && license_name
%span.metadata-info.d-inline-flex.align-items-center.append-right-10.prepend-top-8
= sprite_icon('scale', size: 14, css_class: 'append-right-4')
= project.repository.license.name
= license_name
- if !explore_projects_tab? && access&.nonzero?
-# haml-lint:disable UnnecessaryStringOutput

View File

@ -0,0 +1,5 @@
---
title: Handle Gitaly failure when fetching license
merge_request: 24310
author:
type: fixed

View File

@ -285,6 +285,13 @@ module Gitlab
g.factory_bot false
end
# This empty initializer forces the :let_zeitwerk_take_over initializer to run before we load
# initializers in config/initializers. This is done because autoloading before Zeitwerk takes
# over is deprecated but our initializers do a lot of autoloading.
# See https://gitlab.com/gitlab-org/gitlab/issues/197346 for more details
initializer :move_initializers, before: :load_config_initializers, after: :let_zeitwerk_take_over do
end
config.after_initialize do
Rails.application.reload_routes!

View File

@ -1,3 +1,6 @@
require 'gitlab/testing/request_blocker_middleware'
require 'gitlab/testing/request_inspector_middleware'
Rails.application.configure do
# Make sure the middleware is inserted first in middleware chain
config.middleware.insert_before(ActionDispatch::Static, Gitlab::Testing::RequestBlockerMiddleware)

View File

@ -6,8 +6,6 @@ GraphQL::Field.accepts_definitions(authorize: GraphQL::Define.assign_metadata_ke
GraphQL::Schema::Object.accepts_definition(:authorize)
GraphQL::Schema::Field.accepts_definition(:authorize)
Gitlab::Application.config.after_initialize do
GitlabSchema.middleware << GraphQL::Schema::TimeoutMiddleware.new(max_seconds: Gitlab.config.gitlab.graphql_timeout) do |timeout_error, query|
Gitlab::GraphqlLogger.error(message: timeout_error.to_s, query: query.query_string, query_variables: query.provided_variables)
end
GitlabSchema.middleware << GraphQL::Schema::TimeoutMiddleware.new(max_seconds: Gitlab.config.gitlab.graphql_timeout) do |timeout_error, query|
Gitlab::GraphqlLogger.error(message: timeout_error.to_s, query: query.query_string, query_variables: query.provided_variables)
end

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
class AddAutoRenewToGitlabSubscriptions < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :gitlab_subscription_histories, :auto_renew, :boolean
add_column :gitlab_subscriptions, :auto_renew, :boolean
end
end

View File

@ -1912,6 +1912,7 @@ ActiveRecord::Schema.define(version: 2020_02_14_034836) do
t.bigint "gitlab_subscription_id", null: false
t.datetime_with_timezone "created_at"
t.date "trial_starts_on"
t.boolean "auto_renew"
t.index ["gitlab_subscription_id"], name: "index_gitlab_subscription_histories_on_gitlab_subscription_id"
end
@ -1927,6 +1928,7 @@ ActiveRecord::Schema.define(version: 2020_02_14_034836) do
t.integer "seats", default: 0
t.boolean "trial", default: false
t.date "trial_starts_on"
t.boolean "auto_renew"
t.index ["hosted_plan_id"], name: "index_gitlab_subscriptions_on_hosted_plan_id"
t.index ["namespace_id"], name: "index_gitlab_subscriptions_on_namespace_id", unique: true
end

View File

@ -3,7 +3,7 @@
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/36146) in GitLab 12.9.
> - Using this API you can consume GitLab's [Merge Train](../ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md) entries.
Every API call to merge trains must be authenticated with Developer or higher [permissions](link-to-permissions-doc).
Every API call to merge trains must be authenticated with Developer or higher [permissions](../user/permissions.md).
If a user is not a member of a project and the project is private, a `GET` request on that project will result to a `404` status code.

View File

@ -6303,6 +6303,9 @@ msgstr ""
msgid "Dependency List"
msgstr ""
msgid "Dependency List has no entries"
msgstr ""
msgid "Dependency Proxy"
msgstr ""
@ -10822,6 +10825,9 @@ msgstr ""
msgid "It must have a header row and at least two columns: the first column is the issue title and the second column is the issue description. The separator is automatically detected."
msgstr ""
msgid "It seems like the Dependency Scanning job ran successfully, but no dependencies have been detected in your project."
msgstr ""
msgid "It's you"
msgstr ""
@ -21516,6 +21522,9 @@ msgstr ""
msgid "View replaced file @ "
msgstr ""
msgid "View supported languages and frameworks"
msgstr ""
msgid "View the documentation"
msgstr ""

View File

@ -994,4 +994,56 @@ describe ProjectsHelper do
it { is_expected.to eq(grafana_integration.enabled) }
end
end
describe '#project_license_name(project)' do
let_it_be(:project) { create(:project) }
let_it_be(:repository) { project.repository }
subject { project_license_name(project) }
context 'gitaly is working appropriately' do
it 'returns the license name' do
license = Licensee::License.new('mit')
allow(repository).to receive(:license).and_return(license)
expect(subject).to eq(license.name)
end
end
context 'gitaly is unreachable' do
shared_examples 'returns nil and tracks exception' do
it { is_expected.to be_nil }
it 'tracks the exception' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(exception)
)
subject
end
end
before do
allow(repository).to receive(:license).and_raise(exception)
end
context "Gitlab::Git::CommandError" do
let(:exception) { Gitlab::Git::CommandError }
it_behaves_like 'returns nil and tracks exception'
end
context "GRPC::Unavailable" do
let(:exception) { GRPC::Unavailable }
it_behaves_like 'returns nil and tracks exception'
end
context "GRPC::DeadlineExceeded" do
let(:exception) { GRPC::DeadlineExceeded }
it_behaves_like 'returns nil and tracks exception'
end
end
end
end