diff options
author | Robert Speicher <robert@gitlab.com> | 2016-06-10 16:21:26 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-06-10 16:21:26 +0000 |
commit | 37be2007f9aa6197c1304a450110aecbde5434f9 (patch) | |
tree | 63e12aaae7dad8a962141b78542431083aea23dd /app/controllers | |
parent | d6de816982eb9a227a384c3318d050a23ad18529 (diff) | |
parent | 701e2df7e55113dafd48c570baad44bf7f24f863 (diff) | |
download | gitlab-ce-37be2007f9aa6197c1304a450110aecbde5434f9.tar.gz |
Merge branch 'workhorse-helpers' into 'master'
Add workhorse controller and API helpers
Adds `send_git_blob` and `send_git_archive` controller and API helpers to reduce duplication and make Workhorse easier for a developer to work with.
See merge request !4486
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/projects/avatars_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/raw_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/repositories_controller.rb | 3 |
5 files changed, 6 insertions, 15 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 62f63701799..cd6ae507cf1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base include Gitlab::GonHelper include GitlabRoutingHelper include PageLayoutHelper + include WorkhorseHelper before_action :authenticate_user_from_token! before_action :authenticate_user! diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb index 72921b3aa14..5962f74c39b 100644 --- a/app/controllers/projects/avatars_controller.rb +++ b/app/controllers/projects/avatars_controller.rb @@ -10,10 +10,7 @@ class Projects::AvatarsController < Projects::ApplicationController return if cached_blob? - headers.store(*Gitlab::Workhorse.send_git_blob(@repository, @blob)) - headers['Content-Disposition'] = 'inline' - headers['Content-Type'] = safe_content_type(@blob) - head :ok # 'render nothing: true' messes up the Content-Type + send_git_blob @repository, @blob else render_404 end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 06a114dcbe8..67e7187c10d 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -61,12 +61,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController format.json { render json: @merge_request } format.patch { render text: @merge_request.to_patch } format.diff do - headers.store(*Gitlab::Workhorse.send_git_diff(@project.repository, - @merge_request.diff_base_commit.id, - @merge_request.last_commit.id)) - headers['Content-Disposition'] = 'inline' + return render_404 unless @merge_request.diff_refs - head :ok + send_git_diff @project.repository, @merge_request.diff_refs end end end diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 10de0e60530..10d24da16d7 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -18,10 +18,7 @@ class Projects::RawController < Projects::ApplicationController if @blob.lfs_pointer? send_lfs_object else - headers.store(*Gitlab::Workhorse.send_git_blob(@repository, @blob)) - headers['Content-Disposition'] = 'inline' - headers['Content-Type'] = safe_content_type(@blob) - head :ok # 'render nothing: true' messes up the Content-Type + send_git_blob @repository, @blob end else render_404 diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index bb7a6b6a5ab..d5af0341d18 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -11,8 +11,7 @@ class Projects::RepositoriesController < Projects::ApplicationController end def archive - headers.store(*Gitlab::Workhorse.send_git_archive(@project, params[:ref], params[:format])) - head :ok + send_git_archive @repository, ref: params[:ref], format: params[:format] rescue => ex logger.error("#{self.class.name}: #{ex}") return git_not_found! |