Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
d5823ee1cd
commit
a7f1e2ebd6
|
@ -13,7 +13,8 @@ export default class GpgBadges {
|
|||
|
||||
const badges = $('.js-loading-gpg-badge');
|
||||
|
||||
badges.html('<i class="fa fa-spinner fa-spin"></i>');
|
||||
badges.html('<span class="gl-spinner gl-spinner-orange gl-spinner-sm"></span>');
|
||||
badges.children().attr('aria-label', __('Loading'));
|
||||
|
||||
const displayError = () => createFlash(__('An error occurred while loading commit signatures'));
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Migrate '.fa-spinner' to '.spinner' for 'app/assets/javascripts/gpg_badges.js'
|
||||
merge_request: 41136
|
||||
author: Gilang Gumilar
|
||||
type: changed
|
|
@ -77,5 +77,3 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
::Gitlab::Ci::Features.prepend_if_ee('::EE::Gitlab::Ci::Features')
|
||||
|
|
|
@ -118,6 +118,10 @@ module QA
|
|||
run(%Q{git config user.signingkey #{@gpg_key_id} && git config gpg.program $(command -v gpg) && git commit -S -m "#{message}"}).to_s
|
||||
end
|
||||
|
||||
def current_branch
|
||||
run("git rev-parse --abbrev-ref HEAD").to_s
|
||||
end
|
||||
|
||||
def push_changes(branch = 'master')
|
||||
run("git push #{uri} #{branch}", max_attempts: 3).to_s
|
||||
end
|
||||
|
|
|
@ -13,6 +13,7 @@ module QA
|
|||
attr_writer :initialize_with_readme
|
||||
attr_writer :auto_devops_enabled
|
||||
|
||||
attribute :default_branch
|
||||
attribute :id
|
||||
attribute :name
|
||||
attribute :add_name_uuid
|
||||
|
|
|
@ -2,43 +2,39 @@
|
|||
|
||||
module QA
|
||||
module Runtime
|
||||
module ApplicationSettings
|
||||
extend self
|
||||
extend Support::Api
|
||||
class ApplicationSettings
|
||||
class << self
|
||||
include Support::Api
|
||||
|
||||
APPLICATION_SETTINGS_PATH = '/application/settings'
|
||||
APPLICATION_SETTINGS_PATH = '/application/settings'
|
||||
|
||||
# Set a GitLab application setting
|
||||
# Example:
|
||||
# #set({ allow_local_requests_from_web_hooks_and_services: true })
|
||||
# #set(allow_local_requests_from_web_hooks_and_services: true)
|
||||
# https://docs.gitlab.com/ee/api/settings.html
|
||||
def set_application_settings(**application_settings)
|
||||
QA::Runtime::Logger.info("Setting application settings: #{application_settings}")
|
||||
r = put(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url, **application_settings)
|
||||
raise "Couldn't set application settings #{application_settings.inspect}" unless r.code == QA::Support::Api::HTTP_STATUS_OK
|
||||
end
|
||||
# Set a GitLab application setting
|
||||
# Example:
|
||||
# #set({ allow_local_requests_from_web_hooks_and_services: true })
|
||||
# #set(allow_local_requests_from_web_hooks_and_services: true)
|
||||
# https://docs.gitlab.com/ee/api/settings.html
|
||||
def set_application_settings(**application_settings)
|
||||
@original_application_settings = get_application_settings
|
||||
|
||||
def get_application_settings
|
||||
parse_body(get(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url))
|
||||
end
|
||||
QA::Runtime::Logger.info("Setting application settings: #{application_settings}")
|
||||
r = put(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url, **application_settings)
|
||||
raise "Couldn't set application settings #{application_settings.inspect}" unless r.code == QA::Support::Api::HTTP_STATUS_OK
|
||||
end
|
||||
|
||||
private
|
||||
def get_application_settings
|
||||
parse_body(get(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url))
|
||||
end
|
||||
|
||||
def api_client
|
||||
@api_client ||= begin
|
||||
return Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.admin_personal_access_token) if Runtime::Env.admin_personal_access_token
|
||||
def restore_application_settings(*application_settings_keys)
|
||||
set_application_settings(@original_application_settings.slice(*application_settings_keys))
|
||||
end
|
||||
|
||||
user = Resource::User.fabricate_via_api! do |user|
|
||||
user.username = Runtime::User.admin_username
|
||||
user.password = Runtime::User.admin_password
|
||||
end
|
||||
private
|
||||
|
||||
unless user.admin?
|
||||
raise "Administrator access is required to set application settings. User '#{user.username}' is not an administrator."
|
||||
end
|
||||
|
||||
Runtime::API::Client.new(:gitlab, user: user)
|
||||
def api_client
|
||||
@api_client ||= Runtime::API::Client.as_admin
|
||||
rescue AuthorizationError => e
|
||||
raise "Administrator access is required to set application settings. #{e.message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'securerandom'
|
||||
|
||||
module QA
|
||||
RSpec.describe 'Create' do
|
||||
describe 'Default branch name instance setting', :requires_admin, :skip_live_env do
|
||||
before(:context) do
|
||||
Runtime::ApplicationSettings.set_application_settings(default_branch_name: 'main')
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Runtime::ApplicationSettings.restore_application_settings(:default_branch_name)
|
||||
end
|
||||
|
||||
it 'sets the default branch name for a new project' do
|
||||
project = Resource::Project.fabricate_via_api! do |project|
|
||||
project.name = "default-branch-name"
|
||||
project.initialize_with_readme = true
|
||||
end
|
||||
|
||||
# It takes a moment to create the project. We wait until we
|
||||
# know it exists before we try to clone it
|
||||
Support::Waiter.wait_until { project.has_file?('README.md') }
|
||||
|
||||
Git::Repository.perform do |repository|
|
||||
repository.uri = project.repository_http_location.uri
|
||||
repository.use_default_credentials
|
||||
repository.clone
|
||||
|
||||
expect(repository.current_branch).to eq('main')
|
||||
end
|
||||
end
|
||||
|
||||
it 'allows a project to be created via the CLI with a different default branch name' do
|
||||
project_name = "default-branch-name-via-cli-#{SecureRandom.hex(8)}"
|
||||
group = Resource::Group.fabricate_via_api!
|
||||
|
||||
Git::Repository.perform do |repository|
|
||||
repository.init_repository
|
||||
repository.uri = "#{Runtime::Scenario.gitlab_address}/#{group.full_path}/#{project_name}"
|
||||
repository.use_default_credentials
|
||||
repository.configure_identity('GitLab QA', 'root@gitlab.com')
|
||||
repository.checkout('trunk', new_branch: true)
|
||||
repository.commit_file('README.md', 'Created via the CLI', 'initial commit via CLI')
|
||||
repository.push_changes('trunk')
|
||||
end
|
||||
|
||||
project = Resource::Project.fabricate_via_api! do |project|
|
||||
project.add_name_uuid = false
|
||||
project.name = project_name
|
||||
project.group = group
|
||||
end
|
||||
|
||||
expect(project.default_branch).to eq('trunk')
|
||||
expect(project).to have_file('README.md')
|
||||
expect(project.commits.map { |commit| commit[:message].chomp })
|
||||
.to include('initial commit via CLI')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -16,12 +16,14 @@ describe QA::Runtime::ApplicationSettings do
|
|||
.with(api_client, '/application/settings')
|
||||
.and_return(request)
|
||||
|
||||
expect(described_class).to receive(:get_application_settings)
|
||||
|
||||
expect(described_class)
|
||||
.to receive(:put)
|
||||
.with(request.url, { allow_local_requests_from_web_hooks_and_services: true })
|
||||
.and_return(Struct.new(:code).new(200))
|
||||
|
||||
subject.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
|
||||
described_class.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +39,7 @@ describe QA::Runtime::ApplicationSettings do
|
|||
.with(request.url)
|
||||
.and_return(get_response)
|
||||
|
||||
subject.get_application_settings
|
||||
described_class.get_application_settings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ describe('GpgBadges', () => {
|
|||
GpgBadges.fetch()
|
||||
.then(() => {
|
||||
expect(document.querySelector('.js-loading-gpg-badge:empty')).toBe(null);
|
||||
const spinners = document.querySelectorAll('.js-loading-gpg-badge i.fa.fa-spinner.fa-spin');
|
||||
const spinners = document.querySelectorAll('.js-loading-gpg-badge span.gl-spinner');
|
||||
|
||||
expect(spinners.length).toBe(1);
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue