diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-10-15 01:11:15 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-10-15 01:11:15 +0300 |
commit | 0541b3f3c5dcd291d144c83d9731c75ee811b4e0 (patch) | |
tree | 920e79e7626bcd6fb3b517ce9697b8d2d44ee125 | |
parent | d3784687943e0bd699d73d82a6bc6cac39689473 (diff) | |
download | gitlab-ce-0541b3f3c5dcd291d144c83d9731c75ee811b4e0.tar.gz |
1.0.1
25 files changed, 233 insertions, 178 deletions
diff --git a/CHANGELOG b/CHANGELOG index 121ae39855d..1201a85762b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +v 1.0.1 + - fixed: with invalid source code for commit + - fixed: lose branch/tag selection when use tree navigateion + - when history clicked - display path + - bug fix & code cleaning v 1.0.0 - bug fix - projects preview mode @@ -13,7 +13,7 @@ gem "carrierwave" gem 'six' gem 'therubyracer' gem 'faker' -gem 'seed-fu', :branch => 'rails-3-1', :git => 'git://github.com/mbleigh/seed-fu.git' +gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git' gem "inifile" gem "albino", :git => "git://github.com/gitlabhq/albino.git" gem "kaminari" diff --git a/Gemfile.lock b/Gemfile.lock index 46c908a1d62..c02ad3cdc18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,12 +22,11 @@ GIT GIT remote: git://github.com/mbleigh/seed-fu.git - revision: 29fe8c61ca6cc4408115ea7475fe2647081bd348 - branch: rails-3-1 + revision: 77be06852b18fb01e272ab763ddb292da575586c specs: - seed-fu (2.0.1.rails31) - activerecord (~> 3.1.0.rc4) - activesupport (~> 3.1.0.rc4) + seed-fu (2.1.0) + activerecord (~> 3.1.0) + activesupport (~> 3.1.0) GEM remote: http://rubygems.org/ @@ -1 +1 @@ -1.0.0 +1.0.1 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 829126fee05..f8eb238b1d2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,4 +41,24 @@ class ApplicationController < ActionController::Base super end end + + def load_refs + @branch = unless params[:branch].blank? + params[:branch] + else + nil + end + + @tag = unless params[:tag].blank? + params[:tag] + else + nil + end + + @ref = @branch || @tag || "master" + end + + def render_404 + render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404" + end end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index d7daec13f0f..af82b1cd901 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -8,25 +8,19 @@ class CommitsController < ApplicationController before_filter :authorize_read_project! def index + load_refs # load @branch, @tag & @ref + @repo = project.repo - @branch = if !params[:branch].blank? - params[:branch] - elsif !params[:tag].blank? - params[:tag] - else - "master" - end if params[:path] - @commits = @repo.log(@branch, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0) + @commits = @repo.log(@ref, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0) else - @commits = @repo.commits(@branch, params[:limit] || 100, params[:offset] || 0) + @commits = @repo.commits(@ref, params[:limit] || 100, params[:offset] || 0) end respond_to do |format| format.html # index.html.erb format.js - format.json { render json: @commits } end end @@ -38,7 +32,6 @@ class CommitsController < ApplicationController respond_to do |format| format.html # show.html.erb format.js - format.json { render json: @commit } end end end diff --git a/app/controllers/keys_controller.rb b/app/controllers/keys_controller.rb index 003de6b301a..b0249375b85 100644 --- a/app/controllers/keys_controller.rb +++ b/app/controllers/keys_controller.rb @@ -3,11 +3,6 @@ class KeysController < ApplicationController def index @keys = current_user.keys.all - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @keys } - end end def new @@ -23,8 +18,6 @@ class KeysController < ApplicationController respond_with(@key) end - # DELETE /keys/1 - # DELETE /keys/1.json def destroy @key = current_user.keys.find(params[:id]) @key.destroy @@ -32,7 +25,6 @@ class KeysController < ApplicationController respond_to do |format| format.html { redirect_to keys_url } format.js { render :nothing => true } - format.json { head :ok } end end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 080a6ee62f6..1cc2fd63faa 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,78 +8,10 @@ class ProjectsController < ApplicationController def index @projects = current_user.projects.all - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @projects } - end - end - - def show - @repo = project.repo - @commit = @repo.commits.first - @tree = @commit.tree - @tree = @tree / params[:path] if params[:path] - - respond_to do |format| - format.html # show.html.erb - format.json { render json: project } - end - rescue Grit::NoSuchPathError => ex - respond_to do |format| - format.html {render "projects/empty"} - end - end - - def tree - @repo = project.repo - @branch = if !params[:branch].blank? - params[:branch] - elsif !params[:tag].blank? - params[:tag] - else - "master" - end - - if params[:commit_id] - @commit = @repo.commits(params[:commit_id]).first - else - @commit = @repo.commits(@branch || "master").first - end - @tree = @commit.tree - @tree = @tree / params[:path] if params[:path] - - respond_to do |format| - format.html # show.html.erb - format.js do - # temp solution - response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" - response.headers["Pragma"] = "no-cache" - response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" - end - format.json { render json: project } - end - end - - def blob - @repo = project.repo - @commit = project.commit(params[:commit_id]) - @tree = project.tree(@commit, params[:path]) - - if @tree.is_a?(Grit::Blob) - send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name) - else - head(404) - end end def new @project = Project.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @project } - end end def edit @@ -98,11 +30,9 @@ class ProjectsController < ApplicationController if @project.valid? format.html { redirect_to @project, notice: 'Project was successfully created.' } format.js - format.json { render json: @project, status: :created, location: @project } else format.html { render action: "new" } format.js - format.json { render json: @project.errors, status: :unprocessable_entity } end end rescue Gitosis::AccessDenied @@ -112,7 +42,6 @@ class ProjectsController < ApplicationController respond_to do |format| format.html { render action: "new" } format.js - format.json { render json: @project.errors, status: :unprocessable_entity } end end @@ -121,29 +50,87 @@ class ProjectsController < ApplicationController if project.update_attributes(params[:project]) format.html { redirect_to project, notice: 'Project was successfully updated.' } format.js - format.json { head :ok } else format.html { render action: "edit" } format.js - format.json { render json: project.errors, status: :unprocessable_entity } end end end - def destroy - project.destroy + def show + @repo = project.repo + @commit = @repo.commits.first + @tree = @commit.tree + @tree = @tree / params[:path] if params[:path] + rescue Grit::NoSuchPathError => ex respond_to do |format| - format.html { redirect_to projects_url } - format.json { head :ok } + format.html {render "projects/empty"} end end + # + # Wall + # + def wall @notes = @project.common_notes @note = Note.new end + # + # Repository preview + # + + def tree + load_refs # load @branch, @tag & @ref + + @repo = project.repo + + if params[:commit_id] + @commit = @repo.commits(params[:commit_id]).first + else + @commit = @repo.commits(@ref || "master").first + end + + @tree = @commit.tree + @tree = @tree / params[:path] if params[:path] + + respond_to do |format| + format.html # show.html.erb + format.js do + # diasbale cache to allow back button works + response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate" + response.headers["Pragma"] = "no-cache" + response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" + end + end + rescue + return render_404 + end + + def blob + @repo = project.repo + @commit = project.commit(params[:commit_id]) + @tree = project.tree(@commit, params[:path]) + + if @tree.is_a?(Grit::Blob) + send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name) + else + head(404) + end + rescue + return render_404 + end + + def destroy + project.destroy + + respond_to do |format| + format.html { redirect_to projects_url } + end + end + protected def project diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index fd3c944b289..e00cc36c0eb 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html # show.html.erb format.js - format.json { render json: @team_member } end end @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html # new.html.erb format.js - format.json { render json: @team_member } end end @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController if @team_member.save format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } format.js - format.json { render json: @team_member, status: :created, location: @team_member } else format.html { render action: "new" } format.js - format.json { render json: @team_member.errors, status: :unprocessable_entity } end end end @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController respond_to do |format| format.html { redirect_to root_path } - format.json { head :ok } format.js { render :nothing => true } end end diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 55c41ec31bb..327561dea99 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -11,7 +11,7 @@ - @admin_projects.each do |project| %tr - %td= project.name + %td= link_to project.name, [:admin, project] %td= project.code %td= project.path %td= project.users_projects.count diff --git a/app/views/admin/team_members/index.html.haml b/app/views/admin/team_members/index.html.haml index 4076917da64..bbd7a6c0af8 100644 --- a/app/views/admin/team_members/index.html.haml +++ b/app/views/admin/team_members/index.html.haml @@ -14,7 +14,7 @@ - members.each do |tm| - user = tm.user %tr - %td.span-6= tm.user_name + %td.span-6= link_to tm.user_name, admin_team_member_path(tm) %td.span-6= tm.user_email %td.span-1= check_box_tag "read", 1, project.readers.include?(user), :disabled => :disabled %td.span-1= check_box_tag "commit", 1, project.writers.include?(user), :disabled => :disabled diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index db60a613bce..3b5aa3996bb 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -11,7 +11,7 @@ - @admin_users.each do |user| %tr %td= check_box_tag "admin", 1, user.admin, :disabled => :disabled - %td= user.name + %td= link_to user.name, [:admin, user] %td= user.email %td= user.users_projects.count %td= link_to 'Show', [:admin, user] diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index 95579119aee..452e13f8bdb 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -6,8 +6,10 @@ .left.prepend-1 = form_tag project_commits_path(@project), :method => :get do - = select_tag "tag", options_for_select(@project.tags, @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" + = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url", "one_click_select"] .clear + - if params[:path] + %h3{:style => "color:#555"} /#{params[:path]} %div{:id => dom_id(@project)} = render "commits" diff --git a/app/views/notes/_notes.html.haml b/app/views/notes/_notes.html.haml index 457bb8db763..9d1d4b941c8 100644 --- a/app/views/notes/_notes.html.haml +++ b/app/views/notes/_notes.html.haml @@ -1,5 +1,6 @@ %ul#notes-list - @notes.each do |note| + - next unless note.author = render :partial => "notes/show", :locals => {:note => note} %br diff --git a/app/views/projects/_list.html.haml b/app/views/projects/_list.html.haml index 82e1948c757..aec61ffbbe1 100644 --- a/app/views/projects/_list.html.haml +++ b/app/views/projects/_list.html.haml @@ -1,6 +1,3 @@ --#- if current_user.can_create_project? - = link_to 'New Project', new_project_path, :class => "lbutton vm" - %table.round-borders#projects-list %tr %th Name diff --git a/app/views/projects/_projects_top_menu.html.haml b/app/views/projects/_projects_top_menu.html.haml index be04c57e842..f80f28a8bbb 100644 --- a/app/views/projects/_projects_top_menu.html.haml +++ b/app/views/projects/_projects_top_menu.html.haml @@ -1,6 +1,7 @@ %div.top_project_menu %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil - %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil + - if current_user.can_create_project? + %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil %span.right = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") diff --git a/app/views/projects/_tree.html.haml b/app/views/projects/_tree.html.haml index af3a209a8ab..d1903586400 100644 --- a/app/views/projects/_tree.html.haml +++ b/app/views/projects/_tree.html.haml @@ -5,7 +5,7 @@ .left.prepend-1 = form_tag tree_project_path(@project), :method => :get do - = select_tag "tag", options_for_select(@project.tags, @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" + = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url","one_click_select"] .clear @@ -18,7 +18,7 @@ - if part_path.empty? - part_path = part \/ - = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id)), :remote => :true + = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id), :branch => @branch, :tag => @tag), :remote => :true #tree-content-holder - if tree.is_a?(Grit::Blob) = render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree } @@ -36,7 +36,7 @@ %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } %td.tree-item-file-name = image_tag "dir.png" - = link_to "..", tree_file_project_path(@project, @commit.id, file), :remote => :true + = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true %td %td diff --git a/app/views/projects/_tree_file.html.haml b/app/views/projects/_tree_file.html.haml index 08927fc2aac..3463bfc543f 100644 --- a/app/views/projects/_tree_file.html.haml +++ b/app/views/projects/_tree_file.html.haml @@ -3,7 +3,6 @@ .view_file_header %strong = name - -#= file.mime_type = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" %br/ diff --git a/app/views/projects/_tree_item.html.haml b/app/views/projects/_tree_item.html.haml index 7179368a0c3..9ba33c1ef88 100644 --- a/app/views/projects/_tree_item.html.haml +++ b/app/views/projects/_tree_item.html.haml @@ -1,5 +1,5 @@ - file = params[:path] ? File.join(params[:path], content.name) : content.name -- content_commit = @project.repo.log(@branch, file, :max_count => 1).last +- content_commit = @project.repo.log(@commit.id, file, :max_count => 1).last - return unless content_commit %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } %td.tree-item-file-name @@ -7,7 +7,7 @@ = image_tag "txt.png" - else = image_tag "dir.png" - = link_to truncate(content.name, :length => 40), tree_file_project_path(@project, @commit.id, file), :remote => :true + = link_to truncate(content.name, :length => 40), tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true %td = time_ago_in_words(content_commit.committed_date) ago diff --git a/configure.rb b/configure.rb deleted file mode 100644 index 27bad806ff6..00000000000 --- a/configure.rb +++ /dev/null @@ -1,5 +0,0 @@ -root_path = File.expand_path(File.dirname(__FILE__)) -require File.join(root_path, "install", "prepare") -env = ARGV[0] || "development" - -Install.prepare(env) diff --git a/install.rb b/install.rb new file mode 100644 index 00000000000..a118cb5d6f1 --- /dev/null +++ b/install.rb @@ -0,0 +1,32 @@ +root_path = File.expand_path(File.dirname(__FILE__)) +require File.join(root_path, "lib", "color") +include Color + +# +# ruby ./update.rb development # or test or production (default) +# +envs = ["production", "test", "development"] +env = if envs.include?(ARGV[0]) + ARGV[0] + else + "production" + end + +puts green " == Install for ENV=#{env} ..." + +# bundle install +`bundle install` + +# migrate db +`bundle exec rake db:create RAILS_ENV=#{env}` +`bundle exec rake db:schema:load RAILS_ENV=#{env}` +`bundle exec rake db:seed_fu RAILS_ENV=#{env}` + +puts green %q[ +Administrator account created: + +login.........admin@local.host +password......5iveL!fe +] + +puts green " == Done! Now you can start server" diff --git a/install/prepare.rb b/install/prepare.rb deleted file mode 100644 index f85c01a01ec..00000000000 --- a/install/prepare.rb +++ /dev/null @@ -1,51 +0,0 @@ -module Install - class << self - def prepare(env) - puts green " == Starting for ENV=#{env} ..." - puts "rvm detected" if is_rvm? - - bundler - db(env) - - puts green " == Done! Now you can start server" - end - - def bundler - command 'gem install bundler' - command 'bundle install' - end - - def db(env) - command "bundle exec rake db:setup RAILS_ENV=#{env}" - command "bundle exec rake db:seed_fu RAILS_ENV=#{env}" - end - - def is_rvm? - `type rvm | head -1` =~ /^rvm is/ - end - - def colorize(text, color_code) - "\033[#{color_code}#{text}\033[0m" - end - - def red(text) - colorize(text, "31m") - end - - def green(text) - colorize(text, "32m") - end - - def command(string) - `#{string}` - if $?.to_i > 0 - puts red " == #{string} - FAIL" - puts red " == Error during configure" - exit - else - puts green " == #{string} - OK" - end - end - end -end - diff --git a/lib/color.rb b/lib/color.rb new file mode 100644 index 00000000000..d5500aca8e2 --- /dev/null +++ b/lib/color.rb @@ -0,0 +1,25 @@ +module Color + def colorize(text, color_code) + "\033[#{color_code}#{text}\033[0m" + end + + def red(text) + colorize(text, "31m") + end + + def green(text) + colorize(text, "32m") + end + + def command(string) + `#{string}` + if $?.to_i > 0 + puts red " == #{string} - FAIL" + puts red " == Error during configure" + exit + else + puts green " == #{string} - OK" + end + end +end + diff --git a/spec/requests/projects_tree_perfomance_spec.rb b/spec/requests/projects_tree_perfomance_spec.rb new file mode 100644 index 00000000000..5b4facb17d6 --- /dev/null +++ b/spec/requests/projects_tree_perfomance_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' +require 'benchmark' + +describe "Projects" do + before { login_as :user } + + describe "GET /projects/tree" do + describe "head" do + before do + @project = Factory :project + @project.add_access(@user, :read) + + end + + it "should be fast" do + time = Benchmark.realtime do + visit tree_project_path(@project) + end + (time < 1.0).should be_true + end + end + + describe ValidCommit::ID do + before do + @project = Factory :project + @project.add_access(@user, :read) + end + + it "should be fast" do + time = Benchmark.realtime do + visit tree_project_path(@project, :commit_id => ValidCommit::ID) + end + (time < 1.0).should be_true + end + end + end +end diff --git a/update.rb b/update.rb new file mode 100644 index 00000000000..d7eec2898b2 --- /dev/null +++ b/update.rb @@ -0,0 +1,26 @@ +root_path = File.expand_path(File.dirname(__FILE__)) +require File.join(root_path, "lib", "color") +include Color + +# +# ruby ./update.rb development # or test or production (default) +# +envs = ["production", "test", "development"] +env = if envs.include?(ARGV[0]) + ARGV[0] + else + "production" + end + +puts green " == Update for ENV=#{env}" + +# pull from github +`git pull` + +`bundle install` + +# migrate db +`bundle exec rake db:migrate RAILS_ENV=#{env}` + + +puts green " == Done! Now you can start/restart server" |