Commit b9119b47 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-01-12

# Conflicts:
#	app/assets/stylesheets/pages/projects.scss
#	app/models/project.rb
#	app/models/repository.rb

[ci skip]
parents 00f95297 214cf9c2
...@@ -907,6 +907,7 @@ a.allowed-to-push { ...@@ -907,6 +907,7 @@ a.allowed-to-push {
} }
} }
<<<<<<< HEAD
.protected-branch-push-access-list, .protected-branch-push-access-list,
.protected-branch-merge-access-list { .protected-branch-merge-access-list {
a { a {
...@@ -914,6 +915,8 @@ a.allowed-to-push { ...@@ -914,6 +915,8 @@ a.allowed-to-push {
} }
} }
=======
>>>>>>> upstream/master
.protected-branches-list, .protected-branches-list,
.protected-tags-list { .protected-tags-list {
margin-bottom: 30px; margin-bottom: 30px;
......
...@@ -342,10 +342,11 @@ class Commit ...@@ -342,10 +342,11 @@ class Commit
@merged_merge_request_hash[current_user] @merged_merge_request_hash[current_user]
end end
def has_been_reverted?(current_user, noteable = self) def has_been_reverted?(current_user, notes_association = nil)
ext = all_references(current_user) ext = all_references(current_user)
notes_association ||= notes_with_associations
noteable.notes_with_associations.system.each do |note| notes_association.system.each do |note|
note.all_references(current_user, extractor: ext) note.all_references(current_user, extractor: ext)
end end
......
...@@ -1008,7 +1008,16 @@ class MergeRequest < ActiveRecord::Base ...@@ -1008,7 +1008,16 @@ class MergeRequest < ActiveRecord::Base
end end
def can_be_reverted?(current_user) def can_be_reverted?(current_user)
merge_commit && !merge_commit.has_been_reverted?(current_user, self) return false unless merge_commit
merged_at = metrics&.merged_at
notes_association = notes_with_associations
if merged_at
notes_association = notes_association.where('created_at > ?', merged_at)
end
!merge_commit.has_been_reverted?(current_user, notes_association)
end end
def can_be_cherry_picked? def can_be_cherry_picked?
......
...@@ -21,9 +21,12 @@ class Project < ActiveRecord::Base ...@@ -21,9 +21,12 @@ class Project < ActiveRecord::Base
include Gitlab::SQL::Pattern include Gitlab::SQL::Pattern
include DeploymentPlatform include DeploymentPlatform
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
<<<<<<< HEAD
# EE specific modules # EE specific modules
prepend EE::Project prepend EE::Project
=======
>>>>>>> upstream/master
extend Gitlab::ConfigHelper extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings extend Gitlab::CurrentSettings
......
...@@ -910,6 +910,7 @@ class Repository ...@@ -910,6 +910,7 @@ class Repository
end end
end end
<<<<<<< HEAD
def fetch_upstream(url) def fetch_upstream(url)
add_remote(Repository::MIRROR_REMOTE, url) add_remote(Repository::MIRROR_REMOTE, url)
fetch_remote(Repository::MIRROR_REMOTE, ssh_auth: project&.import_data) fetch_remote(Repository::MIRROR_REMOTE, ssh_auth: project&.import_data)
...@@ -952,6 +953,8 @@ class Repository ...@@ -952,6 +953,8 @@ class Repository
end end
end end
=======
>>>>>>> upstream/master
def root_ref_sha def root_ref_sha
@root_ref_sha ||= commit(root_ref).sha @root_ref_sha ||= commit(root_ref).sha
end end
......
---
title: Speed up loading merged merge requests when they contained a lot of commits
before merging
merge_request: 16320
author:
type: performance
...@@ -151,11 +151,11 @@ describe CommitRange do ...@@ -151,11 +151,11 @@ describe CommitRange do
.with(commit1, user) .with(commit1, user)
.and_return(true) .and_return(true)
expect(commit1.has_been_reverted?(user, issue)).to eq(true) expect(commit1.has_been_reverted?(user, issue.notes_with_associations)).to eq(true)
end end
it 'returns false a commit has not been reverted' do it 'returns false if the commit has not been reverted' do
expect(commit1.has_been_reverted?(user, issue)).to eq(false) expect(commit1.has_been_reverted?(user, issue.notes_with_associations)).to eq(false)
end end
end end
end end
...@@ -1239,6 +1239,83 @@ describe MergeRequest do ...@@ -1239,6 +1239,83 @@ describe MergeRequest do
end end
end end
describe '#can_be_reverted?' do
context 'when there is no merged_at for the MR' do
before do
subject.metrics.update!(merged_at: nil)
end
it 'returns false' do
expect(subject.can_be_reverted?(nil)).to be_falsey
end
end
context 'when there is no merge_commit for the MR' do
before do
subject.metrics.update!(merged_at: Time.now.utc)
end
it 'returns false' do
expect(subject.can_be_reverted?(nil)).to be_falsey
end
end
context 'when the MR has been merged' do
before do
MergeRequests::MergeService
.new(subject.target_project, subject.author)
.execute(subject)
end
context 'when there is no revert commit' do
it 'returns true' do
expect(subject.can_be_reverted?(nil)).to be_truthy
end
end
context 'when there is a revert commit' do
let(:current_user) { subject.author }
let(:branch) { subject.target_branch }
let(:project) { subject.target_project }
let(:revert_commit_id) do
params = {
commit: subject.merge_commit,
branch_name: branch,
start_branch: branch
}
Commits::RevertService.new(project, current_user, params).execute[:result]
end
before do
project.add_master(current_user)
ProcessCommitWorker.new.perform(project.id,
current_user.id,
project.commit(revert_commit_id).to_hash,
project.default_branch == branch)
end
context 'when the revert commit is mentioned in a note after the MR was merged' do
it 'returns false' do
expect(subject.can_be_reverted?(current_user)).to be_falsey
end
end
context 'when the revert commit is mentioned in a note before the MR was merged' do
before do
subject.notes.last.update!(created_at: subject.metrics.merged_at - 1.second)
end
it 'returns true' do
expect(subject.can_be_reverted?(current_user)).to be_truthy
end
end
end
end
end
describe '#participants' do describe '#participants' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
......
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