Commit a243253b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactored project archive. Improved MR usability form

parent edd81a79
......@@ -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
......
......@@ -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
......@@ -117,4 +117,28 @@ module Repository
def root_ref? branch
root_ref == branch
end
# Archive Project to .tar.gz
#
# Already packed repo archives stored at
# app_root/tmp/repositories/project_name/project_name-commit-id.tag.gz
#
def archive_repo ref
ref = ref || self.root_ref
commit = self.commit(ref)
return nil unless commit
# Build file path
file_name = self.code + "-" + commit.id.to_s + ".tar.gz"
storage_path = File.join(Rails.root, "tmp", "repositories", self.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 = self.repo.archive_to_file(ref, nil, file_path)
end
file_path
end
end
......@@ -5,23 +5,43 @@
- @merge_request.errors.full_messages.each do |msg|
%li= msg
.control-group
= f.label :title, :class => "control-label"
.controls= f.text_area :title, :class => "input-xxlarge", :maxlength => 255, :rows => 5
.control-group
= f.label :source_branch, "From", :class => "control-label"
.controls
= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
.mr_source_commit
.control-group
= f.label :target_branch, "To", :class => "control-label"
.controls
= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
.mr_target_commit
%h3.padded.cgray 1. Select Branches
.row
.span6
.ui-box
%h5 From (Head Branch)
.body
.padded
= f.label :source_branch, "From", :class => "control-label"
.controls
= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
%hr
.mr_source_commit
.clearfix
.span6
.ui-box
%h5 To (Base Branch)
.body
.padded
= f.label :target_branch, "To", :class => "control-label"
.controls
= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
%hr
.mr_target_commit
.clearfix
%h3.padded.cgray 2. Fill info
.clearfix
= f.label :assignee_id, "Assign to", :class => "control-label"
.controls= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px")
.control-group
= f.label :title, :class => "control-label"
.controls= f.text_field :title, :class => "input-xxlarge pad", :maxlength => 255, :rows => 5
.form-actions
= f.submit 'Save', :class => "btn-primary btn"
- if @merge_request.new_record?
......@@ -38,14 +58,18 @@
$('select#merge_request_assignee_id').chosen();
$('select#merge_request_source_branch').chosen();
$('select#merge_request_target_branch').chosen();
var source_branch = $("#merge_request_source_branch");
var target_branch = $("#merge_request_target_branch");
$.get("#{branch_from_project_merge_requests_path(@project)}", {ref: source_branch.val() });
$.get("#{branch_to_project_merge_requests_path(@project)}", {ref: target_branch.val() });
$("#merge_request_source_branch").live("change", function() {
source_branch.live("change", function() {
$.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() });
});
$("#merge_request_target_branch").live("change", function() {
target_branch.live("change", function() {
$.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() });
});
});
......
Gitlab::Application.routes.draw do
#
# Search
#
get 'search' => "search#show"
# Optionally, enable Resque here
require 'resque/server'
mount Resque::Server.new, at: '/info/resque'
#
# Help
#
get 'help' => 'help#index'
get 'help/permissions' => 'help#permissions'
get 'help/workflow' => 'help#workflow'
get 'help/web_hooks' => 'help#web_hooks'
#
# Admin Area
#
namespace :admin do
resources :users do
member do
......@@ -44,6 +53,7 @@ Gitlab::Application.routes.draw do
get "profile", :to => "profile#show"
get "profile/design", :to => "profile#design"
put "profile/update", :to => "profile#update"
resources :keys
#
# Dashboard Area
......@@ -53,10 +63,12 @@ Gitlab::Application.routes.draw do
get "dashboard/merge_requests", :to => "dashboard#merge_requests"
resources :projects, :constraints => { :id => /[^\/]+/ }, :only => [:new, :create]
resources :keys
devise_for :users, :controllers => { :omniauth_callbacks => :omniauth_callbacks }
#
# Project Area
#
resources :projects, :constraints => { :id => /[^\/]+/ }, :except => [:new, :create, :index], :path => "/" do
member do
get "team"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment