Skip to content
Snippets Groups Projects
Commit 6e81d7f6 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 3fc9a8e6
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 72 deletions
Loading
Loading
@@ -136,7 +136,7 @@ gem 'faraday_middleware-aws-signers-v4'
 
# Markdown and HTML processing
gem 'html-pipeline', '~> 2.8'
gem 'deckar01-task_list', '2.2.0'
gem 'deckar01-task_list', '2.2.1'
gem 'gitlab-markup', '~> 1.7.0'
gem 'github-markup', '~> 1.7.0', require: 'github/markup'
gem 'commonmarker', '~> 0.17'
Loading
Loading
Loading
Loading
@@ -194,7 +194,7 @@ GEM
database_cleaner (1.7.0)
debug_inspector (0.0.3)
debugger-ruby_core_source (1.3.8)
deckar01-task_list (2.2.0)
deckar01-task_list (2.2.1)
html-pipeline
declarative (0.0.10)
declarative-option (0.1.0)
Loading
Loading
@@ -604,7 +604,7 @@ GEM
netrc (0.11.0)
nio4r (2.3.1)
no_proxy_fix (0.1.2)
nokogiri (1.10.4)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
nokogumbo (1.5.0)
nokogiri
Loading
Loading
@@ -1128,7 +1128,7 @@ DEPENDENCIES
creole (~> 0.5.0)
danger (~> 6.0)
database_cleaner (~> 1.7.0)
deckar01-task_list (= 2.2.0)
deckar01-task_list (= 2.2.1)
default_value_for (~> 3.3.0)
derailed_benchmarks
device_detector
Loading
Loading
Loading
Loading
@@ -36,25 +36,26 @@ export const humanize = string =>
export const dasherize = str => str.replace(/[_\s]+/g, '-');
 
/**
* Replaces whitespaces with hyphens, convert to lower case and remove non-allowed special characters
* @param {String} str
* Replaces whitespace and non-sluggish characters with a given separator
* @param {String} str - The string to slugify
* @param {String=} separator - The separator used to separate words (defaults to "-")
* @returns {String}
*/
export const slugify = str => {
export const slugify = (str, separator = '-') => {
const slug = str
.trim()
.toLowerCase()
.replace(/[^a-zA-Z0-9_.-]+/g, '-');
.replace(/[^a-zA-Z0-9_.-]+/g, separator);
 
return slug === '-' ? '' : slug;
return slug === separator ? '' : slug;
};
 
/**
* Replaces whitespaces with underscore and converts to lower case
* Replaces whitespace and non-sluggish characters with underscores
* @param {String} str
* @returns {String}
*/
export const slugifyWithUnderscore = str => str.toLowerCase().replace(/\s+/g, '_');
export const slugifyWithUnderscore = str => slugify(str, '_');
 
/**
* Truncates given text
Loading
Loading
Loading
Loading
@@ -55,10 +55,12 @@ export default {
};
},
},
mounted() {
this.verifyTimeRange();
watch: {
selectedTimeWindow() {
this.verifyTimeRange();
},
},
updated() {
mounted() {
this.verifyTimeRange();
},
methods: {
Loading
Loading
Loading
Loading
@@ -72,16 +72,14 @@ export default class NewBranchForm {
});
return `${restriction.prefix} ${formatted.join(restriction.conjunction)}`;
};
const validator = (function(_this) {
return function(errors, restriction) {
const matched = _this.name.val().match(restriction.pattern);
if (matched) {
return errors.concat(formatter(matched.reduce(unique, []), restriction));
} else {
return errors;
}
};
})(this);
const validator = (errors, restriction) => {
const matched = this.name.val().match(restriction.pattern);
if (matched) {
return errors.concat(formatter(matched.reduce(unique, []), restriction));
} else {
return errors;
}
};
const errors = this.restrictions.reduce(validator, []);
if (errors.length > 0) {
const errorMessage = $('<span/>').text(errors.join(', '));
Loading
Loading
# frozen_string_literal: true
 
module RendersCommits
def limited_commits(commits)
if commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
def limited_commits(commits, commits_count)
if commits_count > MergeRequestDiff::COMMITS_SAFE_SIZE
[
commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE),
commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE
commits_count - MergeRequestDiff::COMMITS_SAFE_SIZE
]
else
[commits, 0]
Loading
Loading
@@ -14,9 +14,10 @@ module RendersCommits
 
# This is used as a helper method in a controller.
# rubocop: disable Gitlab/ModuleWithInstanceVariables
def set_commits_for_rendering(commits)
@total_commit_count = commits.size
limited, @hidden_commit_count = limited_commits(commits)
def set_commits_for_rendering(commits, commits_count: nil)
@total_commit_count = commits_count || commits.size
limited, @hidden_commit_count = limited_commits(commits, @total_commit_count)
commits.each(&:lazy_author) # preload authors
prepare_commits_for_rendering(limited)
end
# rubocop: enable Gitlab/ModuleWithInstanceVariables
Loading
Loading
Loading
Loading
@@ -109,7 +109,13 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
 
@target_project = @merge_request.target_project
@source_project = @merge_request.source_project
@commits = set_commits_for_rendering(@merge_request.commits)
@commits =
set_commits_for_rendering(
@merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch),
commits_count: @merge_request.commits_count
)
@commit = @merge_request.diff_head_commit
 
# FIXME: We have to assign a presenter to another instance variable
Loading
Loading
Loading
Loading
@@ -90,7 +90,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
# Get commits from repository
# or from cache if already merged
@commits =
set_commits_for_rendering(@merge_request.commits.with_latest_pipeline)
set_commits_for_rendering(
@merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch),
commits_count: @merge_request.commits_count
)
 
render json: { html: view_to_html_string('projects/merge_requests/_commits') }
end
Loading
Loading
@@ -252,7 +255,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
 
def merge_params_attributes
[:should_remove_source_branch, :commit_message, :squash_commit_message, :squash, :auto_merge_strategy]
MergeRequest::KNOWN_MERGE_PARAMS
end
 
def auto_merge_requested?
Loading
Loading
@@ -292,7 +295,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
 
return :sha_mismatch if params[:sha] != @merge_request.diff_head_sha
 
@merge_request.update(merge_error: nil, squash: merge_params.fetch(:squash, false))
@merge_request.update(merge_error: nil, squash: params.fetch(:squash, false))
 
if auto_merge_requested?
if merge_request.auto_merge_enabled?
Loading
Loading
Loading
Loading
@@ -117,12 +117,6 @@ class TodosFinder
params[:group_id].present?
end
 
def project
strong_memoize(:project) do
Project.find_without_deleted(params[:project_id]) if project?
end
end
def group
strong_memoize(:group) do
Group.find(params[:group_id])
Loading
Loading
@@ -181,7 +175,7 @@ class TodosFinder
 
def by_project(items)
if project?
items.for_project(project)
items.for_undeleted_projects.for_project(params[:project_id])
else
items
end
Loading
Loading
Loading
Loading
@@ -374,11 +374,12 @@ class MergeRequest < ApplicationRecord
"#{project.to_reference(from, full: full)}#{reference}"
end
 
def commits
return merge_request_diff.commits if persisted?
def commits(limit: nil)
return merge_request_diff.commits(limit: limit) if persisted?
 
commits_arr = if compare_commits
compare_commits.reverse
reversed_commits = compare_commits.reverse
limit ? reversed_commits.take(limit) : reversed_commits
else
[]
end
Loading
Loading
@@ -386,6 +387,10 @@ class MergeRequest < ApplicationRecord
CommitCollection.new(source_project, commits_arr, source_branch)
end
 
def recent_commits
commits(limit: MergeRequestDiff::COMMITS_SAFE_SIZE)
end
def commits_count
if persisted?
merge_request_diff.commits_count
Loading
Loading
Loading
Loading
@@ -213,8 +213,10 @@ class MergeRequestDiff < ApplicationRecord
end
end
 
def commits
@commits ||= load_commits
def commits(limit: nil)
strong_memoize(:"commits_#{limit || 'all'}") do
load_commits(limit: limit)
end
end
 
def last_commit_sha
Loading
Loading
@@ -529,8 +531,9 @@ class MergeRequestDiff < ApplicationRecord
end
end
 
def load_commits
commits = merge_request_diff_commits.map { |commit| Commit.from_hash(commit.to_hash, project) }
def load_commits(limit: nil)
commits = merge_request_diff_commits.limit(limit)
.map { |commit| Commit.from_hash(commit.to_hash, project) }
 
CommitCollection
.new(merge_request.source_project, commits, merge_request.source_branch)
Loading
Loading
Loading
Loading
@@ -464,13 +464,6 @@ class Project < ApplicationRecord
# Used by Projects::CleanupService to hold a map of rewritten object IDs
mount_uploader :bfg_object_map, AttachmentUploader
 
# Returns a project, if it is not about to be removed.
#
# id - The ID of the project to retrieve.
def self.find_without_deleted(id)
without_deleted.find_by_id(id)
end
def self.eager_load_namespace_and_owner
includes(namespace: :owner)
end
Loading
Loading
Loading
Loading
@@ -55,7 +55,8 @@ class Todo < ApplicationRecord
scope :done, -> { with_state(:done) }
scope :for_action, -> (action) { where(action: action) }
scope :for_author, -> (author) { where(author: author) }
scope :for_project, -> (project) { where(project: project) }
scope :for_project, -> (projects) { where(project: projects) }
scope :for_undeleted_projects, -> { joins(:project).merge(Project.without_deleted) }
scope :for_group, -> (group) { where(group: group) }
scope :for_type, -> (type) { where(target_type: type) }
scope :for_target, -> (id) { where(target_id: id) }
Loading
Loading
Loading
Loading
@@ -19,10 +19,12 @@ module MergeRequests
end
 
def source
if merge_request.squash
squash_sha!
else
merge_request.diff_head_sha
strong_memoize(:source) do
if merge_request.squash
squash_sha!
else
merge_request.diff_head_sha
end
end
end
 
Loading
Loading
@@ -58,16 +60,14 @@ module MergeRequests
end
 
def squash_sha!
strong_memoize(:squash_sha) do
params[:merge_request] = merge_request
squash_result = ::MergeRequests::SquashService.new(project, current_user, params).execute
case squash_result[:status]
when :success
squash_result[:squash_sha]
when :error
raise ::MergeRequests::MergeService::MergeError, squash_result[:message]
end
params[:merge_request] = merge_request
squash_result = ::MergeRequests::SquashService.new(project, current_user, params).execute
case squash_result[:status]
when :success
squash_result[:squash_sha]
when :error
raise ::MergeRequests::MergeService::MergeError, squash_result[:message]
end
end
end
Loading
Loading
Loading
Loading
@@ -37,6 +37,7 @@ module MergeRequests
def validate!
authorization_check!
error_check!
updated_check!
end
 
def authorization_check!
Loading
Loading
@@ -60,6 +61,15 @@ module MergeRequests
raise_error(error) if error
end
 
def updated_check!
return unless Feature.enabled?(:validate_merge_sha, merge_request.target_project, default_enabled: false)
unless source_matches?
raise_error('Branch has been updated since the merge was requested. '\
'Please review the changes.')
end
end
def commit
log_info("Git merge started on JID #{merge_jid}")
commit_id = try_merge
Loading
Loading
@@ -125,5 +135,11 @@ module MergeRequests
def merge_request_info
merge_request.to_reference(full: true)
end
def source_matches?
# params-keys are symbols coming from the controller, but when they get
# loaded from the database they're strings
params.with_indifferent_access[:sha] == merge_request.diff_head_sha
end
end
end
Loading
Loading
@@ -88,9 +88,9 @@ module MergeRequests
merge_request.update(merge_error: nil)
 
if merge_request.head_pipeline && merge_request.head_pipeline.active?
AutoMergeService.new(project, current_user).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS)
AutoMergeService.new(project, current_user, { sha: last_diff_sha }).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS)
else
merge_request.merge_async(current_user.id, {})
merge_request.merge_async(current_user.id, { sha: last_diff_sha })
end
end
 
Loading
Loading
---
title: Fix checking task item when previous tasks contain only spaces
merge_request: 19724
author:
type: fixed
---
title: Correctly cleanup orphan job artifacts
merge_request: 17679
author: Adam Mulvany
type: fixed
---
title: Remove IIFEs from new_branch_form.js
merge_request: 20009
author: minghuan lei
type: other
---
title: Remove update hook from date filter to prevent js from getting stuck
merge_request: 20215
author:
type: fixed
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment