summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--app/controllers/projects/avatars_controller.rb2
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/project.rb1
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/views/projects/commit/_ci_stage.html.haml4
-rw-r--r--doc/development/doc_styleguide.md2
-rw-r--r--doc/user/project/img/issue_board.pngbin200614 -> 275093 bytes
-rw-r--r--doc/workflow/merge_requests.md2
-rw-r--r--spec/models/project_spec.rb31
12 files changed, 44 insertions, 8 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 46dfe2fd355..4e12f5d4f00 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,8 @@ v 8.12.0 (unreleased)
- Automatically expand hidden discussions when accessed by a permalink !5585 (Mike Greiling)
- Added tests for diff notes
- Added 'only_allow_merge_if_build_succeeds' project setting in the API. !5930 (Duck)
+ - Reduce number of database queries on builds tab
+ - Use the default branch for displaying the project icon instead of master !5792 (Hannes Rosenögger)
v 8.11.2 (unreleased)
- Show "Create Merge Request" widget for push events to fork projects on the source project
diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb
index 5962f74c39b..ada7db3c552 100644
--- a/app/controllers/projects/avatars_controller.rb
+++ b/app/controllers/projects/avatars_controller.rb
@@ -4,7 +4,7 @@ class Projects::AvatarsController < Projects::ApplicationController
before_action :authorize_admin_project!, only: [:destroy]
def show
- @blob = @repository.blob_at_branch('master', @project.avatar_in_git)
+ @blob = @repository.blob_at_branch(@repository.root_ref, @project.avatar_in_git)
if @blob
headers['X-Content-Type-Options'] = 'nosniff'
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 096b3b801af..23c8de6f650 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -352,7 +352,7 @@ module Ci
end
def artifacts?
- !artifacts_expired? && artifacts_file.exists?
+ !artifacts_expired? && self[:artifacts_file].present?
end
def artifacts_metadata?
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 087abe4cbb1..aff908ea16c 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -83,7 +83,7 @@ module Ci
end
def stages_with_latest_statuses
- statuses.latest.order(:stage_idx).group_by(&:stage)
+ statuses.latest.includes(project: :namespace).order(:stage_idx).group_by(&:stage)
end
def project_id
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 84ceeac7d3e..1b403fa646d 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -25,6 +25,8 @@ class CommitStatus < ActiveRecord::Base
scope :retried, -> { where.not(id: latest) }
scope :ordered, -> { order(:name) }
scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) }
+ scope :latest_ci_stages, -> { latest.ordered.includes(project: :namespace) }
+ scope :retried_ci_stages, -> { retried.ordered.includes(project: :namespace) }
state_machine :status do
event :enqueue do
diff --git a/app/models/project.rb b/app/models/project.rb
index 8cf093be4c3..0e4fb94f8eb 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1035,6 +1035,7 @@ class Project < ActiveRecord::Base
"refs/heads/#{branch}",
force: true)
repository.copy_gitattributes(branch)
+ repository.expire_avatar_cache(branch)
reload_default_branch
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index bdc3b9d1c1c..91bdafdac99 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1065,7 +1065,7 @@ class Repository
@avatar ||= cache.fetch(:avatar) do
AVATAR_FILES.find do |file|
- blob_at_branch('master', file)
+ blob_at_branch(root_ref, file)
end
end
end
diff --git a/app/views/projects/commit/_ci_stage.html.haml b/app/views/projects/commit/_ci_stage.html.haml
index 9d925cacc0d..6bb900e3fc1 100644
--- a/app/views/projects/commit/_ci_stage.html.haml
+++ b/app/views/projects/commit/_ci_stage.html.haml
@@ -8,8 +8,8 @@
- if stage
&nbsp;
= stage.titleize
- = render statuses.latest.ordered, coverage: @project.build_coverage_enabled?, stage: false, ref: false, allow_retry: true
- = render statuses.retried.ordered, coverage: @project.build_coverage_enabled?, stage: false, ref: false, retried: true
+ = render statuses.latest_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, allow_retry: true
+ = render statuses.retried_ci_stages, coverage: @project.build_coverage_enabled?, stage: false, ref: false, retried: true
%tr
%td{colspan: 10}
&nbsp;
diff --git a/doc/development/doc_styleguide.md b/doc/development/doc_styleguide.md
index 927a1872413..dc7d832ce3a 100644
--- a/doc/development/doc_styleguide.md
+++ b/doc/development/doc_styleguide.md
@@ -6,7 +6,7 @@ it organized and easy to find.
## Location and naming of documents
>**Note:**
-These guidelines derive from the discussion taken place in issue [#3349](ce-3349).
+These guidelines derive from the discussion taken place in issue [#3349][ce-3349].
The documentation hierarchy can be vastly improved by providing a better layout
and organization of directories.
diff --git a/doc/user/project/img/issue_board.png b/doc/user/project/img/issue_board.png
index accd0900cbb..63c269f6dbc 100644
--- a/doc/user/project/img/issue_board.png
+++ b/doc/user/project/img/issue_board.png
Binary files differ
diff --git a/doc/workflow/merge_requests.md b/doc/workflow/merge_requests.md
index 91fcfb02d39..334a119e522 100644
--- a/doc/workflow/merge_requests.md
+++ b/doc/workflow/merge_requests.md
@@ -53,7 +53,7 @@ It should look like this:
fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
```
-Now you can fetch all the merge requests requests:
+Now you can fetch all the merge requests:
```
$ git fetch origin
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 9a3660012f9..b2baeeb31bb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1442,4 +1442,35 @@ describe Project, models: true do
expect(shared_project.authorized_for_user?(master, Gitlab::Access::MASTER)).to be(true)
end
end
+
+ describe 'change_head' do
+ let(:project) { create(:project) }
+
+ it 'calls the before_change_head method' do
+ expect(project.repository).to receive(:before_change_head)
+ project.change_head(project.default_branch)
+ end
+
+ it 'creates the new reference with rugged' do
+ expect(project.repository.rugged.references).to receive(:create).with('HEAD',
+ "refs/heads/#{project.default_branch}",
+ force: true)
+ project.change_head(project.default_branch)
+ end
+
+ it 'copies the gitattributes' do
+ expect(project.repository).to receive(:copy_gitattributes).with(project.default_branch)
+ project.change_head(project.default_branch)
+ end
+
+ it 'expires the avatar cache' do
+ expect(project.repository).to receive(:expire_avatar_cache).with(project.default_branch)
+ project.change_head(project.default_branch)
+ end
+
+ it 'reloads the default branch' do
+ expect(project).to receive(:reload_default_branch)
+ project.change_head(project.default_branch)
+ end
+ end
end