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
cdafffcf
Commit
cdafffcf
authored
Aug 02, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Codestyle: move hooks to the same place and move dependent methods to private
parent
539ed0a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
app/models/project.rb
app/models/project.rb
+18
-19
No files found.
app/models/project.rb
View file @
cdafffcf
...
@@ -44,31 +44,23 @@ class Project < ActiveRecord::Base
...
@@ -44,31 +44,23 @@ class Project < ActiveRecord::Base
default_value_for
:snippets_enabled
,
gitlab_config_features
.
snippets
default_value_for
:snippets_enabled
,
gitlab_config_features
.
snippets
default_value_for
:only_allow_merge_if_all_discussions_are_resolved
,
false
default_value_for
:only_allow_merge_if_all_discussions_are_resolved
,
false
after_create
:ensure_storage_path_exist
add_authentication_token_field
:runners_token
after_create
:create_project_feature
,
unless: :project_feature
before_save
:ensure_runners_token
after_save
:update_project_statistics
,
if: :namespace_id_changed?
# set last_activity_at to the same as created_at
after_save
:update_project_statistics
,
if: :namespace_id_changed?
after_create
:create_project_feature
,
unless: :project_feature
after_create
:set_last_activity_at
after_create
:set_last_activity_at
def
set_last_activity_at
update_column
(
:last_activity_at
,
self
.
created_at
)
end
after_create
:set_last_repository_updated_at
after_create
:set_last_repository_updated_at
def
set_last_repository_updated_at
after_update
:update_forks_visibility_level
update_column
(
:last_repository_updated_at
,
self
.
created_at
)
end
before_destroy
:remove_private_deploy_keys
before_destroy
:remove_private_deploy_keys
after_destroy
->
{
run_after_commit
{
remove_pages
}
}
after_destroy
->
{
run_after_commit
{
remove_pages
}
}
# update visibility_level of forks
after_update
:update_forks_visibility_level
after_validation
:check_pending_delete
after_validation
:check_pending_delete
# Legacy Storage specific hooks
# Storage specific hooks
after_initialize
:load_storage
after_create
:ensure_storage_path_exist
after_save
:ensure_storage_path_exist
,
if: :namespace_id_changed?
after_save
:ensure_storage_path_exist
,
if: :namespace_id_changed?
acts_as_taggable
acts_as_taggable
...
@@ -238,9 +230,6 @@ class Project < ActiveRecord::Base
...
@@ -238,9 +230,6 @@ class Project < ActiveRecord::Base
presence:
true
,
presence:
true
,
inclusion:
{
in:
->
(
_object
)
{
Gitlab
.
config
.
repositories
.
storages
.
keys
}
}
inclusion:
{
in:
->
(
_object
)
{
Gitlab
.
config
.
repositories
.
storages
.
keys
}
}
add_authentication_token_field
:runners_token
before_save
:ensure_runners_token
mount_uploader
:avatar
,
AvatarUploader
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:uploads
,
as: :model
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
...
@@ -1086,6 +1075,7 @@ class Project < ActiveRecord::Base
...
@@ -1086,6 +1075,7 @@ class Project < ActiveRecord::Base
!!
repository
.
exists?
!!
repository
.
exists?
end
end
# update visibility_level of forks
def
update_forks_visibility_level
def
update_forks_visibility_level
return
unless
visibility_level
<
visibility_level_was
return
unless
visibility_level
<
visibility_level_was
...
@@ -1421,6 +1411,15 @@ class Project < ActiveRecord::Base
...
@@ -1421,6 +1411,15 @@ class Project < ActiveRecord::Base
private
private
# set last_activity_at to the same as created_at
def
set_last_activity_at
update_column
(
:last_activity_at
,
self
.
created_at
)
end
def
set_last_repository_updated_at
update_column
(
:last_repository_updated_at
,
self
.
created_at
)
end
def
cross_namespace_reference?
(
from
)
def
cross_namespace_reference?
(
from
)
case
from
case
from
when
Project
when
Project
...
...
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