summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 18:08:08 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-06 18:08:08 +0000
commit83731155d997ae24c7e0cd5ffa6f0dba41bec6dc (patch)
tree31f785012137fda4ac9a470f4f07c961b42d0299 /app/models
parent57a37ce99f297cddae12cb4d982b6d572f932bb4 (diff)
downloadgitlab-ce-83731155d997ae24c7e0cd5ffa6f0dba41bec6dc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/snippet.rb4
-rw-r--r--app/models/snippet_repository.rb6
2 files changed, 10 insertions, 0 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?