Skip to content
Snippets Groups Projects
Commit e40c13ae authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Merge branch 'master' into fix/visibility-level-setting-in-forked-projects

* master:
  Add CI permissions and api links to README [ci skip]
  Remove duplicate documentation links
  make migrations reversible
  Add missing stage to builds view
  CI details cleanup
  Allow groups to appear in the search results if the group owner allows it
  Update installation.md
  update example of regex for pytest-cov
parents 3a52662c 193bc5fb
No related branches found
No related tags found
1 merge request!1744Fix/visibility level setting in forked projects
Showing
with 103 additions and 104 deletions
Loading
@@ -22,6 +22,7 @@ v 8.2.0 (unreleased)
Loading
@@ -22,6 +22,7 @@ v 8.2.0 (unreleased)
- Include commit logs in project search - Include commit logs in project search
- Add "added", "modified" and "removed" properties to commit object in webhook - Add "added", "modified" and "removed" properties to commit object in webhook
- Rename "Back to" links to "Go to" because its not always a case it point to place user come from - Rename "Back to" links to "Go to" because its not always a case it point to place user come from
- Allow groups to appear in the search results if the group owner allows it
   
v 8.1.3 v 8.1.3
- Spread out runner contacted_at updates - Spread out runner contacted_at updates
Loading
Loading
Loading
@@ -4,12 +4,12 @@ class GroupsController < Groups::ApplicationController
Loading
@@ -4,12 +4,12 @@ class GroupsController < Groups::ApplicationController
before_action :group, except: [:new, :create] before_action :group, except: [:new, :create]
   
# Authorize # Authorize
before_action :authorize_read_group!, except: [:show, :new, :create] before_action :authorize_read_group!, except: [:show, :new, :create, :autocomplete]
before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects] before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects]
before_action :authorize_create_group!, only: [:new, :create] before_action :authorize_create_group!, only: [:new, :create]
   
# Load group projects # Load group projects
before_action :load_projects, except: [:new, :create, :projects, :edit, :update] before_action :load_projects, except: [:new, :create, :projects, :edit, :update, :autocomplete]
before_action :event_filter, only: :show before_action :event_filter, only: :show
   
layout :determine_layout layout :determine_layout
Loading
@@ -133,7 +133,7 @@ class GroupsController < Groups::ApplicationController
Loading
@@ -133,7 +133,7 @@ class GroupsController < Groups::ApplicationController
end end
   
def group_params def group_params
params.require(:group).permit(:name, :description, :path, :avatar) params.require(:group).permit(:name, :description, :path, :avatar, :public)
end end
   
def load_events def load_events
Loading
Loading
Loading
@@ -30,7 +30,7 @@ class Projects::BuildsController < Projects::ApplicationController
Loading
@@ -30,7 +30,7 @@ class Projects::BuildsController < Projects::ApplicationController
   
def show def show
@builds = @ci_project.commits.find_by_sha(@build.sha).builds.order('id DESC') @builds = @ci_project.commits.find_by_sha(@build.sha).builds.order('id DESC')
@builds = @builds.where("id not in (?)", @build.id).page(params[:page]).per(20) @builds = @builds.where("id not in (?)", @build.id)
@commit = @build.commit @commit = @build.commit
   
respond_to do |format| respond_to do |format|
Loading
@@ -42,17 +42,13 @@ class Projects::BuildsController < Projects::ApplicationController
Loading
@@ -42,17 +42,13 @@ class Projects::BuildsController < Projects::ApplicationController
end end
   
def retry def retry
if @build.commands.blank? unless @build.retryable?
return page_404 return page_404
end end
   
build = Ci::Build.retry(@build) build = Ci::Build.retry(@build)
   
if params[:return_to] redirect_to build_path(build)
redirect_to URI.parse(params[:return_to]).path
else
redirect_to build_path(build)
end
end end
   
def status def status
Loading
Loading
Loading
@@ -7,14 +7,14 @@ class Projects::CommitController < Projects::ApplicationController
Loading
@@ -7,14 +7,14 @@ class Projects::CommitController < Projects::ApplicationController
before_action :authorize_download_code!, except: [:cancel_builds] before_action :authorize_download_code!, except: [:cancel_builds]
before_action :authorize_manage_builds!, only: [:cancel_builds] before_action :authorize_manage_builds!, only: [:cancel_builds]
before_action :commit before_action :commit
before_action :authorize_manage_builds!, only: [:cancel_builds, :retry_builds]
before_action :define_show_vars, only: [:show, :builds]
   
def show def show
return git_not_found! unless @commit return git_not_found! unless @commit
   
@line_notes = commit.notes.inline @line_notes = commit.notes.inline
@diffs = @commit.diffs
@note = @project.build_commit_note(commit) @note = @project.build_commit_note(commit)
@notes_count = commit.notes.count
@notes = commit.notes.not_inline.fresh @notes = commit.notes.not_inline.fresh
@noteable = @commit @noteable = @commit
@comments_allowed = @reply_allowed = true @comments_allowed = @reply_allowed = true
Loading
@@ -23,8 +23,6 @@ class Projects::CommitController < Projects::ApplicationController
Loading
@@ -23,8 +23,6 @@ class Projects::CommitController < Projects::ApplicationController
commit_id: @commit.id commit_id: @commit.id
} }
   
@ci_commit = project.ci_commit(commit.sha)
respond_to do |format| respond_to do |format|
format.html format.html
format.diff { render text: @commit.to_diff } format.diff { render text: @commit.to_diff }
Loading
@@ -32,20 +30,25 @@ class Projects::CommitController < Projects::ApplicationController
Loading
@@ -32,20 +30,25 @@ class Projects::CommitController < Projects::ApplicationController
end end
end end
   
def ci def builds
@ci_commit = @project.ci_commit(@commit.sha)
@builds = @ci_commit.builds if @ci_commit
@notes_count = @commit.notes.count
@ci_project = @project.gitlab_ci_project @ci_project = @project.gitlab_ci_project
end end
   
def cancel_builds def cancel_builds
@ci_commit = @project.ci_commit(@commit.sha) ci_commit.builds.running_or_pending.each(&:cancel)
@ci_commit.builds.running_or_pending.each(&:cancel)
   
redirect_to ci_namespace_project_commit_path(project.namespace, project, commit.sha) redirect_to builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end end
   
def retry_builds
ci_commit.builds.latest.failed.each do |build|
if build.retryable?
Ci::Build.retry(build)
end
end
redirect_to builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end
   
def branches def branches
@branches = @project.repository.branch_names_contains(commit.id) @branches = @project.repository.branch_names_contains(commit.id)
Loading
@@ -53,11 +56,22 @@ class Projects::CommitController < Projects::ApplicationController
Loading
@@ -53,11 +56,22 @@ class Projects::CommitController < Projects::ApplicationController
render layout: false render layout: false
end end
   
private
def commit def commit
@commit ||= @project.commit(params[:id]) @commit ||= @project.commit(params[:id])
end end
   
private def ci_commit
@ci_commit ||= project.ci_commit(commit.sha)
end
def define_show_vars
@diffs = commit.diffs
@notes_count = commit.notes.count
@builds = ci_commit.builds if ci_commit
end
   
def authorize_manage_builds! def authorize_manage_builds!
unless can?(current_user, :manage_builds, project) unless can?(current_user, :manage_builds, project)
Loading
Loading
Loading
@@ -6,33 +6,34 @@ class GroupsFinder
Loading
@@ -6,33 +6,34 @@ class GroupsFinder
private private
   
def all_groups(current_user) def all_groups(current_user)
if current_user group_ids = if current_user
if current_user.authorized_groups.any? if current_user.authorized_groups.any?
# User has access to groups # User has access to groups
# #
# Return only: # Return only:
# groups with public projects # groups with public projects
# groups with internal projects # groups with internal projects
# groups with joined projects # groups with joined projects
# #
group_ids = Project.public_and_internal_only.pluck(:namespace_id) + Project.public_and_internal_only.pluck(:namespace_id) +
current_user.authorized_groups.pluck(:id) current_user.authorized_groups.pluck(:id)
Group.where(id: group_ids) else
else # User has no group membership
# User has no group membership #
# # Return only:
# Return only: # groups with public projects
# groups with public projects # groups with internal projects
# groups with internal projects #
# Project.public_and_internal_only.pluck(:namespace_id)
Group.where(id: Project.public_and_internal_only.pluck(:namespace_id)) end
end else
else # Not authenticated
# Not authenticated #
# # Return only:
# Return only: # groups with public projects
# groups with public projects Project.public_only.pluck(:namespace_id)
Group.where(id: Project.public_only.pluck(:namespace_id)) end
end
Group.where("public IS TRUE OR id IN(?)", group_ids)
end end
end end
module BuildsHelper
def build_ref_link build
gitlab_ref_link build.project, build.ref
end
def build_commit_link build
gitlab_commit_link build.project, build.short_sha
end
def build_url(build)
namespace_project_build_path(build.gl_project, build.project, build)
end
end
Loading
@@ -4,25 +4,6 @@ module Ci
Loading
@@ -4,25 +4,6 @@ module Ci
{ :"data-no-turbolink" => "data-no-turbolink" } { :"data-no-turbolink" => "data-no-turbolink" }
end end
   
def gitlab_ref_link project, ref
gitlab_url = project.gitlab_url.dup
gitlab_url << "/commits/#{ref}"
link_to ref, gitlab_url, no_turbolink
end
def gitlab_compare_link project, before, after
gitlab_url = project.gitlab_url.dup
gitlab_url << "/compare/#{before}...#{after}"
link_to "#{before}...#{after}", gitlab_url, no_turbolink
end
def gitlab_commit_link project, sha
gitlab_url = project.gitlab_url.dup
gitlab_url << "/commit/#{sha}"
link_to Ci::Commit.truncate_sha(sha), gitlab_url, no_turbolink
end
def yaml_web_editor_link(project) def yaml_web_editor_link(project)
commits = project.commits commits = project.commits
   
Loading
Loading
module CiStatusHelper module CiStatusHelper
def ci_status_path(ci_commit) def ci_status_path(ci_commit)
project = ci_commit.gl_project project = ci_commit.gl_project
ci_namespace_project_commit_path(project.namespace, project, ci_commit.sha) builds_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
end end
   
def ci_status_icon(ci_commit) def ci_status_icon(ci_commit)
Loading
Loading
Loading
@@ -70,7 +70,7 @@ module SearchHelper
Loading
@@ -70,7 +70,7 @@ module SearchHelper
   
# Autocomplete results for the current user's groups # Autocomplete results for the current user's groups
def groups_autocomplete(term, limit = 5) def groups_autocomplete(term, limit = 5)
current_user.authorized_groups.search(term).limit(limit).map do |group| GroupsFinder.new.execute(current_user).search(term).limit(limit).map do |group|
{ {
label: "group: #{search_result_sanitize(group.name)}", label: "group: #{search_result_sanitize(group.name)}",
url: group_path(group) url: group_path(group)
Loading
Loading
Loading
@@ -106,6 +106,14 @@ module Ci
Loading
@@ -106,6 +106,14 @@ module Ci
failed? && allow_failure? failed? && allow_failure?
end end
   
def retryable?
commands.present?
end
def retried?
!self.commit.latest_builds_for_ref(self.ref).include?(self)
end
def trace_html def trace_html
html = Ci::Ansi2html::convert(trace) if trace.present? html = Ci::Ansi2html::convert(trace) if trace.present?
html || '' html || ''
Loading
@@ -222,7 +230,7 @@ module Ci
Loading
@@ -222,7 +230,7 @@ module Ci
end end
   
def retry_url def retry_url
if commands.present? if retryable?
Gitlab::Application.routes.url_helpers. Gitlab::Application.routes.url_helpers.
retry_namespace_project_build_path(gl_project.namespace, gl_project, self) retry_namespace_project_build_path(gl_project.namespace, gl_project, self)
end end
Loading
Loading
Loading
@@ -15,8 +15,8 @@ class CommitStatus < ActiveRecord::Base
Loading
@@ -15,8 +15,8 @@ class CommitStatus < ActiveRecord::Base
scope :pending, -> { where(status: 'pending') } scope :pending, -> { where(status: 'pending') }
scope :success, -> { where(status: 'success') } scope :success, -> { where(status: 'success') }
scope :failed, -> { where(status: 'failed') } scope :failed, -> { where(status: 'failed') }
scope :running_or_pending, -> { where(status:[:running, :pending]) } scope :running_or_pending, -> { where(status: [:running, :pending]) }
scope :finished, -> { where(status:[:success, :failed, :canceled]) } scope :finished, -> { where(status: [:success, :failed, :canceled]) }
scope :latest, -> { where(id: unscope(:select).select('max(id)').group(:name, :ref)) } scope :latest, -> { where(id: unscope(:select).select('max(id)').group(:name, :ref)) }
scope :ordered, -> { order(:ref, :stage_idx, :name) } scope :ordered, -> { order(:ref, :stage_idx, :name) }
scope :for_ref, ->(ref) { where(ref: ref) } scope :for_ref, ->(ref) { where(ref: ref) }
Loading
Loading
Loading
@@ -120,7 +120,7 @@ class Group < Namespace
Loading
@@ -120,7 +120,7 @@ class Group < Namespace
end end
   
def public_profile? def public_profile?
projects.public_only.any? self.public || projects.public_only.any?
end end
   
def post_create_hook def post_create_hook
Loading
Loading
Loading
@@ -11,7 +11,7 @@ module Ci
Loading
@@ -11,7 +11,7 @@ module Ci
def to_s def to_s
lines = Array.new lines = Array.new
lines.push("<a href=\"#{ci_project_url(project)}\">#{project.name}</a> - ") lines.push("<a href=\"#{ci_project_url(project)}\">#{project.name}</a> - ")
lines.push("<a href=\"#{ci_namespace_project_commit_url(commit.gl_project.namespace, commit.gl_project, commit.sha)}\">Commit ##{commit.id}</a></br>") lines.push("<a href=\"#{builds_namespace_project_commit_url(commit.gl_project.namespace, commit.gl_project, commit.sha)}\">Commit ##{commit.id}</a></br>")
lines.push("#{commit.short_sha} #{commit.git_author_name} - #{commit.git_commit_message}</br>") lines.push("#{commit.short_sha} #{commit.git_author_name} - #{commit.git_commit_message}</br>")
lines.push("#{humanized_status(commit_status)} in #{commit.duration} second(s).") lines.push("#{humanized_status(commit_status)} in #{commit.duration} second(s).")
lines.join('') lines.join('')
Loading
Loading
Loading
@@ -45,7 +45,7 @@ module Ci
Loading
@@ -45,7 +45,7 @@ module Ci
   
def attachment_message def attachment_message
out = "<#{ci_project_url(project)}|#{project_name}>: " out = "<#{ci_project_url(project)}|#{project_name}>: "
out << "Commit <#{ci_namespace_project_commit_url(commit.gl_project.namespace, commit.gl_project, commit.sha)}|\##{commit.id}> " out << "Commit <#{builds_namespace_project_commit_url(commit.gl_project.namespace, commit.gl_project, commit.sha)}|\##{commit.id}> "
out << "(<#{commit_sha_link}|#{commit.short_sha}>) " out << "(<#{commit_sha_link}|#{commit.short_sha}>) "
out << "of <#{commit_ref_link}|#{commit.ref}> " out << "of <#{commit_ref_link}|#{commit.ref}> "
out << "by #{commit.git_author_name} " if commit.git_author_name out << "by #{commit.git_author_name} " if commit.git_author_name
Loading
Loading
Loading
@@ -71,7 +71,7 @@ class GitlabCiService < CiService
Loading
@@ -71,7 +71,7 @@ class GitlabCiService < CiService
   
def build_page(sha, ref) def build_page(sha, ref)
if project.gitlab_ci_project.present? if project.gitlab_ci_project.present?
ci_namespace_project_commit_url(project.namespace, project, sha) builds_namespace_project_commit_url(project.namespace, project, sha)
end end
end end
   
Loading
Loading
Loading
@@ -7,7 +7,7 @@
Loading
@@ -7,7 +7,7 @@
= @project.name = @project.name
   
%p %p
Commit link: #{gitlab_commit_link(@project, @build.commit.short_sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_path(@build.gl_project.namespace, @build.gl_project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.commit.git_author_name}
%p %p
Loading
@@ -16,4 +16,4 @@
Loading
@@ -16,4 +16,4 @@
Message: #{@build.commit.git_commit_message} Message: #{@build.commit.git_commit_message}
   
%p %p
Url: #{link_to @build.short_sha, namespace_project_build_url(@build.gl_project.namespace, @build.gl_project, @build)} Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.gl_project.namespace, @build.gl_project, @build)}
Loading
@@ -8,7 +8,7 @@
Loading
@@ -8,7 +8,7 @@
= @project.name = @project.name
   
%p %p
Commit link: #{gitlab_commit_link(@project, @build.commit.short_sha)} Commit: #{link_to @build.short_sha, namespace_project_commit_path(@build.gl_project.namespace, @build.gl_project, @build.sha)}
%p %p
Author: #{@build.commit.git_author_name} Author: #{@build.commit.git_author_name}
%p %p
Loading
@@ -17,4 +17,4 @@
Loading
@@ -17,4 +17,4 @@
Message: #{@build.commit.git_commit_message} Message: #{@build.commit.git_commit_message}
   
%p %p
Url: #{link_to @build.short_sha, namespace_project_build_url(@build.gl_project.namespace, @build.gl_project, @build)} Build details: #{link_to "Build #{@build.id}", namespace_project_build_url(@build.gl_project.namespace, @build.gl_project, @build)}
Loading
@@ -16,4 +16,4 @@
Loading
@@ -16,4 +16,4 @@
- group = group_member.group - group = group_member.group
= render 'shared/groups/group', group: group, group_member: group_member = render 'shared/groups/group', group: group, group_member: group_member
   
= paginate @group_members = paginate @group_members, theme: 'gitlab'
Loading
@@ -25,6 +25,15 @@
Loading
@@ -25,6 +25,15 @@
%hr %hr
= link_to 'Remove avatar', group_avatar_path(@group.to_param), data: { confirm: "Group avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-avatar" = link_to 'Remove avatar', group_avatar_path(@group.to_param), data: { confirm: "Group avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-avatar"
   
.form-group
%hr
= f.label :public, class: 'control-label' do
Public
.col-sm-10
.checkbox
= f.check_box :public
%span.descr Make this group public (even if there is no any public project inside this group)
.form-actions .form-actions
= f.submit 'Save group', class: "btn btn-save" = f.submit 'Save group', class: "btn btn-save"
   
Loading
Loading
Loading
@@ -9,23 +9,25 @@
Loading
@@ -9,23 +9,25 @@
= nav_link path: 'projects#index' do = nav_link path: 'projects#index' do
= link_to ci_admin_projects_path do = link_to ci_admin_projects_path do
= icon('list-alt fw') = icon('list-alt fw')
Projects %span
Projects
= nav_link path: 'events#index' do = nav_link path: 'events#index' do
= link_to ci_admin_events_path do = link_to ci_admin_events_path do
= icon('book fw') = icon('book fw')
Events %span
Events
= nav_link path: ['runners#index', 'runners#show'] do = nav_link path: ['runners#index', 'runners#show'] do
= link_to ci_admin_runners_path do = link_to ci_admin_runners_path do
= icon('cog fw') = icon('cog fw')
Runners %span
%small.pull-right Runners
= Ci::Runner.count(:all) %span.count= Ci::Runner.count(:all)
= nav_link path: 'builds#index' do = nav_link path: 'builds#index' do
= link_to ci_admin_builds_path do = link_to ci_admin_builds_path do
= icon('link fw') = icon('link fw')
Builds %span
%small.pull-right Builds
= Ci::Build.count(:all) %span.count= Ci::Build.count(:all)
= nav_link(controller: :application_settings, html_options: { class: 'separate-item'}) do = nav_link(controller: :application_settings, html_options: { class: 'separate-item'}) do
= link_to ci_admin_application_settings_path do = link_to ci_admin_application_settings_path do
= icon('cogs fw') = icon('cogs fw')
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