summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/merge_requests_controller.rb31
-rw-r--r--app/controllers/repositories_controller.rb24
2 files changed, 19 insertions, 36 deletions
diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb
index 54227fc2c80..b0d122b55db 100644
--- a/app/controllers/merge_requests_controller.rb
+++ b/app/controllers/merge_requests_controller.rb
@@ -73,29 +73,21 @@ class MergeRequestsController < ApplicationController
@merge_request = @project.merge_requests.new(params[:merge_request])
@merge_request.author = current_user
- respond_to do |format|
- if @merge_request.save
- @merge_request.reload_code
- format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' }
- format.json { render json: @merge_request, status: :created, location: @merge_request }
- else
- format.html { render action: "new" }
- format.json { render json: @merge_request.errors, status: :unprocessable_entity }
- end
+ if @merge_request.save
+ @merge_request.reload_code
+ redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.'
+ else
+ render action: "new"
end
end
def update
- respond_to do |format|
- if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
- @merge_request.reload_code
- @merge_request.mark_as_unchecked
- format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' }
- format.json { head :ok }
- else
- format.html { render action: "edit" }
- format.json { render json: @merge_request.errors, status: :unprocessable_entity }
- end
+ if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
+ @merge_request.reload_code
+ @merge_request.mark_as_unchecked
+ redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.'
+ else
+ render action: "edit"
end
end
@@ -122,7 +114,6 @@ class MergeRequestsController < ApplicationController
respond_to do |format|
format.html { redirect_to project_merge_requests_url(@project) }
- format.json { head :ok }
end
end
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 036eb3713bf..cd20677e1ad 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -27,22 +27,14 @@ class RepositoriesController < ApplicationController
render_404 and return
end
- ref = params[:ref] || @project.root_ref
- commit = @project.commit(ref)
- render_404 and return unless commit
-
- # Build file path
- file_name = @project.code + "-" + commit.id.to_s + ".tar.gz"
- storage_path = File.join(Rails.root, "tmp", "repositories", @project.code)
- file_path = File.join(storage_path, file_name)
-
- # Create file if not exists
- unless File.exists?(file_path)
- FileUtils.mkdir_p storage_path
- file = @project.repo.archive_to_file(ref, nil, file_path)
- end
- # Send file to user
- send_file file_path
+ file_path = @project.archive_repo(params[:ref])
+
+ if file_path
+ # Send file to user
+ send_file file_path
+ else
+ render_404
+ end
end
end