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
Jérome Perrin
gitlab-ce
Commits
a14b98f8
Commit
a14b98f8
authored
Mar 01, 2016
by
tiagonbotelho
Committed by
Yorick Peterse
Mar 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implements project languages saving them onto the database
parent
d9e646a7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
app/models/.project.rb.swo
app/models/.project.rb.swo
+0
-0
app/models/project.rb
app/models/project.rb
+12
-0
db/migrate/20160229193553_add_main_language_to_repository.rb
db/migrate/20160229193553_add_main_language_to_repository.rb
+21
-0
No files found.
app/models/.project.rb.swo
0 → 100644
View file @
a14b98f8
File added
app/models/project.rb
View file @
a14b98f8
...
...
@@ -86,6 +86,18 @@ class Project < ActiveRecord::Base
end
end
# checks if the language main language of the project changed
before_save
:check_main_language
def
check_main_language
if
!
repository
.
empty?
&&
self
.
changed?
language
=
Linguist
::
Repository
.
new
(
repository
.
rugged
,
repository
.
rugged
.
head
.
target_id
).
language
self
.
main_language
=
language
end
end
ActsAsTaggableOn
.
strict_case_match
=
true
acts_as_taggable_on
:tags
...
...
db/migrate/20160229193553_add_main_language_to_repository.rb
0 → 100644
View file @
a14b98f8
class
AddMainLanguageToRepository
<
ActiveRecord
::
Migration
require
'rugged'
require
'linguist'
def
up
add_column
:projects
,
:main_language
,
:string
,
default:
nil
Project
.
all
.
each
do
|
project
|
unless
project
.
repository
.
empty?
language
=
Linguist
::
Repository
.
new
(
project
.
repository
.
rugged
,
project
.
repository
.
rugged
.
head
.
target_id
).
language
project
.
update_attributes
(
main_language:
language
)
end
end
end
def
down
remove_column
:projects
,
:main_language
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