Commit 0541b3f3c5dcd291d144c83d9731c75ee811b4e0

Authored by Dmitriy Zaporozhets
1 parent d3784687

1.0.1

  1 +v 1.0.1
  2 + - fixed: with invalid source code for commit
  3 + - fixed: lose branch/tag selection when use tree navigateion
  4 + - when history clicked - display path
  5 + - bug fix & code cleaning
1 v 1.0.0 6 v 1.0.0
2 - bug fix 7 - bug fix
3 - projects preview mode 8 - projects preview mode
@@ -13,7 +13,7 @@ gem "carrierwave" @@ -13,7 +13,7 @@ gem "carrierwave"
13 gem 'six' 13 gem 'six'
14 gem 'therubyracer' 14 gem 'therubyracer'
15 gem 'faker' 15 gem 'faker'
16 -gem 'seed-fu', :branch => 'rails-3-1', :git => 'git://github.com/mbleigh/seed-fu.git' 16 +gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git'
17 gem "inifile" 17 gem "inifile"
18 gem "albino", :git => "git://github.com/gitlabhq/albino.git" 18 gem "albino", :git => "git://github.com/gitlabhq/albino.git"
19 gem "kaminari" 19 gem "kaminari"
@@ -22,12 +22,11 @@ GIT @@ -22,12 +22,11 @@ GIT
22 22
23 GIT 23 GIT
24 remote: git://github.com/mbleigh/seed-fu.git 24 remote: git://github.com/mbleigh/seed-fu.git
25 - revision: 29fe8c61ca6cc4408115ea7475fe2647081bd348  
26 - branch: rails-3-1 25 + revision: 77be06852b18fb01e272ab763ddb292da575586c
27 specs: 26 specs:
28 - seed-fu (2.0.1.rails31)  
29 - activerecord (~> 3.1.0.rc4)  
30 - activesupport (~> 3.1.0.rc4) 27 + seed-fu (2.1.0)
  28 + activerecord (~> 3.1.0)
  29 + activesupport (~> 3.1.0)
31 30
32 GEM 31 GEM
33 remote: http://rubygems.org/ 32 remote: http://rubygems.org/
1 -1.0.0 1 +1.0.1
app/controllers/application_controller.rb
@@ -41,4 +41,24 @@ class ApplicationController < ActionController::Base @@ -41,4 +41,24 @@ class ApplicationController < ActionController::Base
41 super 41 super
42 end 42 end
43 end 43 end
  44 +
  45 + def load_refs
  46 + @branch = unless params[:branch].blank?
  47 + params[:branch]
  48 + else
  49 + nil
  50 + end
  51 +
  52 + @tag = unless params[:tag].blank?
  53 + params[:tag]
  54 + else
  55 + nil
  56 + end
  57 +
  58 + @ref = @branch || @tag || "master"
  59 + end
  60 +
  61 + def render_404
  62 + render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404"
  63 + end
44 end 64 end
app/controllers/commits_controller.rb
@@ -8,25 +8,19 @@ class CommitsController < ApplicationController @@ -8,25 +8,19 @@ class CommitsController < ApplicationController
8 before_filter :authorize_read_project! 8 before_filter :authorize_read_project!
9 9
10 def index 10 def index
  11 + load_refs # load @branch, @tag & @ref
  12 +
11 @repo = project.repo 13 @repo = project.repo
12 - @branch = if !params[:branch].blank?  
13 - params[:branch]  
14 - elsif !params[:tag].blank?  
15 - params[:tag]  
16 - else  
17 - "master"  
18 - end  
19 14
20 if params[:path] 15 if params[:path]
21 - @commits = @repo.log(@branch, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0) 16 + @commits = @repo.log(@ref, params[:path], :max_count => params[:limit] || 100, :skip => params[:offset] || 0)
22 else 17 else
23 - @commits = @repo.commits(@branch, params[:limit] || 100, params[:offset] || 0) 18 + @commits = @repo.commits(@ref, params[:limit] || 100, params[:offset] || 0)
24 end 19 end
25 20
26 respond_to do |format| 21 respond_to do |format|
27 format.html # index.html.erb 22 format.html # index.html.erb
28 format.js 23 format.js
29 - format.json { render json: @commits }  
30 end 24 end
31 end 25 end
32 26
@@ -38,7 +32,6 @@ class CommitsController < ApplicationController @@ -38,7 +32,6 @@ class CommitsController < ApplicationController
38 respond_to do |format| 32 respond_to do |format|
39 format.html # show.html.erb 33 format.html # show.html.erb
40 format.js 34 format.js
41 - format.json { render json: @commit }  
42 end 35 end
43 end 36 end
44 end 37 end
app/controllers/keys_controller.rb
@@ -3,11 +3,6 @@ class KeysController < ApplicationController @@ -3,11 +3,6 @@ class KeysController < ApplicationController
3 3
4 def index 4 def index
5 @keys = current_user.keys.all 5 @keys = current_user.keys.all
6 -  
7 - respond_to do |format|  
8 - format.html # index.html.erb  
9 - format.json { render json: @keys }  
10 - end  
11 end 6 end
12 7
13 def new 8 def new
@@ -23,8 +18,6 @@ class KeysController < ApplicationController @@ -23,8 +18,6 @@ class KeysController < ApplicationController
23 respond_with(@key) 18 respond_with(@key)
24 end 19 end
25 20
26 - # DELETE /keys/1  
27 - # DELETE /keys/1.json  
28 def destroy 21 def destroy
29 @key = current_user.keys.find(params[:id]) 22 @key = current_user.keys.find(params[:id])
30 @key.destroy 23 @key.destroy
@@ -32,7 +25,6 @@ class KeysController < ApplicationController @@ -32,7 +25,6 @@ class KeysController < ApplicationController
32 respond_to do |format| 25 respond_to do |format|
33 format.html { redirect_to keys_url } 26 format.html { redirect_to keys_url }
34 format.js { render :nothing => true } 27 format.js { render :nothing => true }
35 - format.json { head :ok }  
36 end 28 end
37 end 29 end
38 end 30 end
app/controllers/projects_controller.rb
@@ -8,78 +8,10 @@ class ProjectsController < ApplicationController @@ -8,78 +8,10 @@ class ProjectsController < ApplicationController
8 8
9 def index 9 def index
10 @projects = current_user.projects.all 10 @projects = current_user.projects.all
11 -  
12 - respond_to do |format|  
13 - format.html # index.html.erb  
14 - format.json { render json: @projects }  
15 - end  
16 - end  
17 -  
18 - def show  
19 - @repo = project.repo  
20 - @commit = @repo.commits.first  
21 - @tree = @commit.tree  
22 - @tree = @tree / params[:path] if params[:path]  
23 -  
24 - respond_to do |format|  
25 - format.html # show.html.erb  
26 - format.json { render json: project }  
27 - end  
28 - rescue Grit::NoSuchPathError => ex  
29 - respond_to do |format|  
30 - format.html {render "projects/empty"}  
31 - end  
32 - end  
33 -  
34 - def tree  
35 - @repo = project.repo  
36 - @branch = if !params[:branch].blank?  
37 - params[:branch]  
38 - elsif !params[:tag].blank?  
39 - params[:tag]  
40 - else  
41 - "master"  
42 - end  
43 -  
44 - if params[:commit_id]  
45 - @commit = @repo.commits(params[:commit_id]).first  
46 - else  
47 - @commit = @repo.commits(@branch || "master").first  
48 - end  
49 - @tree = @commit.tree  
50 - @tree = @tree / params[:path] if params[:path]  
51 -  
52 - respond_to do |format|  
53 - format.html # show.html.erb  
54 - format.js do  
55 - # temp solution  
56 - response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"  
57 - response.headers["Pragma"] = "no-cache"  
58 - response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"  
59 - end  
60 - format.json { render json: project }  
61 - end  
62 - end  
63 -  
64 - def blob  
65 - @repo = project.repo  
66 - @commit = project.commit(params[:commit_id])  
67 - @tree = project.tree(@commit, params[:path])  
68 -  
69 - if @tree.is_a?(Grit::Blob)  
70 - send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)  
71 - else  
72 - head(404)  
73 - end  
74 end 11 end
75 12
76 def new 13 def new
77 @project = Project.new 14 @project = Project.new
78 -  
79 - respond_to do |format|  
80 - format.html # new.html.erb  
81 - format.json { render json: @project }  
82 - end  
83 end 15 end
84 16
85 def edit 17 def edit
@@ -98,11 +30,9 @@ class ProjectsController < ApplicationController @@ -98,11 +30,9 @@ class ProjectsController < ApplicationController
98 if @project.valid? 30 if @project.valid?
99 format.html { redirect_to @project, notice: 'Project was successfully created.' } 31 format.html { redirect_to @project, notice: 'Project was successfully created.' }
100 format.js 32 format.js
101 - format.json { render json: @project, status: :created, location: @project }  
102 else 33 else
103 format.html { render action: "new" } 34 format.html { render action: "new" }
104 format.js 35 format.js
105 - format.json { render json: @project.errors, status: :unprocessable_entity }  
106 end 36 end
107 end 37 end
108 rescue Gitosis::AccessDenied 38 rescue Gitosis::AccessDenied
@@ -112,7 +42,6 @@ class ProjectsController < ApplicationController @@ -112,7 +42,6 @@ class ProjectsController < ApplicationController
112 respond_to do |format| 42 respond_to do |format|
113 format.html { render action: "new" } 43 format.html { render action: "new" }
114 format.js 44 format.js
115 - format.json { render json: @project.errors, status: :unprocessable_entity }  
116 end 45 end
117 end 46 end
118 47
@@ -121,29 +50,87 @@ class ProjectsController < ApplicationController @@ -121,29 +50,87 @@ class ProjectsController < ApplicationController
121 if project.update_attributes(params[:project]) 50 if project.update_attributes(params[:project])
122 format.html { redirect_to project, notice: 'Project was successfully updated.' } 51 format.html { redirect_to project, notice: 'Project was successfully updated.' }
123 format.js 52 format.js
124 - format.json { head :ok }  
125 else 53 else
126 format.html { render action: "edit" } 54 format.html { render action: "edit" }
127 format.js 55 format.js
128 - format.json { render json: project.errors, status: :unprocessable_entity }  
129 end 56 end
130 end 57 end
131 end 58 end
132 59
133 - def destroy  
134 - project.destroy 60 + def show
  61 + @repo = project.repo
  62 + @commit = @repo.commits.first
  63 + @tree = @commit.tree
  64 + @tree = @tree / params[:path] if params[:path]
135 65
  66 + rescue Grit::NoSuchPathError => ex
136 respond_to do |format| 67 respond_to do |format|
137 - format.html { redirect_to projects_url }  
138 - format.json { head :ok } 68 + format.html {render "projects/empty"}
139 end 69 end
140 end 70 end
141 71
  72 + #
  73 + # Wall
  74 + #
  75 +
142 def wall 76 def wall
143 @notes = @project.common_notes 77 @notes = @project.common_notes
144 @note = Note.new 78 @note = Note.new
145 end 79 end
146 80
  81 + #
  82 + # Repository preview
  83 + #
  84 +
  85 + def tree
  86 + load_refs # load @branch, @tag & @ref
  87 +
  88 + @repo = project.repo
  89 +
  90 + if params[:commit_id]
  91 + @commit = @repo.commits(params[:commit_id]).first
  92 + else
  93 + @commit = @repo.commits(@ref || "master").first
  94 + end
  95 +
  96 + @tree = @commit.tree
  97 + @tree = @tree / params[:path] if params[:path]
  98 +
  99 + respond_to do |format|
  100 + format.html # show.html.erb
  101 + format.js do
  102 + # diasbale cache to allow back button works
  103 + response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
  104 + response.headers["Pragma"] = "no-cache"
  105 + response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
  106 + end
  107 + end
  108 + rescue
  109 + return render_404
  110 + end
  111 +
  112 + def blob
  113 + @repo = project.repo
  114 + @commit = project.commit(params[:commit_id])
  115 + @tree = project.tree(@commit, params[:path])
  116 +
  117 + if @tree.is_a?(Grit::Blob)
  118 + send_data(@tree.data, :type => @tree.mime_type, :disposition => 'inline', :filename => @tree.name)
  119 + else
  120 + head(404)
  121 + end
  122 + rescue
  123 + return render_404
  124 + end
  125 +
  126 + def destroy
  127 + project.destroy
  128 +
  129 + respond_to do |format|
  130 + format.html { redirect_to projects_url }
  131 + end
  132 + end
  133 +
147 protected 134 protected
148 135
149 def project 136 def project
app/controllers/team_members_controller.rb
@@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController
12 respond_to do |format| 12 respond_to do |format|
13 format.html # show.html.erb 13 format.html # show.html.erb
14 format.js 14 format.js
15 - format.json { render json: @team_member }  
16 end 15 end
17 end 16 end
18 17
@@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController
22 respond_to do |format| 21 respond_to do |format|
23 format.html # new.html.erb 22 format.html # new.html.erb
24 format.js 23 format.js
25 - format.json { render json: @team_member }  
26 end 24 end
27 end 25 end
28 26
@@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController
34 if @team_member.save 32 if @team_member.save
35 format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } 33 format.html { redirect_to @team_member, notice: 'Team member was successfully created.' }
36 format.js 34 format.js
37 - format.json { render json: @team_member, status: :created, location: @team_member }  
38 else 35 else
39 format.html { render action: "new" } 36 format.html { render action: "new" }
40 format.js 37 format.js
41 - format.json { render json: @team_member.errors, status: :unprocessable_entity }  
42 end 38 end
43 end 39 end
44 end 40 end
@@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController
59 55
60 respond_to do |format| 56 respond_to do |format|
61 format.html { redirect_to root_path } 57 format.html { redirect_to root_path }
62 - format.json { head :ok }  
63 format.js { render :nothing => true } 58 format.js { render :nothing => true }
64 end 59 end
65 end 60 end
app/views/admin/projects/index.html.haml
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 11
12 - @admin_projects.each do |project| 12 - @admin_projects.each do |project|
13 %tr 13 %tr
14 - %td= project.name 14 + %td= link_to project.name, [:admin, project]
15 %td= project.code 15 %td= project.code
16 %td= project.path 16 %td= project.path
17 %td= project.users_projects.count 17 %td= project.users_projects.count
app/views/admin/team_members/index.html.haml
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 - members.each do |tm| 14 - members.each do |tm|
15 - user = tm.user 15 - user = tm.user
16 %tr 16 %tr
17 - %td.span-6= tm.user_name 17 + %td.span-6= link_to tm.user_name, admin_team_member_path(tm)
18 %td.span-6= tm.user_email 18 %td.span-6= tm.user_email
19 %td.span-1= check_box_tag "read", 1, project.readers.include?(user), :disabled => :disabled 19 %td.span-1= check_box_tag "read", 1, project.readers.include?(user), :disabled => :disabled
20 %td.span-1= check_box_tag "commit", 1, project.writers.include?(user), :disabled => :disabled 20 %td.span-1= check_box_tag "commit", 1, project.writers.include?(user), :disabled => :disabled
app/views/admin/users/index.html.haml
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 - @admin_users.each do |user| 11 - @admin_users.each do |user|
12 %tr 12 %tr
13 %td= check_box_tag "admin", 1, user.admin, :disabled => :disabled 13 %td= check_box_tag "admin", 1, user.admin, :disabled => :disabled
14 - %td= user.name 14 + %td= link_to user.name, [:admin, user]
15 %td= user.email 15 %td= user.email
16 %td= user.users_projects.count 16 %td= user.users_projects.count
17 %td= link_to 'Show', [:admin, user] 17 %td= link_to 'Show', [:admin, user]
app/views/commits/index.html.haml
@@ -6,8 +6,10 @@ @@ -6,8 +6,10 @@
6   6  
7 .left.prepend-1 7 .left.prepend-1
8 = form_tag project_commits_path(@project), :method => :get do 8 = form_tag project_commits_path(@project), :method => :get do
9 - = select_tag "tag", options_for_select(@project.tags, @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" 9 + = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags"
10 = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url", "one_click_select"] 10 = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url", "one_click_select"]
11 .clear 11 .clear
  12 + - if params[:path]
  13 + %h3{:style => "color:#555"} /#{params[:path]}
12 %div{:id => dom_id(@project)} 14 %div{:id => dom_id(@project)}
13 = render "commits" 15 = render "commits"
app/views/notes/_notes.html.haml
1 %ul#notes-list 1 %ul#notes-list
2 - @notes.each do |note| 2 - @notes.each do |note|
  3 + - next unless note.author
3 = render :partial => "notes/show", :locals => {:note => note} 4 = render :partial => "notes/show", :locals => {:note => note}
4 5
5 %br 6 %br
app/views/projects/_list.html.haml
1 --#- if current_user.can_create_project?  
2 - = link_to 'New Project', new_project_path, :class => "lbutton vm"  
3 -  
4 %table.round-borders#projects-list 1 %table.round-borders#projects-list
5 %tr 2 %tr
6 %th Name 3 %th Name
app/views/projects/_projects_top_menu.html.haml
1 %div.top_project_menu 1 %div.top_project_menu
2 %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil 2 %span= link_to 'All', projects_path, :class => current_page?(projects_path) ? "current" : nil
3 - %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil 3 + - if current_user.can_create_project?
  4 + %span= link_to "New Project", new_project_path, :class => current_page?(:controller => "projects", :action => "new") ? "current" : nil
4 %span.right 5 %span.right
5 = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;") 6 = link_to_function(image_tag("list_view_icon.jpg"), "switchProjectView()", :style => "border:none;box-shadow:none;")
6 7
app/views/projects/_tree.html.haml
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5   5  
6 .left.prepend-1 6 .left.prepend-1
7 = form_tag tree_project_path(@project), :method => :get do 7 = form_tag tree_project_path(@project), :method => :get do
8 - = select_tag "tag", options_for_select(@project.tags, @branch), :onchange => "this.form.submit();", :class => "", :prompt => "Tags" 8 + = select_tag "tag", options_for_select(@project.tags, @tag), :onchange => "this.form.submit();", :class => "", :prompt => "Tags"
9 = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url","one_click_select"] 9 = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url","one_click_select"]
10 .clear 10 .clear
11 11
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 - if part_path.empty? 18 - if part_path.empty?
19 - part_path = part 19 - part_path = part
20 \/ 20 \/
21 - = link_to truncate(part, :length => 40), tree_file_project_path(@project, :path => part_path, :commit_id => @commit.try(:id)), :remote => :true 21 + = 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
22 #tree-content-holder 22 #tree-content-holder
23 - if tree.is_a?(Grit::Blob) 23 - if tree.is_a?(Grit::Blob)
24 = render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree } 24 = render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } 36 %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
37 %td.tree-item-file-name 37 %td.tree-item-file-name
38 = image_tag "dir.png" 38 = image_tag "dir.png"
39 - = link_to "..", tree_file_project_path(@project, @commit.id, file), :remote => :true 39 + = link_to "..", tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
40 %td 40 %td
41 %td 41 %td
42 42
app/views/projects/_tree_file.html.haml
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 .view_file_header 3 .view_file_header
4 %strong 4 %strong
5 = name 5 = name
6 - -#= file.mime_type  
7 = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" 6 = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank"
8 = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" 7 = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;"
9 %br/ 8 %br/
app/views/projects/_tree_item.html.haml
1 - file = params[:path] ? File.join(params[:path], content.name) : content.name 1 - file = params[:path] ? File.join(params[:path], content.name) : content.name
2 -- content_commit = @project.repo.log(@branch, file, :max_count => 1).last 2 +- content_commit = @project.repo.log(@commit.id, file, :max_count => 1).last
3 - return unless content_commit 3 - return unless content_commit
4 %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } 4 %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) }
5 %td.tree-item-file-name 5 %td.tree-item-file-name
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 = image_tag "txt.png" 7 = image_tag "txt.png"
8 - else 8 - else
9 = image_tag "dir.png" 9 = image_tag "dir.png"
10 - = link_to truncate(content.name, :length => 40), tree_file_project_path(@project, @commit.id, file), :remote => :true 10 + = link_to truncate(content.name, :length => 40), tree_file_project_path(@project, @commit.id, file, :branch => @branch, :tag => @tag), :remote => :true
11 %td 11 %td
12 = time_ago_in_words(content_commit.committed_date) 12 = time_ago_in_words(content_commit.committed_date)
13 ago 13 ago
configure.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -root_path = File.expand_path(File.dirname(__FILE__))  
2 -require File.join(root_path, "install", "prepare")  
3 -env = ARGV[0] || "development"  
4 -  
5 -Install.prepare(env)  
install.rb 0 → 100644
@@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
  1 +root_path = File.expand_path(File.dirname(__FILE__))
  2 +require File.join(root_path, "lib", "color")
  3 +include Color
  4 +
  5 +#
  6 +# ruby ./update.rb development # or test or production (default)
  7 +#
  8 +envs = ["production", "test", "development"]
  9 +env = if envs.include?(ARGV[0])
  10 + ARGV[0]
  11 + else
  12 + "production"
  13 + end
  14 +
  15 +puts green " == Install for ENV=#{env} ..."
  16 +
  17 +# bundle install
  18 +`bundle install`
  19 +
  20 +# migrate db
  21 +`bundle exec rake db:create RAILS_ENV=#{env}`
  22 +`bundle exec rake db:schema:load RAILS_ENV=#{env}`
  23 +`bundle exec rake db:seed_fu RAILS_ENV=#{env}`
  24 +
  25 +puts green %q[
  26 +Administrator account created:
  27 +
  28 +login.........admin@local.host
  29 +password......5iveL!fe
  30 +]
  31 +
  32 +puts green " == Done! Now you can start server"
install/prepare.rb
@@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
1 -module Install  
2 - class << self  
3 - def prepare(env)  
4 - puts green " == Starting for ENV=#{env} ..."  
5 - puts "rvm detected" if is_rvm?  
6 -  
7 - bundler  
8 - db(env)  
9 -  
10 - puts green " == Done! Now you can start server"  
11 - end  
12 -  
13 - def bundler  
14 - command 'gem install bundler'  
15 - command 'bundle install'  
16 - end  
17 -  
18 - def db(env)  
19 - command "bundle exec rake db:setup RAILS_ENV=#{env}"  
20 - command "bundle exec rake db:seed_fu RAILS_ENV=#{env}"  
21 - end  
22 -  
23 - def is_rvm?  
24 - `type rvm | head -1` =~ /^rvm is/  
25 - end  
26 -  
27 - def colorize(text, color_code)  
28 - "\033[#{color_code}#{text}\033[0m"  
29 - end  
30 -  
31 - def red(text)  
32 - colorize(text, "31m")  
33 - end  
34 -  
35 - def green(text)  
36 - colorize(text, "32m")  
37 - end  
38 -  
39 - def command(string)  
40 - `#{string}`  
41 - if $?.to_i > 0  
42 - puts red " == #{string} - FAIL"  
43 - puts red " == Error during configure"  
44 - exit  
45 - else  
46 - puts green " == #{string} - OK"  
47 - end  
48 - end  
49 - end  
50 -end  
51 -  
lib/color.rb 0 → 100644
@@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
  1 +module Color
  2 + def colorize(text, color_code)
  3 + "\033[#{color_code}#{text}\033[0m"
  4 + end
  5 +
  6 + def red(text)
  7 + colorize(text, "31m")
  8 + end
  9 +
  10 + def green(text)
  11 + colorize(text, "32m")
  12 + end
  13 +
  14 + def command(string)
  15 + `#{string}`
  16 + if $?.to_i > 0
  17 + puts red " == #{string} - FAIL"
  18 + puts red " == Error during configure"
  19 + exit
  20 + else
  21 + puts green " == #{string} - OK"
  22 + end
  23 + end
  24 +end
  25 +
spec/requests/projects_tree_perfomance_spec.rb 0 → 100644
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +require 'spec_helper'
  2 +require 'benchmark'
  3 +
  4 +describe "Projects" do
  5 + before { login_as :user }
  6 +
  7 + describe "GET /projects/tree" do
  8 + describe "head" do
  9 + before do
  10 + @project = Factory :project
  11 + @project.add_access(@user, :read)
  12 +
  13 + end
  14 +
  15 + it "should be fast" do
  16 + time = Benchmark.realtime do
  17 + visit tree_project_path(@project)
  18 + end
  19 + (time < 1.0).should be_true
  20 + end
  21 + end
  22 +
  23 + describe ValidCommit::ID do
  24 + before do
  25 + @project = Factory :project
  26 + @project.add_access(@user, :read)
  27 + end
  28 +
  29 + it "should be fast" do
  30 + time = Benchmark.realtime do
  31 + visit tree_project_path(@project, :commit_id => ValidCommit::ID)
  32 + end
  33 + (time < 1.0).should be_true
  34 + end
  35 + end
  36 + end
  37 +end
update.rb 0 → 100644
@@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
  1 +root_path = File.expand_path(File.dirname(__FILE__))
  2 +require File.join(root_path, "lib", "color")
  3 +include Color
  4 +
  5 +#
  6 +# ruby ./update.rb development # or test or production (default)
  7 +#
  8 +envs = ["production", "test", "development"]
  9 +env = if envs.include?(ARGV[0])
  10 + ARGV[0]
  11 + else
  12 + "production"
  13 + end
  14 +
  15 +puts green " == Update for ENV=#{env}"
  16 +
  17 +# pull from github
  18 +`git pull`
  19 +
  20 +`bundle install`
  21 +
  22 +# migrate db
  23 +`bundle exec rake db:migrate RAILS_ENV=#{env}`
  24 +
  25 +
  26 +puts green " == Done! Now you can start/restart server"