BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
10 deletions
+15
-10
compare_helper.rb
app/helpers/compare_helper.rb
+2
-2
merge_request.rb
app/models/merge_request.rb
+2
-2
interpret_service.rb
app/services/quick_actions/interpret_service.rb
+1
-1
an-use-branch-exists-over-branch-names-include.yml
...leased/an-use-branch-exists-over-branch-names-include.yml
+5
-0
branches_controller_spec.rb
spec/controllers/projects/branches_controller_spec.rb
+1
-1
issuable_templates_spec.rb
spec/features/projects/issuable_templates_spec.rb
+1
-1
user_views_open_merge_request_spec.rb
...ects/merge_requests/user_views_open_merge_request_spec.rb
+1
-1
task_lists_spec.rb
spec/features/task_lists_spec.rb
+1
-1
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
to
.
present?
&&
from
!=
to
&&
can?
(
current_user
,
:create_merge_request
,
project
)
&&
project
.
repository
.
branch_
names
.
include
?
(
from
)
&&
project
.
repository
.
branch_
names
.
include
?
(
to
)
project
.
repository
.
branch_
exists
?
(
from
)
&&
project
.
repository
.
branch_
exists
?
(
to
)
end
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
def
source_branch_exists?
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
def
target_branch_exists?
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
def
merge_commit_message
(
include_description:
false
)
...
...
app/services/quick_actions/interpret_service.rb
View file @
47d19c2d
...
...
@@ -458,7 +458,7 @@ module QuickActions
target_branch_param
.
strip
end
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
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
let
(
:branch
)
{
"feature%2Ftest"
}
let
(
:ref
)
{
"<script>alert('ref');</script>"
}
it
{
is_expected
.
to
render_template
(
'new'
)
}
it
{
project
.
repository
.
branch_
names
.
include
?
(
'feature/test'
)
}
it
{
project
.
repository
.
branch_
exists
?
(
'feature/test'
)
}
end
end
...
...
spec/features/projects/issuable_templates_spec.rb
View file @
47d19c2d
...
...
@@ -118,7 +118,7 @@ feature 'issuable templates', :js 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
(
: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
)
}
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
end
context
'when a merge request does not have repository'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
before
do
visit
(
merge_request_path
(
merge_request
))
...
...
spec/features/task_lists_spec.rb
View file @
47d19c2d
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
feature
'Task Lists'
do
include
Warden
::
Test
::
Helpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
...
...
spec/serializers/merge_request_entity_spec.rb
View file @
47d19c2d
require
'spec_helper'
describe
MergeRequestEntity
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
,
:repository
}
let
(
:resource
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
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