diff options
author | Stan Hu <stanhu@gmail.com> | 2018-02-28 17:37:50 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-02-28 17:37:50 +0000 |
commit | fb03846bb2732ae25ffbb448b01ef6283c4607f4 (patch) | |
tree | 2ebcd6779889fb7da800149696d60ce0f7034528 /app/services | |
parent | ee631557ab139461d8ec4f12ba33a61e83b8e307 (diff) | |
parent | 86de1e291cb831ec3aca2fa7227626b93134f740 (diff) | |
download | gitlab-ce-fb03846bb2732ae25ffbb448b01ef6283c4607f4.tar.gz |
Merge branch '4826-create-empty-wiki-when-it-s-enabled' into 'master'
Make sure wiki exists when it's enabled
See merge request gitlab-org/gitlab-ce!17117
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/update_service.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index 0e235a6d2a0..379a8068023 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -15,6 +15,8 @@ module Projects return error("Could not set the default branch") unless project.change_head(params[:default_branch]) end + ensure_wiki_exists if enabling_wiki? + if project.update_attributes(params.except(:default_branch)) if project.previous_changes.include?('path') project.rename_repo @@ -52,5 +54,18 @@ module Projects project.repository.exists? && new_branch && new_branch != project.default_branch end + + def enabling_wiki? + return false if @project.wiki_enabled? + + params[:project_feature_attributes][:wiki_access_level].to_i > ProjectFeature::DISABLED + end + + def ensure_wiki_exists + ProjectWiki.new(project, project.owner).wiki + rescue ProjectWiki::CouldNotCreateWikiError + log_error("Could not create wiki for #{project.full_name}") + Gitlab::Metrics.counter(:wiki_can_not_be_created_total, 'Counts the times we failed to create a wiki') + end end end |