Skip to content
Snippets Groups Projects
Commit 264d25da authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge remote-tracking branch 'origin/master' into add-filter-sort-dropdown-to-dashboard-group-pages

parents c79c441c 22772871
No related branches found
No related tags found
No related merge requests found
Showing
with 69 additions and 78 deletions
Loading
Loading
@@ -13,10 +13,10 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
current_user.save! if current_user.changed?
 
if two_factor_grace_period_expired?
flash.now[:alert] = 'You must configure Two-Factor Authentication in your account.'
flash.now[:alert] = 'You must enable Two-factor Authentication for your account.'
else
grace_period_deadline = current_user.otp_grace_period_started_at + two_factor_grace_period.hours
flash.now[:alert] = "You must configure Two-Factor Authentication in your account until #{l(grace_period_deadline)}."
flash.now[:alert] = "You must enable Two-factor Authentication for your account before #{l(grace_period_deadline)}."
end
 
@qr_code = build_qr_code
Loading
Loading
Loading
Loading
@@ -8,28 +8,6 @@ class Projects::BlameController < Projects::ApplicationController
 
def show
@blob = @repository.blob_at(@commit.id, @path)
@blame = group_blame_lines
end
def group_blame_lines
blame = Gitlab::Git::Blame.new(@repository, @commit.id, @path)
prev_sha = nil
groups = []
current_group = nil
blame.each do |commit, line|
if prev_sha && prev_sha == commit.sha
current_group[:lines] << line
else
groups << current_group if current_group.present?
current_group = { commit: commit, lines: [line] }
end
prev_sha = commit.sha
end
groups << current_group if current_group.present?
groups
@blame_groups = Gitlab::Blame.new(@blob, @commit).groups
end
end
Loading
Loading
@@ -21,7 +21,7 @@ class Projects::CompareController < Projects::ApplicationController
@commits = Commit.decorate(compare_result.commits, @project)
@diffs = compare_result.diffs
@commit = @project.commit(head_ref)
@base_commit = @project.commit(base_ref)
@base_commit = @project.merge_base_commit(base_ref, head_ref)
@diff_refs = [@base_commit, @commit]
@line_notes = []
end
Loading
Loading
Loading
Loading
@@ -3,6 +3,15 @@ class Projects::ForksController < Projects::ApplicationController
before_action :require_non_empty_project
before_action :authorize_download_code!
 
def index
@sort = params[:sort] || 'id_desc'
@all_forks = project.forks.includes(:creator).order_by(@sort)
@public_forks, @protected_forks = @all_forks.partition do |project|
can?(current_user, :read_project, project)
end
end
def new
@namespaces = current_user.manageable_namespaces
@namespaces.delete(@project.namespace)
Loading
Loading
@@ -10,7 +19,7 @@ class Projects::ForksController < Projects::ApplicationController
 
def create
namespace = Namespace.find(params[:namespace_key])
@forked_project = namespace.projects.find_by(path: project.path)
@forked_project = nil unless @forked_project && @forked_project.forked_from_project == project
 
Loading
Loading
class Projects::ImportsController < Projects::ApplicationController
# Authorize
before_action :authorize_admin_project!
before_action :require_no_repo, except: :show
before_action :redirect_if_progress, except: :show
before_action :require_no_repo, only: [:new, :create]
before_action :redirect_if_progress, only: [:new, :create]
 
def new
end
Loading
Loading
@@ -24,11 +24,11 @@ class Projects::ImportsController < Projects::ApplicationController
end
 
def show
if @project.repository_exists? || @project.import_finished?
if @project.import_finished?
if continue_params
redirect_to continue_params[:to], notice: continue_params[:notice]
else
redirect_to project_path(@project), notice: "The project was successfully forked."
redirect_to namespace_project_path(@project.namespace, @project), notice: finished_notice
end
elsif @project.import_failed?
redirect_to new_namespace_project_import_path(@project.namespace, @project)
Loading
Loading
@@ -36,6 +36,7 @@ class Projects::ImportsController < Projects::ApplicationController
if continue_params && continue_params[:notice_now]
flash.now[:notice] = continue_params[:notice_now]
end
# Render
end
end
Loading
Loading
@@ -44,6 +45,7 @@ class Projects::ImportsController < Projects::ApplicationController
 
def continue_params
continue_params = params[:continue]
if continue_params
continue_params.permit(:to, :notice, :notice_now)
else
Loading
Loading
@@ -51,8 +53,16 @@ class Projects::ImportsController < Projects::ApplicationController
end
end
 
def finished_notice
if @project.forked?
'The project was successfully forked.'
else
'The project was successfully imported.'
end
end
def require_no_repo
if @project.repository_exists? && !@project.import_in_progress?
if @project.repository_exists?
redirect_to(namespace_project_path(@project.namespace, @project))
end
end
Loading
Loading
Loading
Loading
@@ -106,7 +106,7 @@ class Projects::NotesController < Projects::ApplicationController
{ notes_left: [note], notes_right: [] }
else
{ notes_left: [], notes_right: [note] }
end
end
else
template = "projects/notes/_diff_notes_with_reply"
locals = { notes: [note] }
Loading
Loading
Loading
Loading
@@ -8,11 +8,6 @@ class RegistrationsController < Devise::RegistrationsController
 
def create
if !Gitlab::Recaptcha.load_configurations! || verify_recaptcha
if Gitlab::IpCheck.new(request.remote_ip).spam?
flash[:alert] = 'Could not create an account. This IP is listed for spam.'
return render action: 'new'
end
super
else
flash[:alert] = "There was an error with the reCAPTCHA code below. Please re-enter the code."
Loading
Loading
Loading
Loading
@@ -2,6 +2,8 @@ class SessionsController < Devise::SessionsController
include AuthenticatesWithTwoFactor
include Recaptcha::ClientHelper
 
skip_before_action :check_2fa_requirement, only: [:destroy]
prepend_before_action :authenticate_with_two_factor, only: [:create]
prepend_before_action :store_redirect_path, only: [:new]
before_action :auto_sign_in_with_provider, only: [:new]
Loading
Loading
Loading
Loading
@@ -171,7 +171,7 @@ module ApplicationHelper
 
def search_placeholder
if @project && @project.persisted?
'Search in this project'
'Search'
elsif @snippet || @snippets || @show_snippets
'Search snippets'
elsif @group && @group.persisted?
Loading
Loading
Loading
Loading
@@ -36,8 +36,7 @@ module BlobHelper
notice: edit_in_new_fork_notice,
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_fork_path(project.namespace, project, namespace_key: current_user.namespace.id,
continue: continue_params)
fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
 
link_to "Edit", fork_path, class: 'btn', method: :post
end
Loading
Loading
@@ -62,8 +61,7 @@ module BlobHelper
notice: edit_in_new_fork_notice + " Try to #{action} this file again.",
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_fork_path(project.namespace, project, namespace_key: current_user.namespace.id,
continue: continue_params)
fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
 
link_to label, fork_path, class: "btn btn-#{btn_class}", method: :post
end
Loading
Loading
Loading
Loading
@@ -152,7 +152,7 @@ module CommitsHelper
 
options = {
class: "commit-#{options[:source]}-link has_tooltip",
data: { :'original-title' => sanitize(source_email) }
data: { 'original-title'.to_sym => sanitize(source_email) }
}
 
if user.nil?
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ module IconsHelper
# font-awesome-rails gem, but should we ever use a different icon pack in the
# future we won't have to change hundreds of method calls.
def icon(names, options = {})
fa_icon(names, options)
options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options)
end
 
def spinner(text = nil, visible = false)
Loading
Loading
Loading
Loading
@@ -83,7 +83,11 @@ module LabelsHelper
end
 
def text_color_for_bg(bg_color)
r, g, b = bg_color.slice(1,7).scan(/.{2}/).map(&:hex)
if bg_color.length == 4
r, g, b = bg_color[1, 4].scan(/./).map { |v| (v * 2).hex }
else
r, g, b = bg_color[1, 7].scan(/.{2}/).map(&:hex)
end
 
if (r + g + b) > 500
'#333333'
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ module ProjectsHelper
link_to(author_html, user_path(author), class: "author_link").html_safe
else
title = opts[:title].sub(":name", sanitize(author.name))
link_to(author_html, user_path(author), class: "author_link has_tooltip", data: { :'original-title' => title, container: 'body' } ).html_safe
link_to(author_html, user_path(author), class: "author_link has_tooltip", data: { 'original-title'.to_sym => title, container: 'body' } ).html_safe
end
end
 
Loading
Loading
@@ -116,7 +116,7 @@ module ProjectsHelper
private
 
def get_project_nav_tabs(project, current_user)
nav_tabs = [:home]
nav_tabs = [:home, :forks]
 
if !project.empty_repo? && can?(current_user, :download_code, project)
nav_tabs << [:files, :commits, :network, :graphs]
Loading
Loading
Loading
Loading
@@ -43,8 +43,6 @@
# metrics_port :integer default(8089)
# sentry_enabled :boolean default(FALSE)
# sentry_dsn :string
# ip_blocking_enabled :boolean default(FALSE)
# dns_blacklist_threshold :float default(0.33)
#
 
class ApplicationSetting < ActiveRecord::Base
Loading
Loading
Loading
Loading
@@ -47,7 +47,11 @@ class Event < ActiveRecord::Base
# Scopes
scope :recent, -> { reorder(id: :desc) }
scope :code_push, -> { where(action: PUSHED) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
scope :in_projects, ->(projects) do
where(project_id: projects.select(:id).reorder(nil)).recent
end
scope :with_associations, -> { includes(project: :namespace) }
scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) }
 
Loading
Loading
@@ -64,12 +68,6 @@ class Event < ActiveRecord::Base
[Event::CREATED, Event::CLOSED, Event::MERGED])
end
 
def latest_update_time
row = select(:updated_at, :project_id).reorder(id: :desc).take
row ? row.updated_at : nil
end
def limit_recent(limit = 20, offset = nil)
recent.limit(limit).offset(offset)
end
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ class ExternalIssue
 
# Pattern used to extract `JIRA-123` issue references from text
def self.reference_pattern
%r{(?<issue>([A-Z\-]+-)\d+)}
%r{(?<issue>\b([A-Z][A-Z0-9_]+-)\d+)}
end
 
def to_reference(_from_project = nil)
Loading
Loading
Loading
Loading
@@ -183,8 +183,8 @@ class MergeRequest < ActiveRecord::Base
def diff_base_commit
if merge_request_diff
merge_request_diff.base_commit
else
self.target_project.commit(self.target_branch)
elsif source_sha
self.target_project.merge_base_commit(self.source_sha, self.target_branch)
end
end
 
Loading
Loading
@@ -489,7 +489,7 @@ class MergeRequest < ActiveRecord::Base
end
 
def source_sha
commits.first.sha
last_commit.try(:sha)
end
 
def fetch_ref
Loading
Loading
Loading
Loading
@@ -48,14 +48,11 @@ class MergeRequestDiff < ActiveRecord::Base
end
 
def diffs_no_whitespace
# Get latest sha of branch from source project
source_sha = merge_request.source_project.commit(source_branch).sha
compare_result = Gitlab::CompareResult.new(
Gitlab::Git::Compare.new(
merge_request.target_project.repository.raw_repository,
merge_request.target_branch,
source_sha,
self.repository.raw_repository,
self.target_branch,
self.source_sha,
), { ignore_whitespace_change: true }
)
@diffs_no_whitespace ||= load_diffs(dump_commits(compare_result.diffs))
Loading
Loading
@@ -83,8 +80,6 @@ class MergeRequestDiff < ActiveRecord::Base
@last_commit_short_sha ||= last_commit.short_id
end
 
private
def dump_commits(commits)
commits.map(&:to_hash)
end
Loading
Loading
@@ -163,7 +158,7 @@ class MergeRequestDiff < ActiveRecord::Base
 
self.st_diffs = new_diffs
 
self.base_commit_sha = merge_request.target_project.commit(target_branch).try(:sha)
self.base_commit_sha = self.repository.merge_base(self.source_sha, self.target_branch)
 
self.save
end
Loading
Loading
@@ -181,7 +176,10 @@ class MergeRequestDiff < ActiveRecord::Base
merge_request.target_project.repository
end
 
private
def source_sha
source_commit = merge_request.source_project.commit(source_branch)
source_commit.try(:sha)
end
 
def compare_result
@compare_result ||=
Loading
Loading
@@ -189,15 +187,11 @@ class MergeRequestDiff < ActiveRecord::Base
# Update ref for merge request
merge_request.fetch_ref
 
# Get latest sha of branch from source project
source_commit = merge_request.source_project.commit(source_branch)
source_sha = source_commit.try(:sha)
Gitlab::CompareResult.new(
Gitlab::Git::Compare.new(
merge_request.target_project.repository.raw_repository,
merge_request.target_branch,
source_sha,
self.repository.raw_repository,
self.target_branch,
self.source_sha
)
)
end
Loading
Loading
Loading
Loading
@@ -348,6 +348,11 @@ class Project < ActiveRecord::Base
repository.commit(id)
end
 
def merge_base_commit(first_commit_id, second_commit_id)
sha = repository.merge_base(first_commit_id, second_commit_id)
repository.commit(sha) if sha
end
def saved?
id && persisted?
end
Loading
Loading
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