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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
47d19c2d
Commit
47d19c2d
authored
Oct 10, 2017
by
Andrew Newdigate
Committed by
Rémy Coutable
Oct 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using `branch_names.include?` and use `branch_exists?`
parent
900dd7fa
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
10 deletions
+15
-10
app/helpers/compare_helper.rb
app/helpers/compare_helper.rb
+2
-2
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+1
-1
changelogs/unreleased/an-use-branch-exists-over-branch-names-include.yml
...leased/an-use-branch-exists-over-branch-names-include.yml
+5
-0
spec/controllers/projects/branches_controller_spec.rb
spec/controllers/projects/branches_controller_spec.rb
+1
-1
spec/features/projects/issuable_templates_spec.rb
spec/features/projects/issuable_templates_spec.rb
+1
-1
spec/features/projects/merge_requests/user_views_open_merge_request_spec.rb
...ects/merge_requests/user_views_open_merge_request_spec.rb
+1
-1
spec/features/task_lists_spec.rb
spec/features/task_lists_spec.rb
+1
-1
spec/serializers/merge_request_entity_spec.rb
spec/serializers/merge_request_entity_spec.rb
+1
-1
No files found.
app/helpers/compare_helper.rb
View file @
47d19c2d
...
@@ -4,8 +4,8 @@ module CompareHelper
...
@@ -4,8 +4,8 @@ module CompareHelper
to
.
present?
&&
to
.
present?
&&
from
!=
to
&&
from
!=
to
&&
can?
(
current_user
,
:create_merge_request
,
project
)
&&
can?
(
current_user
,
:create_merge_request
,
project
)
&&
project
.
repository
.
branch_
names
.
include
?
(
from
)
&&
project
.
repository
.
branch_
exists
?
(
from
)
&&
project
.
repository
.
branch_
names
.
include
?
(
to
)
project
.
repository
.
branch_
exists
?
(
to
)
end
end
def
create_mr_path
(
from
=
params
[
:from
],
to
=
params
[
:to
],
project
=
@project
)
def
create_mr_path
(
from
=
params
[
:from
],
to
=
params
[
:to
],
project
=
@project
)
...
...
app/models/merge_request.rb
View file @
47d19c2d
...
@@ -675,13 +675,13 @@ class MergeRequest < ActiveRecord::Base
...
@@ -675,13 +675,13 @@ class MergeRequest < ActiveRecord::Base
def
source_branch_exists?
def
source_branch_exists?
return
false
unless
self
.
source_project
return
false
unless
self
.
source_project
self
.
source_project
.
repository
.
branch_
names
.
include
?
(
self
.
source_branch
)
self
.
source_project
.
repository
.
branch_
exists
?
(
self
.
source_branch
)
end
end
def
target_branch_exists?
def
target_branch_exists?
return
false
unless
self
.
target_project
return
false
unless
self
.
target_project
self
.
target_project
.
repository
.
branch_
names
.
include
?
(
self
.
target_branch
)
self
.
target_project
.
repository
.
branch_
exists
?
(
self
.
target_branch
)
end
end
def
merge_commit_message
(
include_description:
false
)
def
merge_commit_message
(
include_description:
false
)
...
...
app/services/quick_actions/interpret_service.rb
View file @
47d19c2d
...
@@ -458,7 +458,7 @@ module QuickActions
...
@@ -458,7 +458,7 @@ module QuickActions
target_branch_param
.
strip
target_branch_param
.
strip
end
end
command
:target_branch
do
|
branch_name
|
command
:target_branch
do
|
branch_name
|
@updates
[
:target_branch
]
=
branch_name
if
project
.
repository
.
branch_
names
.
include
?
(
branch_name
)
@updates
[
:target_branch
]
=
branch_name
if
project
.
repository
.
branch_
exists
?
(
branch_name
)
end
end
desc
'Move issue from one column of the board to another'
desc
'Move issue from one column of the board to another'
...
...
changelogs/unreleased/an-use-branch-exists-over-branch-names-include.yml
0 → 100644
View file @
47d19c2d
---
title
:
Avoid fetching all branches for branch existence checks
merge_request
:
14778
author
:
type
:
changed
spec/controllers/projects/branches_controller_spec.rb
View file @
47d19c2d
...
@@ -62,7 +62,7 @@ describe Projects::BranchesController do
...
@@ -62,7 +62,7 @@ describe Projects::BranchesController do
let
(
:branch
)
{
"feature%2Ftest"
}
let
(
:branch
)
{
"feature%2Ftest"
}
let
(
:ref
)
{
"<script>alert('ref');</script>"
}
let
(
:ref
)
{
"<script>alert('ref');</script>"
}
it
{
is_expected
.
to
render_template
(
'new'
)
}
it
{
is_expected
.
to
render_template
(
'new'
)
}
it
{
project
.
repository
.
branch_
names
.
include
?
(
'feature/test'
)
}
it
{
project
.
repository
.
branch_
exists
?
(
'feature/test'
)
}
end
end
end
end
...
...
spec/features/projects/issuable_templates_spec.rb
View file @
47d19c2d
...
@@ -118,7 +118,7 @@ feature 'issuable templates', :js do
...
@@ -118,7 +118,7 @@ feature 'issuable templates', :js do
context
'user creates a merge request from a forked project using templates'
do
context
'user creates a merge request from a forked project using templates'
do
let
(
:template_content
)
{
'this is a test "feature-proposal" template'
}
let
(
:template_content
)
{
'this is a test "feature-proposal" template'
}
let
(
:fork_user
)
{
create
(
:user
)
}
let
(
:fork_user
)
{
create
(
:user
)
}
let
(
:forked_project
)
{
fork_project
(
project
,
fork_user
)
}
let
(
:forked_project
)
{
fork_project
(
project
,
fork_user
,
repository:
true
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
forked_project
,
target_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:with_diffs
,
source_project:
forked_project
,
target_project:
project
)
}
background
do
background
do
...
...
spec/features/projects/merge_requests/user_views_open_merge_request_spec.rb
View file @
47d19c2d
...
@@ -6,7 +6,7 @@ describe 'User views an open merge request' do
...
@@ -6,7 +6,7 @@ describe 'User views an open merge request' do
end
end
context
'when a merge request does not have repository'
do
context
'when a merge request does not have repository'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
before
do
before
do
visit
(
merge_request_path
(
merge_request
))
visit
(
merge_request_path
(
merge_request
))
...
...
spec/features/task_lists_spec.rb
View file @
47d19c2d
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
feature
'Task Lists'
do
feature
'Task Lists'
do
include
Warden
::
Test
::
Helpers
include
Warden
::
Test
::
Helpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
...
...
spec/serializers/merge_request_entity_spec.rb
View file @
47d19c2d
require
'spec_helper'
require
'spec_helper'
describe
MergeRequestEntity
do
describe
MergeRequestEntity
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
,
:repository
}
let
(
:resource
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:resource
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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