Skip to content
Snippets Groups Projects
Commit eab086bd authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch 'master' into merge-if-green

# Conflicts:
#	app/controllers/projects/merge_requests_controller.rb
#	config/routes.rb
parents 1464a69c ee0ab46d
No related branches found
No related tags found
No related merge requests found
Showing
with 157 additions and 60 deletions
Loading
Loading
@@ -25,6 +25,7 @@ v 8.3.0 (unreleased)
- Fix bug when simultaneously accepting multiple MRs results in MRs that are of "merged" status, but not merged to the target branch
- Add languages page to graphs
- Block LDAP user when they are no longer found in the LDAP server
- Improve wording on project visibility levels (Zeger-Jan van de Weg)
 
v 8.2.3
- Fix application settings cache not expiring after changes (Stan Hu)
Loading
Loading
Loading
Loading
@@ -43,6 +43,7 @@
#
class @MergeRequestTabs
diffsLoaded: false
buildsLoaded: false
commitsLoaded: false
 
constructor: (@opts = {}) ->
Loading
Loading
@@ -54,6 +55,12 @@ class @MergeRequestTabs
 
bindEvents: ->
$(document).on 'shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', @tabShown
$(document).on 'click', '.js-show-tab', @showTab
showTab: (event) =>
event.preventDefault()
@activateTab $(event.target).data('action')
 
tabShown: (event) =>
$target = $(event.target)
Loading
Loading
@@ -63,6 +70,8 @@ class @MergeRequestTabs
@loadCommits($target.attr('href'))
else if action == 'diffs'
@loadDiff($target.attr('href'))
else if action == 'builds'
@loadBuilds($target.attr('href'))
 
@setCurrentAction(action)
 
Loading
Loading
@@ -101,7 +110,7 @@ class @MergeRequestTabs
action = 'notes' if action == 'show'
 
# Remove a trailing '/commits' or '/diffs'
new_state = @_location.pathname.replace(/\/(commits|diffs)(\.html)?\/?$/, '')
new_state = @_location.pathname.replace(/\/(commits|diffs|builds)(\.html)?\/?$/, '')
 
# Append the new action if we're on a tab other than 'notes'
unless action == 'notes'
Loading
Loading
@@ -139,6 +148,17 @@ class @MergeRequestTabs
@diffsLoaded = true
@scrollToElement("#diffs")
 
loadBuilds: (source) ->
return if @buildsLoaded
@_get
url: "#{source}.json"
success: (data) =>
document.getElementById('builds').innerHTML = data.html
$('.js-timeago').timeago()
@buildsLoaded = true
@scrollToElement("#builds")
# Show or hide the loading spinner
#
# status - Boolean, true to show, false to hide
Loading
Loading
Loading
Loading
@@ -83,6 +83,10 @@
&.ci-error {
color: $gl-danger;
}
a.monospace {
color: inherit;
}
}
 
.mr-widget-body,
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ class Projects::ApplicationController < ApplicationController
unless @repository.branch_names.include?(@ref)
redirect_to(
namespace_project_tree_path(@project.namespace, @project, @ref),
notice: "This action is not allowed unless you are on top of a branch"
notice: "This action is not allowed unless you are on a branch"
)
end
end
Loading
Loading
Loading
Loading
@@ -162,12 +162,20 @@ class Projects::BlobController < Projects::ApplicationController
end
 
def sanitized_new_branch_name
@new_branch ||= sanitize(strip_tags(params[:new_branch]))
sanitize(strip_tags(params[:new_branch]))
end
 
def editor_variables
@current_branch = @ref
@new_branch = params[:new_branch].present? ? sanitized_new_branch_name : @ref
@new_branch =
if params[:new_branch].present?
sanitized_new_branch_name
elsif ::Gitlab::GitAccess.new(current_user, @project).can_push_to_branch?(@ref)
@ref
else
@repository.next_patch_branch
end
 
@file_path =
if action_name.to_s == 'create'
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ class Projects::CommitController < Projects::ApplicationController
def cancel_builds
ci_commit.builds.running_or_pending.each(&:cancel)
 
redirect_to builds_namespace_project_commit_path(project.namespace, project, commit.sha)
redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end
 
def retry_builds
Loading
Loading
@@ -47,7 +47,7 @@ class Projects::CommitController < Projects::ApplicationController
end
end
 
redirect_to builds_namespace_project_commit_path(project.namespace, project, commit.sha)
redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end
 
def branches
Loading
Loading
@@ -74,8 +74,8 @@ class Projects::CommitController < Projects::ApplicationController
end
 
@notes_count = commit.notes.count
@builds = ci_commit.builds if ci_commit
@statuses = ci_commit.statuses if ci_commit
end
 
def authorize_manage_builds!
Loading
Loading
class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled
before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :merge, :merge_check,
:edit, :update, :show, :diffs, :commits, :builds, :merge, :merge_check,
:ci_status, :toggle_subscription, :cancel_merge_when_build_succeeds
]
before_action :closes_issues, only: [:edit, :update, :show, :diffs, :commits]
before_action :validates_merge_request, only: [:show, :diffs, :commits]
before_action :define_show_vars, only: [:show, :diffs, :commits]
before_action :ensure_ref_fetched, only: [:show, :commits, :diffs]
before_action :closes_issues, only: [:edit, :update, :show, :diffs, :commits, :builds]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :builds]
before_action :define_show_vars, only: [:show, :diffs, :commits, :builds]
before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds]
 
# Allow read any merge_request
before_action :authorize_read_merge_request!
Loading
Loading
@@ -79,6 +79,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
 
def builds
@ci_project = @merge_request.source_project.gitlab_ci_project
respond_to do |format|
format.html { render 'show' }
format.json { render json: { html: view_to_html_string('projects/merge_requests/show/_builds') } }
end
end
def new
params[:merge_request] ||= ActionController::Parameters.new(source_project: @project)
@merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute
Loading
Loading
@@ -91,20 +100,19 @@ class Projects::MergeRequestsController < Projects::ApplicationController
 
@target_project = merge_request.target_project
@source_project = merge_request.source_project
@commits = @merge_request.compare_commits
@commits = @merge_request.compare_commits.reverse
@commit = @merge_request.last_commit
@first_commit = @merge_request.first_commit
@diffs = @merge_request.compare_diffs
@ci_project = @source_project.gitlab_ci_project
@ci_commit = @merge_request.ci_commit
@statuses = @ci_commit.statuses if @ci_commit
@note_counts = Note.where(commit_id: @commits.map(&:id)).
group(:commit_id).count
end
 
def edit
@source_project = @merge_request.source_project
@target_project = @merge_request.target_project
@target_branches = @merge_request.target_project.repository.branch_names
end
def create
@target_branches ||= []
@merge_request = MergeRequests::CreateService.new(project, current_user, merge_request_params).execute
Loading
Loading
@@ -118,6 +126,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
 
def edit
@source_project = @merge_request.source_project
@target_project = @merge_request.target_project
@target_branches = @merge_request.target_project.repository.branch_names
end
def update
@merge_request = MergeRequests::UpdateService.new(project, current_user, merge_request_params).execute(@merge_request)
 
Loading
Loading
@@ -279,6 +293,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff = @merge_request.merge_request_diff
 
@ci_commit = @merge_request.ci_commit
@statuses = @ci_commit.statuses if @ci_commit
 
if @merge_request.locked_long_ago?
@merge_request.unlock_mr
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@group_members = @group_members.where(user_id: users)
end
 
@group_members = @group_members.order('access_level DESC').limit(20)
@group_members = @group_members.order('access_level DESC')
end
 
@project_member = @project.project_members.new
Loading
Loading
Loading
Loading
@@ -30,26 +30,24 @@ module BlobHelper
nil
end
 
if blob_viewable?(blob)
text = 'Edit'
after = options[:after] || ''
from_mr = options[:from_merge_request_id]
link_opts = {}
link_opts[:from_merge_request_id] = from_mr if from_mr
cls = 'btn btn-small'
if allowed_tree_edit?(project, ref)
link_to(text,
namespace_project_edit_blob_path(project.namespace, project,
tree_join(ref, path),
link_opts),
class: cls
)
else
content_tag :span, text, class: cls + ' disabled'
end + after.html_safe
else
''
end
return unless blob && blob.text? && blob_editable?(blob)
text = 'Edit'
after = options[:after] || ''
from_mr = options[:from_merge_request_id]
link_opts = {}
link_opts[:from_merge_request_id] = from_mr if from_mr
cls = 'btn btn-small'
link_to(text,
namespace_project_edit_blob_path(project.namespace, project,
tree_join(ref, path),
link_opts),
class: cls
) + after.html_safe
end
def blob_editable?(blob, project = @project, ref = @ref)
!blob.lfs_pointer? && allowed_tree_edit?(project, ref)
end
 
def leave_edit_message
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ module BranchesHelper
 
def can_push_branch?(project, branch_name)
return false unless project.repository.branch_names.include?(branch_name)
::Gitlab::GitAccess.new(current_user, project).can_push_to_branch?(branch_name)
end
end
Loading
Loading
@@ -46,16 +46,26 @@ module TreeHelper
File.join(*args)
end
 
def on_top_of_branch?(project = @project, ref = @ref)
project.repository.branch_names.include?(ref)
end
def allowed_tree_edit?(project = nil, ref = nil)
project ||= @project
ref ||= @ref
return false unless project.repository.branch_names.include?(ref)
return false unless on_top_of_branch?(project, ref)
 
::Gitlab::GitAccess.new(current_user, project).can_push_to_branch?(ref)
can?(current_user, :push_code, project)
end
 
def can_delete_or_replace?(blob)
allowed_tree_edit? && !blob.lfs_pointer?
def tree_edit_branch(project = @project, ref = @ref)
if allowed_tree_edit?(project, ref)
if can_push_branch?(project, ref)
ref
else
project.repository.next_patch_branch
end
end
end
 
def tree_breadcrumbs(tree, max_links = 2)
Loading
Loading
Loading
Loading
@@ -12,22 +12,22 @@ module VisibilityLevelHelper
 
# Return the description for the +level+ argument.
#
# +level+ One of the Gitlab::VisibilityLevel constants
# +form_model+ Either a model object (Project, Snippet, etc.) or the name of
# a Project or Snippet class.
# +level+ One of the Gitlab::VisibilityLevel constants
# +form_model+ Either a model object (Project, Snippet, etc.) or the name of
# a Project or Snippet class.
def visibility_level_description(level, form_model)
case form_model.is_a?(String) ? form_model : form_model.class.name
when 'PersonalSnippet', 'ProjectSnippet', 'Snippet'
snippet_visibility_level_description(level)
when 'Project'
case form_model
when Project
project_visibility_level_description(level)
when Snippet
snippet_visibility_level_description(level, form_model)
end
end
 
def project_visibility_level_description(level)
case level
when Gitlab::VisibilityLevel::PRIVATE
"Project access must be granted explicitly for each user."
"Project access must be granted explicitly to each user."
when Gitlab::VisibilityLevel::INTERNAL
"The project can be cloned by any logged in user."
when Gitlab::VisibilityLevel::PUBLIC
Loading
Loading
@@ -35,12 +35,16 @@ module VisibilityLevelHelper
end
end
 
def snippet_visibility_level_description(level)
def snippet_visibility_level_description(level, snippet = nil)
case level
when Gitlab::VisibilityLevel::PRIVATE
"The snippet is visible only for me."
if snippet.is_a? ProjectSnippet
"The snippet is visible only to project members."
else
"The snippet is visible only to me."
end
when Gitlab::VisibilityLevel::INTERNAL
"The snippet is visible for any logged in user."
"The snippet is visible to any logged in user."
when Gitlab::VisibilityLevel::PUBLIC
"The snippet can be accessed without any authentication."
end
Loading
Loading
# == Schema Information
#
# Table name: lfs_objects
#
# id :integer not null, primary key
# oid :string(255) not null
# size :integer not null
# created_at :datetime
# updated_at :datetime
# file :string(255)
#
class LfsObject < ActiveRecord::Base
has_many :lfs_objects_projects, dependent: :destroy
has_many :projects, through: :lfs_objects_projects
Loading
Loading
# == Schema Information
#
# Table name: lfs_objects_projects
#
# id :integer not null, primary key
# lfs_object_id :integer not null
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
#
class LfsObjectsProject < ActiveRecord::Base
belongs_to :project
belongs_to :lfs_object
Loading
Loading
Loading
Loading
@@ -16,6 +16,7 @@
# system :boolean default(FALSE), not null
# st_diff :text
# updated_by_id :integer
# is_award :boolean default(FALSE), not null
#
 
require 'carrierwave/orm/activerecord'
Loading
Loading
Loading
Loading
@@ -28,6 +28,7 @@
# import_type :string(255)
# import_source :string(255)
# commit_count :integer default(0)
# import_error :text
#
 
require 'carrierwave/orm/activerecord'
Loading
Loading
Loading
Loading
@@ -329,6 +329,17 @@ class Repository
commit(sha)
end
 
def next_patch_branch
patch_branch_ids = self.branch_names.map do |n|
result = n.match(/\Apatch-([0-9]+)\z/)
result[1].to_i if result
end.compact
highest_patch_branch_id = patch_branch_ids.max || 0
"patch-#{highest_patch_branch_id + 1}"
end
# Remove archives older than 2 hours
def branches_sorted_by(value)
case value
Loading
Loading
Loading
Loading
@@ -56,6 +56,7 @@
# project_view :integer default(0)
# consumed_timestep :integer
# layout :integer default(0)
# hide_project_limit :boolean default(FALSE)
#
 
require 'carrierwave/orm/activerecord'
Loading
Loading
Loading
Loading
@@ -53,7 +53,7 @@ module Files
 
unless project.empty_repo?
unless repository.branch_names.include?(@current_branch)
raise_error("You can only create files if you are on top of a branch")
raise_error("You can only create or edit files when you are on a branch")
end
 
if @current_branch != @target_branch
Loading
Loading
Loading
Loading
@@ -14,11 +14,11 @@
.form-group.project-visibility-level-holder
= f.label :default_project_visibility, class: 'control-label col-sm-2'
.col-sm-10
= render('shared/visibility_radios', model_method: :default_project_visibility, form: f, selected_level: @application_setting.default_project_visibility, form_model: 'Project')
= render('shared/visibility_radios', model_method: :default_project_visibility, form: f, selected_level: @application_setting.default_project_visibility, form_model: Project)
.form-group.project-visibility-level-holder
= f.label :default_snippet_visibility, class: 'control-label col-sm-2'
.col-sm-10
= render('shared/visibility_radios', model_method: :default_snippet_visibility, form: f, selected_level: @application_setting.default_snippet_visibility, form_model: 'Snippet')
= render('shared/visibility_radios', model_method: :default_snippet_visibility, form: f, selected_level: @application_setting.default_snippet_visibility, form_model: PersonalSnippet)
.form-group
= f.label :restricted_visibility_levels, class: 'control-label col-sm-2'
.col-sm-10
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