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
c2c5572e
Commit
c2c5572e
authored
Mar 01, 2016
by
tiagonbotelho
Committed by
Yorick Peterse
Mar 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds swp and swo to gitignore and improves migration for project main_language
parent
dc31aff3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
24 deletions
+20
-24
app/models/.project.rb.swo
app/models/.project.rb.swo
+0
-0
app/models/project.rb
app/models/project.rb
+12
-6
app/models/repository.rb
app/models/repository.rb
+6
-0
db/migrate/20160229193553_add_main_language_to_repository.rb
db/migrate/20160229193553_add_main_language_to_repository.rb
+2
-18
No files found.
app/models/.project.rb.swo
deleted
100644 → 0
View file @
dc31aff3
File deleted
app/models/project.rb
View file @
c2c5572e
...
@@ -89,12 +89,8 @@ class Project < ActiveRecord::Base
...
@@ -89,12 +89,8 @@ class Project < ActiveRecord::Base
# checks if the language main language of the project changed
# checks if the language main language of the project changed
before_save
:check_main_language
before_save
:check_main_language
def
check_main_language
def
check_main_language
if
!
repository
.
empty?
&&
self
.
changed?
if
commit_count
.
changed?
language
=
Linguist
::
Repository
.
new
(
self
.
main_language
=
repository
.
main_language
repository
.
rugged
,
repository
.
rugged
.
head
.
target_id
).
language
self
.
main_language
=
language
end
end
end
end
...
@@ -957,4 +953,14 @@ class Project < ActiveRecord::Base
...
@@ -957,4 +953,14 @@ class Project < ActiveRecord::Base
def
wiki
def
wiki
@wiki
||=
ProjectWiki
.
new
(
self
,
self
.
owner
)
@wiki
||=
ProjectWiki
.
new
(
self
,
self
.
owner
)
end
end
def
main_language
language
=
read_attributes
(
:main_language
)
return
language
if
language
update_attributes
(
main_language:
repository
.
main_language
)
read_attributes
(
:main_language
)
end
end
end
app/models/repository.rb
View file @
c2c5572e
...
@@ -812,6 +812,12 @@ class Repository
...
@@ -812,6 +812,12 @@ class Repository
raw_repository
.
ls_files
(
actual_ref
)
raw_repository
.
ls_files
(
actual_ref
)
end
end
def
main_language
unless
empty?
Linguist
::
Repository
.
new
(
rugged
,
rugged
.
head
.
target_id
).
language
end
end
private
private
def
cache
def
cache
...
...
db/migrate/20160229193553_add_main_language_to_repository.rb
View file @
c2c5572e
class
AddMainLanguageToRepository
<
ActiveRecord
::
Migration
class
AddMainLanguageToRepository
<
ActiveRecord
::
Migration
require
'rugged'
def
change
require
'linguist'
add_column
:projects
,
:main_language
,
:string
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
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