Files
gitlabhq/app/controllers/projects/application_controller.rb
T
Robert Speicher e6668f8e34 Merge branch 'edit-in-patch-branch' into 'master'
Default target branch to patch-n when editing file in protected branch

Fixes #3441

See merge request !2021
2015-12-08 22:04:52 +00:00

39 lines
941 B
Ruby

class Projects::ApplicationController < ApplicationController
before_action :project
before_action :repository
layout 'project'
def authenticate_user!
# Restrict access to Projects area only
# for non-signed users
if !current_user
id = params[:project_id] || params[:id]
project_with_namespace = "#{params[:namespace_id]}/#{id}"
@project = Project.find_with_namespace(project_with_namespace)
return if @project && @project.public?
end
super
end
def require_branch_head
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 a branch"
)
end
end
private
def builds_enabled
return render_404 unless @project.builds_enabled?
end
def ci_project
@ci_project ||= @project.ensure_gitlab_ci_project
end
end