2016-07-03 17:01:13 -04:00
|
|
|
# Helpers to send Git blobs, diffs, patches or archives through Workhorse.
|
2016-06-06 07:16:30 -04:00
|
|
|
# Workhorse will also serve files when using `send_file`.
|
|
|
|
module WorkhorseHelper
|
|
|
|
# Send a Git blob through Workhorse
|
|
|
|
def send_git_blob(repository, blob)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_blob(repository, blob))
|
|
|
|
headers['Content-Disposition'] = 'inline'
|
|
|
|
headers['Content-Type'] = safe_content_type(blob)
|
2018-06-05 22:28:32 -04:00
|
|
|
render plain: ""
|
2016-06-06 07:16:30 -04:00
|
|
|
end
|
|
|
|
|
2016-06-08 08:30:15 -04:00
|
|
|
# Send a Git diff through Workhorse
|
|
|
|
def send_git_diff(repository, diff_refs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_diff(repository, diff_refs))
|
|
|
|
headers['Content-Disposition'] = 'inline'
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2016-07-03 17:01:13 -04:00
|
|
|
# Send a Git patch through Workhorse
|
|
|
|
def send_git_patch(repository, diff_refs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_patch(repository, diff_refs))
|
|
|
|
headers['Content-Disposition'] = 'inline'
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2016-06-06 07:16:30 -04:00
|
|
|
# Archive a Git repository and send it through Workhorse
|
2018-02-19 15:41:04 -05:00
|
|
|
def send_git_archive(repository, **kwargs)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_git_archive(repository, **kwargs))
|
2016-06-06 07:16:30 -04:00
|
|
|
head :ok
|
|
|
|
end
|
2016-07-05 10:58:38 -04:00
|
|
|
|
|
|
|
# Send an entry from artifacts through Workhorse
|
|
|
|
def send_artifacts_entry(build, entry)
|
|
|
|
headers.store(*Gitlab::Workhorse.send_artifacts_entry(build, entry))
|
|
|
|
head :ok
|
|
|
|
end
|
2016-08-19 13:10:41 -04:00
|
|
|
|
|
|
|
def set_workhorse_internal_api_content_type
|
|
|
|
headers['Content-Type'] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
|
|
|
|
end
|
2016-06-06 07:16:30 -04:00
|
|
|
end
|