Commit 7f50c7f62c083ef5599b2ffe24723683c246bfb0
1 parent
e603da73
Exists in
spb-stable
and in
3 other branches
Move project creation to service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
24 additions
and
25 deletions
Show diff stats
app/observers/project_observer.rb
| 1 | 1 | class ProjectObserver < BaseObserver |
| 2 | 2 | def after_create(project) |
| 3 | - project.update_column(:last_activity_at, project.created_at) | |
| 4 | - | |
| 5 | - return true if project.forked? | |
| 6 | - | |
| 7 | - if project.import? | |
| 8 | - RepositoryImportWorker.perform_in(5.seconds, project.id) | |
| 9 | - else | |
| 10 | - GitlabShellWorker.perform_async( | |
| 11 | - :add_repository, | |
| 12 | - project.path_with_namespace | |
| 13 | - ) | |
| 14 | - | |
| 15 | - log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") | |
| 16 | - end | |
| 17 | - | |
| 18 | - if project.wiki_enabled? | |
| 19 | - begin | |
| 20 | - # force the creation of a wiki, | |
| 21 | - GollumWiki.new(project, project.owner).wiki | |
| 22 | - rescue GollumWiki::CouldNotCreateWikiError => ex | |
| 23 | - # Prevent project observer crash | |
| 24 | - # if failed to create wiki | |
| 25 | - nil | |
| 26 | - end | |
| 27 | - end | |
| 3 | + log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") | |
| 28 | 4 | end |
| 29 | 5 | |
| 30 | 6 | def after_update(project) | ... | ... |
app/services/projects/create_service.rb
| ... | ... | @@ -58,6 +58,29 @@ module Projects |
| 58 | 58 | user: current_user |
| 59 | 59 | ) |
| 60 | 60 | end |
| 61 | + | |
| 62 | + @project.update_column(:last_activity_at, @project.created_at) | |
| 63 | + | |
| 64 | + if @project.import? | |
| 65 | + RepositoryImportWorker.perform_in(5.seconds, @project.id) | |
| 66 | + else | |
| 67 | + GitlabShellWorker.perform_async( | |
| 68 | + :add_repository, | |
| 69 | + @project.path_with_namespace | |
| 70 | + ) | |
| 71 | + | |
| 72 | + end | |
| 73 | + | |
| 74 | + if @project.wiki_enabled? | |
| 75 | + begin | |
| 76 | + # force the creation of a wiki, | |
| 77 | + GollumWiki.new(@project, @project.owner).wiki | |
| 78 | + rescue GollumWiki::CouldNotCreateWikiError => ex | |
| 79 | + # Prevent project observer crash | |
| 80 | + # if failed to create wiki | |
| 81 | + nil | |
| 82 | + end | |
| 83 | + end | |
| 61 | 84 | end |
| 62 | 85 | |
| 63 | 86 | @project | ... | ... |