diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /lib/api/helpers/snippets_helpers.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/api/helpers/snippets_helpers.rb')
-rw-r--r-- | lib/api/helpers/snippets_helpers.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/helpers/snippets_helpers.rb b/lib/api/helpers/snippets_helpers.rb index f95d066bd7c..79367da8d1f 100644 --- a/lib/api/helpers/snippets_helpers.rb +++ b/lib/api/helpers/snippets_helpers.rb @@ -10,6 +10,23 @@ module API requires :ref, type: String, desc: 'The name of branch, tag or commit' end + params :create_file_params do + optional :files, type: Array, desc: 'An array of files' do + requires :file_path, type: String, file_path: true, allow_blank: false, desc: 'The path of a snippet file' + requires :content, type: String, allow_blank: false, desc: 'The content of a snippet file' + end + + optional :content, type: String, allow_blank: false, desc: 'The content of a snippet' + + given :content do + requires :file_name, type: String, desc: 'The name of a snippet file' + end + + mutually_exclusive :files, :content + + exactly_one_of :files, :content + end + def content_for(snippet) if snippet.empty_repo? env['api.format'] = :txt @@ -35,5 +52,12 @@ module API send_git_blob(repo, blob) end end + + def process_file_args(args) + args[:snippet_actions] = args.delete(:files)&.map do |file| + file[:action] = :create + file.symbolize_keys + end + end end end |