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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
208b18c9
Commit
208b18c9
authored
Jun 20, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify check branch name exist
parent
74f8f260
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
11 deletions
+7
-11
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+1
-1
app/helpers/branches_helper.rb
app/helpers/branches_helper.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+2
-5
app/models/user.rb
app/models/user.rb
+1
-2
spec/workers/merge_worker_spec.rb
spec/workers/merge_worker_spec.rb
+1
-1
No files found.
app/controllers/projects/application_controller.rb
View file @
208b18c9
...
...
@@ -74,7 +74,7 @@ class Projects::ApplicationController < ApplicationController
end
def
require_branch_head
unless
@repository
.
branch_
names
.
include
?
(
@ref
)
unless
@repository
.
branch_
exists
?
(
@ref
)
redirect_to
(
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@ref
),
notice:
"This action is not allowed unless you are on a branch"
...
...
app/helpers/application_helper.rb
View file @
208b18c9
...
...
@@ -116,7 +116,7 @@ module ApplicationHelper
return
false
if
project
.
merge_requests
.
where
(
source_branch:
event
.
branch_name
).
opened
.
any?
# Skip if user removed branch right after that
return
false
unless
project
.
repository
.
branch_
names
.
include
?
(
event
.
branch_name
)
return
false
unless
project
.
repository
.
branch_
exists
?
(
event
.
branch_name
)
true
end
...
...
app/helpers/branches_helper.rb
View file @
208b18c9
...
...
@@ -10,7 +10,7 @@ module BranchesHelper
end
def
can_push_branch?
(
project
,
branch_name
)
return
false
unless
project
.
repository
.
branch_
names
.
include
?
(
branch_name
)
return
false
unless
project
.
repository
.
branch_
exists
?
(
branch_name
)
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
branch_name
)
end
...
...
app/models/repository.rb
View file @
208b18c9
...
...
@@ -192,7 +192,7 @@ class Repository
end
def
branch_names
cache
.
fetch
(
:branch_names
)
{
branches
.
map
(
&
:name
)
}
@branch_names
||=
cache
.
fetch
(
:branch_names
)
{
branches
.
map
(
&
:name
)
}
end
def
branch_exists?
(
branch_name
)
...
...
@@ -267,6 +267,7 @@ class Repository
def
expire_branches_cache
cache
.
expire
(
:branch_names
)
@branch_names
=
nil
@local_branches
=
nil
end
...
...
@@ -332,10 +333,6 @@ class Repository
@lookup_cache
||=
{}
end
def
expire_branch_names
cache
.
expire
(
:branch_names
)
end
def
expire_avatar_cache
(
branch_name
=
nil
,
revision
=
nil
)
# Avatars are pulled from the default branch, thus if somebody pushes to a
# different branch there's no need to expire anything.
...
...
app/models/user.rb
View file @
208b18c9
...
...
@@ -487,9 +487,8 @@ class User < ActiveRecord::Base
events
.
recent
.
find
do
|
event
|
project
=
Project
.
find_by_id
(
event
.
project_id
)
next
unless
project
repo
=
project
.
repository
if
repo
.
branch_names
.
include
?
(
event
.
branch_name
)
if
project
.
repository
.
branch_exists
?
(
event
.
branch_name
)
merge_requests
=
MergeRequest
.
where
(
"created_at >= ?"
,
event
.
created_at
).
where
(
source_project_id:
project
.
id
,
source_branch:
event
.
branch_name
)
...
...
spec/workers/merge_worker_spec.rb
View file @
208b18c9
...
...
@@ -9,7 +9,7 @@ describe MergeWorker do
before
do
source_project
.
team
<<
[
author
,
:master
]
source_project
.
repository
.
expire_branch
_names
source_project
.
repository
.
expire_branch
es_cache
end
it
'clears cache of source repo after removing source branch'
do
...
...
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