Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
a64f1c76
Commit
a64f1c76
authored
Apr 12, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add changelog entry, improve specs and model code
parent
476cf23f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
14 deletions
+9
-14
CHANGELOG
CHANGELOG
+1
-0
app/models/merge_request.rb
app/models/merge_request.rb
+4
-9
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+4
-5
No files found.
CHANGELOG
View file @
a64f1c76
...
...
@@ -17,6 +17,7 @@ v 8.7.0 (unreleased)
- Add links to CI setup documentation from project settings and builds pages
- Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion
- Allow to close merge requests which source projects(forks) are deleted.
- Ensure empty recipients are rejected in BuildsEmailService
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
...
...
app/models/merge_request.rb
View file @
a64f1c76
...
...
@@ -128,7 +128,7 @@ class MergeRequest < ActiveRecord::Base
validates
:target_project
,
presence:
true
validates
:target_branch
,
presence:
true
validates
:merge_user
,
presence:
true
,
if: :merge_when_build_succeeds?
validate
:validate_branches
validate
:validate_branches
,
unless: :allow_broken
validate
:validate_fork
scope
:by_branch
,
->
(
branch_name
)
{
where
(
"(source_branch LIKE :branch) OR (target_branch LIKE :branch)"
,
branch:
branch_name
)
}
...
...
@@ -213,14 +213,12 @@ class MergeRequest < ActiveRecord::Base
end
def
validate_branches
return
if
allow_broken
if
target_project
==
source_project
&&
target_branch
==
source_branch
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
end
if
opened?
||
reopened?
similar_mrs
=
self
.
target_project
.
merge_requests
.
where
(
source_branch:
source_branch
,
target_branch:
target_branch
,
source_project_id:
source_project
.
id
).
opened
similar_mrs
=
self
.
target_project
.
merge_requests
.
where
(
source_branch:
source_branch
,
target_branch:
target_branch
,
source_project_id:
source_project
.
try
(
:id
)
).
opened
similar_mrs
=
similar_mrs
.
where
(
'id not in (?)'
,
self
.
id
)
if
self
.
id
if
similar_mrs
.
any?
errors
.
add
:validate_branches
,
...
...
@@ -346,12 +344,9 @@ class MergeRequest < ActiveRecord::Base
end
def
hook_attrs
source_hook_attrs
=
source_project
.
hook_attrs
if
source_project
.
present?
target_hook_attrs
=
target_project
.
hook_attrs
if
target_project
.
present?
attrs
=
{
source:
source_
hook_attrs
,
target:
target_hook_attrs
,
source:
source_
project
.
try
(
:hook_attrs
)
,
target:
target_
project
.
hook_attrs
,
last_commit:
nil
,
work_in_progress:
work_in_progress?
}
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
a64f1c76
...
...
@@ -161,17 +161,16 @@ describe Projects::MergeRequestsController do
context
'there is no source project'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
{
create
(
:forked_project_with_submodules
)
}
let
(
:merge_request
)
{
create
(
:merge_request
_with_diffs
,
source_project:
fork_project
,
source_branch:
'add-submodule-version-bump'
,
target_branch:
'master'
,
target_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
fork_project
,
source_branch:
'add-submodule-version-bump'
,
target_branch:
'master'
,
target_project:
project
)
}
before
do
fork_project
.
build_forked_project_link
(
forked_to_project_id:
fork_project
.
id
,
forked_from_project_id:
project
.
id
)
fork_project
.
save
merge_request
.
reload
fork_project
.
destroy
end
it
'closes MR without errors'
do
fork_project
.
destroy
post
:update
,
namespace_id:
project
.
namespace
.
path
,
project_id:
project
.
path
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment