Commit 6fcfda2a authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-09-18

# Conflicts:
#	doc/install/requirements.md
#	spec/views/help/index.html.haml_spec.rb

[ci skip]
parents 99b12b1d a2a00a5e
......@@ -151,7 +151,7 @@ the remaining issues on the GitHub issue tracker.
## I want to contribute!
If you want to contribute to GitLab, [issues in the `Backlog (Accepting merge requests)` milestone with small weight][https://gitlab.com/gitlab-org/gitlab-ce/issues?scope=all&utf8=✓&state=opened&assignee_id=0&milestone_title=Backlog%20(Accepting%20merge%20requests)]
If you want to contribute to GitLab, [issues in the Backlog (Accepting merge requests)](https://gitlab.com/gitlab-org/gitlab-ce/issues?scope=all&utf8=✓&state=opened&assignee_id=0&milestone_title=Backlog%20(Accepting%20merge%20requests))
are a great place to start. Issues with a lower weight (1 or 2) are deemed
suitable for beginners. These issues will be of reasonable size and challenge,
for anyone to start contributing to GitLab. If you have any questions or need help visit [Getting Help](https://about.gitlab.com/getting-help/#discussion) to
......
......@@ -123,11 +123,6 @@ module CiStatusHelper
render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement)
end
def no_runners_for_project?(project)
project.runners.blank? &&
Ci::Runner.instance_type.blank?
end
def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body', icon_size: 16)
klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}"
title = "#{type.titleize}: #{ci_label_for_status(status)}"
......
......@@ -198,11 +198,12 @@ class ProjectWiki
def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title)
git_user = Gitlab::Git::User.from_gitlab(@user)
Gitlab::Git::Wiki::CommitDetails.new(@user.id,
@user.username,
@user.name,
@user.email,
git_user.username,
git_user.name,
git_user.email,
commit_message)
end
......
......@@ -1204,13 +1204,13 @@ class User < ActiveRecord::Base
def assigned_open_merge_requests_count(force: false)
Rails.cache.fetch(['users', id, 'assigned_open_merge_requests_count'], force: force, expires_in: 20.minutes) do
MergeRequestsFinder.new(self, assignee_id: self.id, state: 'opened').execute.count
MergeRequestsFinder.new(self, assignee_id: self.id, state: 'opened', non_archived: true).execute.count
end
end
def assigned_open_issues_count(force: false)
Rails.cache.fetch(['users', id, 'assigned_open_issues_count'], force: force, expires_in: 20.minutes) do
IssuesFinder.new(self, assignee_id: self.id, state: 'opened').execute.count
IssuesFinder.new(self, assignee_id: self.id, state: 'opened', non_archived: true).execute.count
end
end
......
......@@ -79,6 +79,20 @@ class BuildDetailsEntity < JobEntity
expose :trigger_variables, as: :variables, using: TriggerVariableEntity
end
expose :runners do
expose :online do |build|
build.any_runners_online?
end
expose :available do |build|
project.any_runners?
end
expose :settings_path, if: -> (*) { can_admin_build? } do |build|
project_runners_path(project)
end
end
private
def build_failed_issue_options
......@@ -97,4 +111,8 @@ class BuildDetailsEntity < JobEntity
def can_create_build_terminal?
can?(current_user, :create_build_terminal, build) && build.has_terminal?
end
def can_admin_build?
can?(request.current_user, :admin_build, project)
end
end
......@@ -57,6 +57,7 @@ module Boards
set_parent
set_state
set_scope
set_non_archived
params
end
......@@ -77,6 +78,10 @@ module Boards
params[:include_subgroups] = board.group_board?
end
def set_non_archived
params[:non_archived] = parent.is_a?(Group)
end
# rubocop: disable CodeReuse/ActiveRecord
def board_label_ids
@board_label_ids ||= board.lists.movable.pluck(:label_id)
......
......@@ -7,8 +7,10 @@ module Files
def initialize(*args)
super
@author_email = params[:author_email] || current_user&.email
@author_name = params[:author_name] || current_user&.name
git_user = Gitlab::Git::User.from_gitlab(current_user) if current_user.present?
@author_email = params[:author_email] || git_user&.email
@author_name = params[:author_name] || git_user&.name
@commit_message = params[:commit_message]
@last_commit_sha = params[:last_commit_sha]
......
......@@ -10,7 +10,7 @@
- unless @build.any_runners_online?
.bs-callout.bs-callout-warning.js-build-stuck
%p
- if no_runners_for_project?(@build.project)
- if @project.any_runners?
This job is stuck, because the project doesn't have any runners online assigned to it.
- elsif @build.tags.any?
This job is stuck, because you don't have any active runners online with any of these tags assigned to them:
......
---
title: Issue and MR count now ignores archived projects
merge_request: 21721
author:
type: fixed
---
title: No longer show open issues from archived projects in group issue board
merge_request: 21721
author:
type: fixed
---
title: Expose project runners in job API
merge_request: 21618
author:
type: other
---
title: Respect the user commit email in more places
merge_request: 21773
author:
type: fixed
......@@ -104,9 +104,13 @@ features of GitLab work with MySQL/MariaDB:
1. MySQL support for subgroups was [dropped with GitLab 9.3][post].
See [issue #30472][30472] for more information.
1. Geo **[STARTER ONLY]** does [not support MySQL](https://docs.gitlab.com/ee/gitlab-geo/database.html#mysql-replication). This means no supported Disaster Recovery solution if using MySQL.
<<<<<<< HEAD
1. [Zero downtime migrations][zero] do not work with MySQL.
1. [Database load balancing](../administration/database_load_balancing.md) is
supported only for PostgreSQL.
=======
1. [Zero downtime migrations][../update/README.md#upgrading-without-downtime] do not work with MySQL.
>>>>>>> upstream/master
1. GitLab [optimizes the loading of dashboard events](https://gitlab.com/gitlab-org/gitlab-ce/issues/31806) using [PostgreSQL LATERAL JOINs](https://blog.heapanalytics.com/postgresqls-powerful-new-join-type-lateral/).
1. In general, SQL optimized for PostgreSQL may run much slower in MySQL due to
differences in query planners. For example, subqueries that work well in PostgreSQL
......@@ -120,7 +124,6 @@ Existing users using GitLab with MySQL/MariaDB are advised to
[migrate to PostgreSQL](../update/mysql_to_postgresql.md) instead.
[30472]: https://gitlab.com/gitlab-org/gitlab-ce/issues/30472
[zero]: ../update/README.md#upgrading-without-downtime
[post]: https://about.gitlab.com/2017/06/22/gitlab-9-3-released/#dropping-support-for-subgroups-in-mysql
### PostgreSQL Requirements
......
......@@ -591,10 +591,6 @@ module Gitlab
end
end
def user_to_committer(user)
Gitlab::Git.committer_hash(email: user.email, name: user.name)
end
# Delete the specified branch from the repository
def delete_branch(branch_name)
wrapped_gitaly_errors do
......
......@@ -288,6 +288,55 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
end
context 'when no runners are available' do
let(:runner) { create(:ci_runner, :instance, active: false) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
it 'exposes needed information' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details')
expect(json_response['runners']['online']).to be false
expect(json_response['runners']['available']).to be false
end
end
context 'when no runner is online' do
let(:runner) { create(:ci_runner, :instance) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
it 'exposes needed information' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details')
expect(json_response['runners']['online']).to be false
expect(json_response['runners']['available']).to be true
end
end
context 'settings_path' do
context 'when user is developer' do
it 'settings_path is not available' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details')
expect(json_response['runners']).not_to have_key('settings_path')
end
end
context 'when user is maintainer' do
let(:user) { create(:user, :admin) }
before do
project.add_maintainer(user)
sign_in(user)
end
it 'settings_path is available' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('job/job_details')
expect(json_response['runners']['settings_path']).to match(/runners/)
end
end
end
end
context 'when requesting JSON job is triggered' do
......
......@@ -62,6 +62,14 @@ FactoryBot.define do
project_view :readme
end
trait :commit_email do
after(:create) do |user, evaluator|
additional = create(:email, :confirmed, user: user, email: "commit-#{user.email}")
user.update!(commit_email: additional.email)
end
end
factory :omniauth_user do
transient do
extern_uid '123456'
......
......@@ -533,7 +533,7 @@ describe 'File blob', :js do
expect(page).to have_content('This project is licensed under the MIT License.')
# shows a learn more link
expect(page).to have_link('Learn more', 'http://choosealicense.com/licenses/mit/')
expect(page).to have_link('Learn more', href: 'http://choosealicense.com/licenses/mit/')
end
end
end
......@@ -566,10 +566,10 @@ describe 'File blob', :js do
expect(page).to have_content('This project manages its dependencies using RubyGems and defines a gem named activerecord.')
# shows a link to the gem
expect(page).to have_link('activerecord', 'https://rubygems.org/gems/activerecord')
expect(page).to have_link('activerecord', href: 'https://rubygems.org/gems/activerecord')
# shows a learn more link
expect(page).to have_link('Learn more', 'http://choosealicense.com/licenses/mit/')
expect(page).to have_link('Learn more', href: 'https://rubygems.org/')
end
end
end
......
......@@ -8,6 +8,7 @@
"terminal_path": { "type": "string" },
"trigger": { "$ref": "trigger.json" },
"deployment_status": { "$ref": "deployment_status.json" },
"runner": { "$ref": "runner.json" }
"runner": { "$ref": "runner.json" },
"runners": { "type": "runners.json" }
}
}
{
"type": "object",
"required": [
"online",
"available"
],
"properties": {
"online": { "type": "boolean" },
"available": { "type": "boolean" },
"settings_path": { "type": "string" }
},
"additionalProperties": false
}
......@@ -2,12 +2,13 @@
require "spec_helper"
describe ProjectWiki do
let(:project) { create(:project, :wiki_repo) }
let(:user) { create(:user, :commit_email) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
let(:repository) { project.repository }
let(:user) { project.owner }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_wiki) { described_class.new(project, user) }
let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + '.git', 'foo') }
let(:commit) { project_wiki.repository.head_commit }
subject { project_wiki }
......@@ -284,6 +285,14 @@ describe ProjectWiki do
expect(subject.pages.first.page.version.message).to eq("commit message")
end
it 'sets the correct commit email' do
subject.create_page('test page', 'content')
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
it 'updates project activity' do
subject.create_page('Test Page', 'This is content')
......@@ -328,6 +337,12 @@ describe ProjectWiki do
expect(@page.version.message).to eq("updated page")
end
it 'sets the correct commit email' do
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
it 'updates project activity' do
subject.update_page(
@gitlab_git_wiki_page,
......@@ -355,6 +370,14 @@ describe ProjectWiki do
expect(subject.pages.count).to eq(0)
end
it 'sets the correct commit email' do
subject.delete_page(@page)
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
it 'updates project activity' do
subject.delete_page(@page)
......@@ -428,7 +451,7 @@ describe ProjectWiki do
end
def commit_details
Gitlab::Git::Wiki::CommitDetails.new(user.id, user.username, user.name, user.email, "test commit")
Gitlab::Git::Wiki::CommitDetails.new(user.id, user.username, user.name, user.commit_email, "test commit")
end
def create_page(name, content)
......
......@@ -2646,6 +2646,34 @@ describe User do
end
end
describe '#assigned_open_merge_requests_count' do
it 'returns number of open merge requests from non-archived projects' do
user = create(:user)
project = create(:project, :public)
archived_project = create(:project, :public, :archived)
create(:merge_request, source_project: project, author: user, assignee: user)
create(:merge_request, :closed, source_project: project, author: user, assignee: user)
create(:merge_request, source_project: archived_project, author: user, assignee: user)
expect(user.assigned_open_merge_requests_count(force: true)).to eq 1
end
end
describe '#assigned_open_issues_count' do
it 'returns number of open issues from non-archived projects' do
user = create(:user)
project = create(:project, :public)
archived_project = create(:project, :public, :archived)
create(:issue, project: project, author: user, assignees: [user])
create(:issue, :closed, project: project, author: user, assignees: [user])
create(:issue, project: archived_project, author: user, assignees: [user])
expect(user.assigned_open_issues_count(force: true)).to eq 1
end
end
describe '#personal_projects_count' do
it 'returns the number of personal projects using a single query' do
user = build(:user)
......
......@@ -24,7 +24,7 @@ describe Boards::Issues::ListService do
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2]) }
let!(:reopened_issue1) { create(:issue, :opened, project: project, title: 'Issue 3' ) }
let!(:reopened_issue1) { create(:issue, :opened, project: project, title: 'Reopened Issue 1' ) }
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) }
let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
......@@ -44,12 +44,19 @@ describe Boards::Issues::ListService do
end
it_behaves_like 'issues list service'
context 'when project is archived' do
let(:project) { create(:project, :archived) }
it_behaves_like 'issues list service'
end
end
context 'when parent is a group' do
let(:user) { create(:user) }
let(:project) { create(:project, :empty_repo, namespace: group) }
let(:project1) { create(:project, :empty_repo, namespace: group) }
let(:project_archived) { create(:project, :empty_repo, :archived, namespace: group) }
let(:m1) { create(:milestone, group: group) }
let(:m2) { create(:milestone, group: group) }
......@@ -77,7 +84,8 @@ describe Boards::Issues::ListService do
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2, p2_project]) }
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Issue 3', closed_at: Time.now ) }
let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: 'Issue 3', labels: [bug]) }
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Reopened Issue 1', closed_at: Time.now ) }
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, p2_project, development]) }
let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
......
......@@ -3,7 +3,7 @@ require "spec_helper"
describe Files::CreateService do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:user) { create(:user, :commit_email) }
let(:file_content) { 'Test file content' }
let(:branch_name) { project.default_branch }
let(:start_branch) { branch_name }
......@@ -20,6 +20,8 @@ describe Files::CreateService do
}
end
let(:commit) { repository.head_commit }
subject { described_class.new(project, user, commit_params) }
before do
......@@ -75,4 +77,16 @@ describe Files::CreateService do
end
end
end
context 'commit attribute' do
let(:file_path) { 'test-commit-attributes.txt' }
it 'uses the commit email' do
subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
end
end
......@@ -4,10 +4,11 @@ describe Files::DeleteService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil }
let(:commit) { project.repository.head_commit }
let(:commit_params) do
{
......@@ -34,6 +35,14 @@ describe Files::DeleteService do
expect(blob).to be_nil
end
it 'uses the commit email' do
subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
end
before do
......
......@@ -4,11 +4,12 @@ describe Files::UpdateService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:new_contents) { 'New Content' }
let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil }
let(:commit) { project.repository.commit }
let(:commit_params) do
{
......@@ -54,6 +55,14 @@ describe Files::UpdateService do
expect(results.data).to eq(new_contents)
end
it 'uses the commit email' do
subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
end
context "when the last_commit_sha is not supplied" do
......
......@@ -21,7 +21,11 @@ describe 'help/index' do
render
expect(rendered).to match '8.0.2'
<<<<<<< HEAD
expect(rendered).to have_link('abcdefg', 'https://gitlab.com/gitlab-org/gitlab-ee/commits/abcdefg')
=======
expect(rendered).to have_link('abcdefg', href: 'https://gitlab.com/gitlab-org/gitlab-ce/commits/abcdefg')
>>>>>>> upstream/master
end
end
......@@ -29,7 +33,7 @@ describe 'help/index' do
it 'is visible to guests' do
render
expect(rendered).to have_link(nil, help_instance_configuration_url)
expect(rendered).to have_link(nil, href: help_instance_configuration_url)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment