summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/snippet.rb4
-rw-r--r--app/models/snippet_repository.rb6
-rw-r--r--app/services/projects/import_export/export_service.rb6
-rw-r--r--app/views/layouts/nav/sidebar/_project.html.haml4
4 files changed, 17 insertions, 3 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 27e1778e9b6..5c2e03e4b9c 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -302,6 +302,10 @@ class Snippet < ApplicationRecord
field != :content || MarkupHelper.gitlab_markdown?(file_name)
end
+ def hexdigest
+ Digest::SHA256.hexdigest("#{title}#{description}#{created_at}#{updated_at}")
+ end
+
class << self
# Searches for snippets with a matching title or file name.
#
diff --git a/app/models/snippet_repository.rb b/app/models/snippet_repository.rb
index 10580c51098..89098971a7d 100644
--- a/app/models/snippet_repository.rb
+++ b/app/models/snippet_repository.rb
@@ -18,6 +18,12 @@ class SnippetRepository < ApplicationRecord
end
end
+ def create_file(user, path, content, **options)
+ options[:actions] = transform_file_entries([{ file_path: path, content: content }])
+
+ capture_git_error { repository.multi_action(user, **options) }
+ end
+
def multi_files_action(user, files = [], **options)
return if files.nil? || files.empty?
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index 5a3eb4c2156..74d5af41a04 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -42,7 +42,7 @@ module Projects
end
def exporters
- [version_saver, avatar_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver, lfs_saver]
+ [version_saver, avatar_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver, lfs_saver, snippets_repo_saver]
end
def version_saver
@@ -73,6 +73,10 @@ module Projects
Gitlab::ImportExport::LfsSaver.new(project: project, shared: shared)
end
+ def snippets_repo_saver
+ Gitlab::ImportExport::SnippetsRepoSaver.new(current_user: current_user, project: project, shared: shared)
+ end
+
def cleanup
FileUtils.rm_rf(shared.archive_path) if shared&.archive_path
end
diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml
index b8b5eacfab1..5afe43d6636 100644
--- a/app/views/layouts/nav/sidebar/_project.html.haml
+++ b/app/views/layouts/nav/sidebar/_project.html.haml
@@ -143,7 +143,7 @@
- issue_tracker = @project.external_issue_tracker
= link_to issue_tracker.issue_tracker_path, class: 'shortcuts-external_tracker' do
.nav-icon-container
- = sprite_icon('issue-external')
+ = sprite_icon('external-link')
%span.nav-item-name
= issue_tracker.title
%ul.sidebar-sub-level-items.is-fly-out-only
@@ -319,7 +319,7 @@
= nav_link do
= link_to external_wiki_url, class: 'shortcuts-external_wiki' do
.nav-icon-container
- = sprite_icon('issue-external')
+ = sprite_icon('external-link')
%span.nav-item-name
= _('External Wiki')
%ul.sidebar-sub-level-items.is-fly-out-only