summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/application_settings_controller.rb1
-rw-r--r--app/controllers/projects/static_site_editor_controller.rb10
-rw-r--r--app/models/concerns/has_repository.rb2
-rw-r--r--app/models/group.rb4
-rw-r--r--app/models/personal_snippet.rb4
-rw-r--r--app/models/project.rb4
-rw-r--r--app/models/project_snippet.rb4
-rw-r--r--app/models/project_wiki.rb4
-rw-r--r--app/presenters/commit_presenter.rb2
-rw-r--r--app/presenters/issue_presenter.rb10
-rw-r--r--app/presenters/milestone_presenter.rb8
-rw-r--r--app/services/snippets/update_service.rb63
-rw-r--r--app/views/projects/static_site_editor/show.html.haml1
13 files changed, 64 insertions, 53 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 1ee3c52ad35..210d488f5a3 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -192,6 +192,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
params[:application_setting][:import_sources]&.delete("")
params[:application_setting][:restricted_visibility_levels]&.delete("")
params[:application_setting].delete(:elasticsearch_aws_secret_access_key) if params[:application_setting][:elasticsearch_aws_secret_access_key].blank?
+ params[:application_setting][:required_instance_ci_template] = nil if params[:application_setting][:required_instance_ci_template].blank?
# TODO Remove domain_blacklist_raw in APIv5 (See https://gitlab.com/gitlab-org/gitlab-foss/issues/67204)
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
params.delete(:domain_blacklist_raw) if params[:domain_blacklist]
diff --git a/app/controllers/projects/static_site_editor_controller.rb b/app/controllers/projects/static_site_editor_controller.rb
new file mode 100644
index 00000000000..597bfccf422
--- /dev/null
+++ b/app/controllers/projects/static_site_editor_controller.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class Projects::StaticSiteEditorController < Projects::ApplicationController
+ layout 'fullscreen'
+
+ prepend_before_action :authenticate_user!, only: [:show]
+
+ def show
+ end
+end
diff --git a/app/models/concerns/has_repository.rb b/app/models/concerns/has_repository.rb
index 35faa87e876..6a09741b903 100644
--- a/app/models/concerns/has_repository.rb
+++ b/app/models/concerns/has_repository.rb
@@ -110,7 +110,7 @@ module HasRepository
end
def web_url(only_path: nil)
- raise NotImplementedError
+ Gitlab::UrlBuilder.build(self, only_path: only_path)
end
def repository_size_checker
diff --git a/app/models/group.rb b/app/models/group.rb
index 5e6e3032251..203ed1694b7 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -172,8 +172,8 @@ class Group < Namespace
"#{self.class.reference_prefix}#{full_path}"
end
- def web_url
- Gitlab::Routing.url_helpers.group_canonical_url(self)
+ def web_url(only_path: nil)
+ Gitlab::UrlBuilder.build(self, only_path: only_path)
end
def human_name
diff --git a/app/models/personal_snippet.rb b/app/models/personal_snippet.rb
index 5940265b17a..1b5be8698b1 100644
--- a/app/models/personal_snippet.rb
+++ b/app/models/personal_snippet.rb
@@ -2,8 +2,4 @@
class PersonalSnippet < Snippet
include WithUploads
-
- def web_url(only_path: nil)
- Gitlab::Routing.url_helpers.snippet_url(self, only_path: only_path)
- end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index eb4412decba..15b8d5db214 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1121,10 +1121,6 @@ class Project < ApplicationRecord
end
end
- def web_url(only_path: nil)
- Gitlab::Routing.url_helpers.project_url(self, only_path: only_path)
- end
-
def readme_url
readme_path = repository.readme_path
if readme_path
diff --git a/app/models/project_snippet.rb b/app/models/project_snippet.rb
index 6045ec71c6e..ffb08e10f1f 100644
--- a/app/models/project_snippet.rb
+++ b/app/models/project_snippet.rb
@@ -5,8 +5,4 @@ class ProjectSnippet < Snippet
validates :project, presence: true
validates :secret, inclusion: { in: [false] }
-
- def web_url(only_path: nil)
- Gitlab::Routing.url_helpers.project_snippet_url(project, self, only_path: only_path)
- end
end
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index f0967b87345..4b888648b9e 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -44,8 +44,8 @@ class ProjectWiki
# @deprecated use full_path when you need it for an URL route or disk_path when you want to point to the filesystem
alias_method :path_with_namespace, :full_path
- def web_url
- Gitlab::Routing.url_helpers.project_wiki_url(@project, :home)
+ def web_url(only_path: nil)
+ Gitlab::UrlBuilder.build(self, only_path: only_path)
end
def url_to_repo
diff --git a/app/presenters/commit_presenter.rb b/app/presenters/commit_presenter.rb
index 94fc8ac8e39..9ded00fcb7a 100644
--- a/app/presenters/commit_presenter.rb
+++ b/app/presenters/commit_presenter.rb
@@ -18,7 +18,7 @@ class CommitPresenter < Gitlab::View::Presenter::Delegated
end
def web_url
- Gitlab::UrlBuilder.new(commit).url
+ url_builder.build(commit)
end
def signature_html
diff --git a/app/presenters/issue_presenter.rb b/app/presenters/issue_presenter.rb
index 3d55b00ac3b..004813d0374 100644
--- a/app/presenters/issue_presenter.rb
+++ b/app/presenters/issue_presenter.rb
@@ -4,20 +4,14 @@ class IssuePresenter < Gitlab::View::Presenter::Delegated
presents :issue
def web_url
- url_builder.url
+ url_builder.build(issue)
end
def issue_path
- url_builder.issue_path(issue)
+ url_builder.build(issue, only_path: true)
end
def subscribed?
issue.subscribed?(current_user, issue.project)
end
-
- private
-
- def url_builder
- @url_builder ||= Gitlab::UrlBuilder.new(issue)
- end
end
diff --git a/app/presenters/milestone_presenter.rb b/app/presenters/milestone_presenter.rb
index 7d9045ddebe..6bf8203702f 100644
--- a/app/presenters/milestone_presenter.rb
+++ b/app/presenters/milestone_presenter.rb
@@ -4,12 +4,6 @@ class MilestonePresenter < Gitlab::View::Presenter::Delegated
presents :milestone
def milestone_path
- url_builder.milestone_path(milestone)
- end
-
- private
-
- def url_builder
- @url_builder ||= Gitlab::UrlBuilder.new(milestone)
+ url_builder.build(milestone, only_path: true)
end
end
diff --git a/app/services/snippets/update_service.rb b/app/services/snippets/update_service.rb
index 5794332a45b..e56b20c6057 100644
--- a/app/services/snippets/update_service.rb
+++ b/app/services/snippets/update_service.rb
@@ -35,28 +35,43 @@ module Snippets
private
def save_and_commit(snippet)
- snippet.with_transaction_returning_status do
- snippet.save.tap do |saved|
- break false unless saved
-
- # In order to avoid non migrated snippets scenarios,
- # if the snippet does not have a repository we created it
- # We don't need to check if the repository exists
- # because `create_repository` already handles it
- if Feature.enabled?(:version_snippets, current_user)
- create_repository_for(snippet)
- end
-
- # If the snippet repository exists we commit always
- # the changes
- create_commit(snippet) if snippet.repository_exists?
- end
- rescue => e
- snippet.errors.add(:repository, e.message)
- log_error(e.message)
+ return false unless snippet.save
+
+ # In order to avoid non migrated snippets scenarios,
+ # if the snippet does not have a repository we created it
+ # We don't need to check if the repository exists
+ # because `create_repository` already handles it
+ if Feature.enabled?(:version_snippets, current_user)
+ create_repository_for(snippet)
+ end
+
+ # If the snippet repository exists we commit always
+ # the changes
+ create_commit(snippet) if snippet.repository_exists?
+
+ true
+ rescue => e
+ # Restore old attributes
+ unless snippet.previous_changes.empty?
+ snippet.previous_changes.each { |attr, value| snippet[attr] = value[0] }
+ snippet.save
+ end
- false
+ snippet.errors.add(:repository, 'Error updating the snippet')
+ log_error(e.message)
+
+ # If the commit action failed we remove it because
+ # we don't want to leave empty repositories
+ # around, to allow cloning them.
+ if repository_empty?(snippet)
+ snippet.repository.remove
+ snippet.snippet_repository&.delete
end
+
+ # Purge any existing value for repository_exists?
+ snippet.repository.expire_exists_cache
+
+ false
end
def create_repository_for(snippet)
@@ -81,5 +96,13 @@ module Snippets
file_path: params[:file_name],
content: params[:content] }]
end
+
+ # Because we are removing repositories we don't want to remove
+ # any existing repository with data. Therefore, we cannot
+ # rely on cached methods for that check in order to avoid losing
+ # data.
+ def repository_empty?(snippet)
+ snippet.repository._uncached_exists? && !snippet.repository._uncached_has_visible_content?
+ end
end
end
diff --git a/app/views/projects/static_site_editor/show.html.haml b/app/views/projects/static_site_editor/show.html.haml
new file mode 100644
index 00000000000..574cdd0bf88
--- /dev/null
+++ b/app/views/projects/static_site_editor/show.html.haml
@@ -0,0 +1 @@
+#static-site-editor{ data: {} }