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
027b07ca
Commit
027b07ca
authored
Jun 21, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '18709-reduce-git-calls' into 'master'
Remove calls to Rugged::BranchCollection#each from extracts_path before_action See merge request !4802
parents
61f7c127
79c521f5
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
12 deletions
+19
-12
CHANGELOG
CHANGELOG
+1
-0
application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
projects_controller.rb
app/controllers/projects_controller.rb
+7
-1
application_helper.rb
app/helpers/application_helper.rb
+1
-1
branches_helper.rb
app/helpers/branches_helper.rb
+1
-1
repository.rb
app/models/repository.rb
+6
-5
user.rb
app/models/user.rb
+1
-2
merge_worker_spec.rb
spec/workers/merge_worker_spec.rb
+1
-1
No files found.
CHANGELOG
View file @
027b07ca
...
@@ -135,6 +135,7 @@ v 8.9.0 (unreleased)
...
@@ -135,6 +135,7 @@ v 8.9.0 (unreleased)
- Use Git cached counters for branches and tags on project page
- Use Git cached counters for branches and tags on project page
- Filter parameters for request_uri value on instrumented transactions.
- Filter parameters for request_uri value on instrumented transactions.
- Remove duplicated keys add UNIQUE index to keys fingerprint column
- Remove duplicated keys add UNIQUE index to keys fingerprint column
- ExtractsPath get ref_names from repository cache, if not there access git.
- Cache user todo counts from TodoService
- Cache user todo counts from TodoService
- Ensure Todos counters doesn't count Todos for projects pending delete
- Ensure Todos counters doesn't count Todos for projects pending delete
...
...
app/controllers/projects/application_controller.rb
View file @
027b07ca
...
@@ -74,7 +74,7 @@ class Projects::ApplicationController < ApplicationController
...
@@ -74,7 +74,7 @@ class Projects::ApplicationController < ApplicationController
end
end
def
require_branch_head
def
require_branch_head
unless
@repository
.
branch_
names
.
include
?
(
@ref
)
unless
@repository
.
branch_
exists
?
(
@ref
)
redirect_to
(
redirect_to
(
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@ref
),
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@ref
),
notice:
"This action is not allowed unless you are on a branch"
notice:
"This action is not allowed unless you are on a branch"
...
...
app/controllers/projects_controller.rb
View file @
027b07ca
...
@@ -303,8 +303,14 @@ class ProjectsController < Projects::ApplicationController
...
@@ -303,8 +303,14 @@ class ProjectsController < Projects::ApplicationController
project
.
repository_exists?
&&
!
project
.
empty_repo?
project
.
repository_exists?
&&
!
project
.
empty_repo?
end
end
# Override
get_id
from ExtractsPath, which returns the branch and file path
# Override
extract_ref
from ExtractsPath, which returns the branch and file path
# for the blob/tree, which in this case is just the root of the default branch.
# for the blob/tree, which in this case is just the root of the default branch.
# This way we avoid to access the repository.ref_names.
def
extract_ref
(
_id
)
[
get_id
,
''
]
end
# Override get_id from ExtractsPath in this case is just the root of the default branch.
def
get_id
def
get_id
project
.
repository
.
root_ref
project
.
repository
.
root_ref
end
end
...
...
app/helpers/application_helper.rb
View file @
027b07ca
...
@@ -116,7 +116,7 @@ module ApplicationHelper
...
@@ -116,7 +116,7 @@ module ApplicationHelper
return
false
if
project
.
merge_requests
.
where
(
source_branch:
event
.
branch_name
).
opened
.
any?
return
false
if
project
.
merge_requests
.
where
(
source_branch:
event
.
branch_name
).
opened
.
any?
# Skip if user removed branch right after that
# 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
true
end
end
...
...
app/helpers/branches_helper.rb
View file @
027b07ca
...
@@ -10,7 +10,7 @@ module BranchesHelper
...
@@ -10,7 +10,7 @@ module BranchesHelper
end
end
def
can_push_branch?
(
project
,
branch_name
)
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
)
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
branch_name
)
end
end
...
...
app/models/repository.rb
View file @
027b07ca
...
@@ -191,8 +191,12 @@ class Repository
...
@@ -191,8 +191,12 @@ class Repository
end
end
end
end
def
ref_names
branch_names
+
tag_names
end
def
branch_names
def
branch_names
cache
.
fetch
(
:branch_names
)
{
branches
.
map
(
&
:name
)
}
@branch_names
||=
cache
.
fetch
(
:branch_names
)
{
branches
.
map
(
&
:name
)
}
end
end
def
branch_exists?
(
branch_name
)
def
branch_exists?
(
branch_name
)
...
@@ -267,6 +271,7 @@ class Repository
...
@@ -267,6 +271,7 @@ class Repository
def
expire_branches_cache
def
expire_branches_cache
cache
.
expire
(
:branch_names
)
cache
.
expire
(
:branch_names
)
@branch_names
=
nil
@local_branches
=
nil
@local_branches
=
nil
end
end
...
@@ -332,10 +337,6 @@ class Repository
...
@@ -332,10 +337,6 @@ class Repository
@lookup_cache
||=
{}
@lookup_cache
||=
{}
end
end
def
expire_branch_names
cache
.
expire
(
:branch_names
)
end
def
expire_avatar_cache
(
branch_name
=
nil
,
revision
=
nil
)
def
expire_avatar_cache
(
branch_name
=
nil
,
revision
=
nil
)
# Avatars are pulled from the default branch, thus if somebody pushes to a
# Avatars are pulled from the default branch, thus if somebody pushes to a
# different branch there's no need to expire anything.
# different branch there's no need to expire anything.
...
...
app/models/user.rb
View file @
027b07ca
...
@@ -487,9 +487,8 @@ class User < ActiveRecord::Base
...
@@ -487,9 +487,8 @@ class User < ActiveRecord::Base
events
.
recent
.
find
do
|
event
|
events
.
recent
.
find
do
|
event
|
project
=
Project
.
find_by_id
(
event
.
project_id
)
project
=
Project
.
find_by_id
(
event
.
project_id
)
next
unless
project
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
).
merge_requests
=
MergeRequest
.
where
(
"created_at >= ?"
,
event
.
created_at
).
where
(
source_project_id:
project
.
id
,
where
(
source_project_id:
project
.
id
,
source_branch:
event
.
branch_name
)
source_branch:
event
.
branch_name
)
...
...
spec/workers/merge_worker_spec.rb
View file @
027b07ca
...
@@ -9,7 +9,7 @@ describe MergeWorker do
...
@@ -9,7 +9,7 @@ describe MergeWorker do
before
do
before
do
source_project
.
team
<<
[
author
,
:master
]
source_project
.
team
<<
[
author
,
:master
]
source_project
.
repository
.
expire_branch
_names
source_project
.
repository
.
expire_branch
es_cache
end
end
it
'clears cache of source repo after removing source branch'
do
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