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
36730e8e
Commit
36730e8e
authored
Mar 08, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'master'
adds language names to projects list [image attached] See merge request !3000
parents
a19a9fab
49295924
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
0 deletions
+58
-0
CHANGELOG
CHANGELOG
+1
-0
repository.rb
app/models/repository.rb
+6
-0
git_push_service.rb
app/services/git_push_service.rb
+14
-0
_project.html.haml
app/views/shared/projects/_project.html.haml
+3
-0
20160229193553_add_main_language_to_repository.rb
db/migrate/20160229193553_add_main_language_to_repository.rb
+5
-0
repository_spec.rb
spec/models/repository_spec.rb
+12
-0
git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+17
-0
No files found.
CHANGELOG
View file @
36730e8e
...
...
@@ -18,6 +18,7 @@ v 8.6.0 (unreleased)
- Don't show Issues/MRs from archived projects in Groups view
- Increase the notes polling timeout over time (Roberto Dip)
- Show labels in dashboard and group milestone views
- Add main language of a project in the list of projects (Tiago Botelho)
v 8.5.4
- Do not cache requests for badges (including builds badge)
...
...
app/models/repository.rb
View file @
36730e8e
...
...
@@ -812,6 +812,12 @@ class Repository
raw_repository
.
ls_files
(
actual_ref
)
end
def
main_language
unless
empty?
Linguist
::
Repository
.
new
(
rugged
,
rugged
.
head
.
target_id
).
language
end
end
private
def
cache
...
...
app/services/git_push_service.rb
View file @
36730e8e
...
...
@@ -14,6 +14,7 @@ class GitPushService < BaseService
# 3. Recognizes cross-references from commit messages
# 4. Executes the project's web hooks
# 5. Executes the project's services
# 6. Checks if the project's main language has changed
#
def
execute
@project
.
repository
.
after_push_commit
(
branch_name
)
...
...
@@ -42,11 +43,24 @@ class GitPushService < BaseService
@push_commits
=
@project
.
repository
.
commits_between
(
params
[
:oldrev
],
params
[
:newrev
])
process_commit_messages
end
# Checks if the main language has changed in the project and if so
# it updates it accordingly
update_main_language
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
update_merge_requests
end
def
update_main_language
current_language
=
@project
.
repository
.
main_language
unless
current_language
==
@project
.
main_language
return
@project
.
update_attributes
(
main_language:
current_language
)
end
true
end
protected
def
update_merge_requests
...
...
app/views/shared/projects/_project.html.haml
View file @
36730e8e
...
...
@@ -28,6 +28,9 @@
=
project
.
name
.controls
-
if
project
.
main_language
%span
=
project
.
main_language
-
if
ci_commit
%span
=
render_ci_status
(
ci_commit
)
...
...
db/migrate/20160229193553_add_main_language_to_repository.rb
0 → 100644
View file @
36730e8e
class
AddMainLanguageToRepository
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:main_language
,
:string
end
end
spec/models/repository_spec.rb
View file @
36730e8e
...
...
@@ -595,4 +595,16 @@ describe Repository, models: true do
repository
.
after_remove_branch
end
end
describe
"#main_language"
do
it
'shows the main language of the project'
do
expect
(
repository
.
main_language
).
to
eq
(
"Ruby"
)
end
it
'returns nil when the repository is empty'
do
allow
(
repository
).
to
receive
(
:empty?
).
and_return
(
true
)
expect
(
repository
.
main_language
).
to
be_nil
end
end
end
spec/services/git_push_service_spec.rb
View file @
36730e8e
...
...
@@ -155,6 +155,23 @@ describe GitPushService, services: true do
end
end
describe
"Updates main language"
do
context
"before push"
do
it
{
expect
(
project
.
main_language
).
to
eq
(
nil
)
}
end
context
"after push"
do
before
do
@service
=
execute_service
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
end
it
{
expect
(
@service
.
update_main_language
).
to
eq
(
true
)
}
it
{
expect
(
project
.
main_language
).
to
eq
(
"Ruby"
)
}
end
end
describe
"Web Hooks"
do
context
"execute web hooks"
do
it
"when pushing a branch for the first time"
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