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
935bf727
Commit
935bf727
authored
Apr 05, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only update main language if it is not already set
parent
779b9eac
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
CHANGELOG
CHANGELOG
+1
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+5
-5
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+21
-5
No files found.
CHANGELOG
View file @
935bf727
...
@@ -24,6 +24,7 @@ v 8.7.0 (unreleased)
...
@@ -24,6 +24,7 @@ v 8.7.0 (unreleased)
- Build status notifications
- Build status notifications
v 8.6.5 (unreleased)
v 8.6.5 (unreleased)
- Only update repository language if it is not set to improve performance
- Check permissions when user attempts to import members from another project
- Check permissions when user attempts to import members from another project
v 8.6.4
v 8.6.4
...
...
app/services/git_push_service.rb
View file @
935bf727
...
@@ -55,15 +55,15 @@ class GitPushService < BaseService
...
@@ -55,15 +55,15 @@ class GitPushService < BaseService
end
end
def
update_main_language
def
update_main_language
# Performance can be bad so for now only check main_language once
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/14937
return
if
@project
.
main_language
.
present?
return
unless
is_default_branch?
return
unless
is_default_branch?
return
unless
push_to_new_branch?
||
push_to_existing_branch?
return
unless
push_to_new_branch?
||
push_to_existing_branch?
current_language
=
@project
.
repository
.
main_language
current_language
=
@project
.
repository
.
main_language
@project
.
update_attributes
(
main_language:
current_language
)
unless
current_language
==
@project
.
main_language
return
@project
.
update_attributes
(
main_language:
current_language
)
end
true
true
end
end
...
...
spec/services/git_push_service_spec.rb
View file @
935bf727
...
@@ -164,21 +164,37 @@ describe GitPushService, services: true do
...
@@ -164,21 +164,37 @@ describe GitPushService, services: true do
end
end
context
"after push"
do
context
"after push"
do
before
do
def
execute
@service
=
execute_service
(
project
,
user
,
@oldrev
,
@newrev
,
ref
)
execute_service
(
project
,
user
,
@oldrev
,
@newrev
,
ref
)
end
end
context
"to master"
do
context
"to master"
do
let
(
:ref
)
{
@ref
}
let
(
:ref
)
{
@ref
}
it
{
expect
(
@service
.
update_main_language
).
to
eq
(
true
)
}
context
'when main_language is nil'
do
it
{
expect
(
project
.
main_language
).
to
eq
(
"Ruby"
)
}
it
'obtains the language from the repository'
do
expect
(
project
.
repository
).
to
receive
(
:main_language
)
execute
end
it
'sets the project main language'
do
execute
expect
(
project
.
main_language
).
to
eq
(
"Ruby"
)
end
end
context
'when main_language is already set'
do
it
'does not check the repository'
do
execute
# do an initial run to simulate lang being preset
expect
(
project
.
repository
).
not_to
receive
(
:main_language
)
execute
end
end
end
end
context
"to other branch"
do
context
"to other branch"
do
let
(
:ref
)
{
'refs/heads/feature/branch'
}
let
(
:ref
)
{
'refs/heads/feature/branch'
}
it
{
expect
(
@service
.
update_main_language
).
to
eq
(
nil
)
}
it
{
expect
(
project
.
main_language
).
to
eq
(
nil
)
}
it
{
expect
(
project
.
main_language
).
to
eq
(
nil
)
}
end
end
end
end
...
...
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