Commit 0541b3f3c5dcd291d144c83d9731c75ee811b4e0
1 parent
d3784687
Exists in
master
and in
4 other branches
1.0.1
Showing
25 changed files
with
233 additions
and
178 deletions
Show diff stats
CHANGELOG
Gemfile
| ... | ... | @@ -13,7 +13,7 @@ gem "carrierwave" |
| 13 | 13 | gem 'six' |
| 14 | 14 | gem 'therubyracer' |
| 15 | 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 | 17 | gem "inifile" |
| 18 | 18 | gem "albino", :git => "git://github.com/gitlabhq/albino.git" |
| 19 | 19 | gem "kaminari" | ... | ... |
Gemfile.lock
| ... | ... | @@ -22,12 +22,11 @@ GIT |
| 22 | 22 | |
| 23 | 23 | GIT |
| 24 | 24 | remote: git://github.com/mbleigh/seed-fu.git |
| 25 | - revision: 29fe8c61ca6cc4408115ea7475fe2647081bd348 | |
| 26 | - branch: rails-3-1 | |
| 25 | + revision: 77be06852b18fb01e272ab763ddb292da575586c | |
| 27 | 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 | 31 | GEM |
| 33 | 32 | remote: http://rubygems.org/ | ... | ... |
VERSION
app/controllers/application_controller.rb
| ... | ... | @@ -41,4 +41,24 @@ class ApplicationController < ActionController::Base |
| 41 | 41 | super |
| 42 | 42 | end |
| 43 | 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 | 64 | end | ... | ... |
app/controllers/commits_controller.rb
| ... | ... | @@ -8,25 +8,19 @@ class CommitsController < ApplicationController |
| 8 | 8 | before_filter :authorize_read_project! |
| 9 | 9 | |
| 10 | 10 | def index |
| 11 | + load_refs # load @branch, @tag & @ref | |
| 12 | + | |
| 11 | 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 | 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 | 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 | 19 | end |
| 25 | 20 | |
| 26 | 21 | respond_to do |format| |
| 27 | 22 | format.html # index.html.erb |
| 28 | 23 | format.js |
| 29 | - format.json { render json: @commits } | |
| 30 | 24 | end |
| 31 | 25 | end |
| 32 | 26 | |
| ... | ... | @@ -38,7 +32,6 @@ class CommitsController < ApplicationController |
| 38 | 32 | respond_to do |format| |
| 39 | 33 | format.html # show.html.erb |
| 40 | 34 | format.js |
| 41 | - format.json { render json: @commit } | |
| 42 | 35 | end |
| 43 | 36 | end |
| 44 | 37 | end | ... | ... |
app/controllers/keys_controller.rb
| ... | ... | @@ -3,11 +3,6 @@ class KeysController < ApplicationController |
| 3 | 3 | |
| 4 | 4 | def index |
| 5 | 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 | 6 | end |
| 12 | 7 | |
| 13 | 8 | def new |
| ... | ... | @@ -23,8 +18,6 @@ class KeysController < ApplicationController |
| 23 | 18 | respond_with(@key) |
| 24 | 19 | end |
| 25 | 20 | |
| 26 | - # DELETE /keys/1 | |
| 27 | - # DELETE /keys/1.json | |
| 28 | 21 | def destroy |
| 29 | 22 | @key = current_user.keys.find(params[:id]) |
| 30 | 23 | @key.destroy |
| ... | ... | @@ -32,7 +25,6 @@ class KeysController < ApplicationController |
| 32 | 25 | respond_to do |format| |
| 33 | 26 | format.html { redirect_to keys_url } |
| 34 | 27 | format.js { render :nothing => true } |
| 35 | - format.json { head :ok } | |
| 36 | 28 | end |
| 37 | 29 | end |
| 38 | 30 | end | ... | ... |
app/controllers/projects_controller.rb
| ... | ... | @@ -8,78 +8,10 @@ class ProjectsController < ApplicationController |
| 8 | 8 | |
| 9 | 9 | def index |
| 10 | 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 | 11 | end |
| 75 | 12 | |
| 76 | 13 | def new |
| 77 | 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 | 15 | end |
| 84 | 16 | |
| 85 | 17 | def edit |
| ... | ... | @@ -98,11 +30,9 @@ class ProjectsController < ApplicationController |
| 98 | 30 | if @project.valid? |
| 99 | 31 | format.html { redirect_to @project, notice: 'Project was successfully created.' } |
| 100 | 32 | format.js |
| 101 | - format.json { render json: @project, status: :created, location: @project } | |
| 102 | 33 | else |
| 103 | 34 | format.html { render action: "new" } |
| 104 | 35 | format.js |
| 105 | - format.json { render json: @project.errors, status: :unprocessable_entity } | |
| 106 | 36 | end |
| 107 | 37 | end |
| 108 | 38 | rescue Gitosis::AccessDenied |
| ... | ... | @@ -112,7 +42,6 @@ class ProjectsController < ApplicationController |
| 112 | 42 | respond_to do |format| |
| 113 | 43 | format.html { render action: "new" } |
| 114 | 44 | format.js |
| 115 | - format.json { render json: @project.errors, status: :unprocessable_entity } | |
| 116 | 45 | end |
| 117 | 46 | end |
| 118 | 47 | |
| ... | ... | @@ -121,29 +50,87 @@ class ProjectsController < ApplicationController |
| 121 | 50 | if project.update_attributes(params[:project]) |
| 122 | 51 | format.html { redirect_to project, notice: 'Project was successfully updated.' } |
| 123 | 52 | format.js |
| 124 | - format.json { head :ok } | |
| 125 | 53 | else |
| 126 | 54 | format.html { render action: "edit" } |
| 127 | 55 | format.js |
| 128 | - format.json { render json: project.errors, status: :unprocessable_entity } | |
| 129 | 56 | end |
| 130 | 57 | end |
| 131 | 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 | 67 | respond_to do |format| |
| 137 | - format.html { redirect_to projects_url } | |
| 138 | - format.json { head :ok } | |
| 68 | + format.html {render "projects/empty"} | |
| 139 | 69 | end |
| 140 | 70 | end |
| 141 | 71 | |
| 72 | + # | |
| 73 | + # Wall | |
| 74 | + # | |
| 75 | + | |
| 142 | 76 | def wall |
| 143 | 77 | @notes = @project.common_notes |
| 144 | 78 | @note = Note.new |
| 145 | 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 | 134 | protected |
| 148 | 135 | |
| 149 | 136 | def project | ... | ... |
app/controllers/team_members_controller.rb
| ... | ... | @@ -12,7 +12,6 @@ class TeamMembersController < ApplicationController |
| 12 | 12 | respond_to do |format| |
| 13 | 13 | format.html # show.html.erb |
| 14 | 14 | format.js |
| 15 | - format.json { render json: @team_member } | |
| 16 | 15 | end |
| 17 | 16 | end |
| 18 | 17 | |
| ... | ... | @@ -22,7 +21,6 @@ class TeamMembersController < ApplicationController |
| 22 | 21 | respond_to do |format| |
| 23 | 22 | format.html # new.html.erb |
| 24 | 23 | format.js |
| 25 | - format.json { render json: @team_member } | |
| 26 | 24 | end |
| 27 | 25 | end |
| 28 | 26 | |
| ... | ... | @@ -34,11 +32,9 @@ class TeamMembersController < ApplicationController |
| 34 | 32 | if @team_member.save |
| 35 | 33 | format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } |
| 36 | 34 | format.js |
| 37 | - format.json { render json: @team_member, status: :created, location: @team_member } | |
| 38 | 35 | else |
| 39 | 36 | format.html { render action: "new" } |
| 40 | 37 | format.js |
| 41 | - format.json { render json: @team_member.errors, status: :unprocessable_entity } | |
| 42 | 38 | end |
| 43 | 39 | end |
| 44 | 40 | end |
| ... | ... | @@ -59,7 +55,6 @@ class TeamMembersController < ApplicationController |
| 59 | 55 | |
| 60 | 56 | respond_to do |format| |
| 61 | 57 | format.html { redirect_to root_path } |
| 62 | - format.json { head :ok } | |
| 63 | 58 | format.js { render :nothing => true } |
| 64 | 59 | end |
| 65 | 60 | end | ... | ... |
app/views/admin/projects/index.html.haml
app/views/admin/team_members/index.html.haml
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | - members.each do |tm| |
| 15 | 15 | - user = tm.user |
| 16 | 16 | %tr |
| 17 | - %td.span-6= tm.user_name | |
| 17 | + %td.span-6= link_to tm.user_name, admin_team_member_path(tm) | |
| 18 | 18 | %td.span-6= tm.user_email |
| 19 | 19 | %td.span-1= check_box_tag "read", 1, project.readers.include?(user), :disabled => :disabled |
| 20 | 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 | 11 | - @admin_users.each do |user| |
| 12 | 12 | %tr |
| 13 | 13 | %td= check_box_tag "admin", 1, user.admin, :disabled => :disabled |
| 14 | - %td= user.name | |
| 14 | + %td= link_to user.name, [:admin, user] | |
| 15 | 15 | %td= user.email |
| 16 | 16 | %td= user.users_projects.count |
| 17 | 17 | %td= link_to 'Show', [:admin, user] | ... | ... |
app/views/commits/index.html.haml
| ... | ... | @@ -6,8 +6,10 @@ |
| 6 | 6 | |
| 7 | 7 | .left.prepend-1 |
| 8 | 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 | 10 | = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url", "one_click_select"] |
| 11 | 11 | .clear |
| 12 | + - if params[:path] | |
| 13 | + %h3{:style => "color:#555"} /#{params[:path]} | |
| 12 | 14 | %div{:id => dom_id(@project)} |
| 13 | 15 | = render "commits" | ... | ... |
app/views/notes/_notes.html.haml
app/views/projects/_list.html.haml
app/views/projects/_projects_top_menu.html.haml
| 1 | 1 | %div.top_project_menu |
| 2 | 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 | 5 | %span.right |
| 5 | 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 | 5 | |
| 6 | 6 | .left.prepend-1 |
| 7 | 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 | 9 | = text_field_tag "ssh", @project.url_to_repo, :class => ["ssh_project_url","one_click_select"] |
| 10 | 10 | .clear |
| 11 | 11 | |
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | - if part_path.empty? |
| 19 | 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 | 22 | #tree-content-holder |
| 23 | 23 | - if tree.is_a?(Grit::Blob) |
| 24 | 24 | = render :partial => "projects/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree } |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } |
| 37 | 37 | %td.tree-item-file-name |
| 38 | 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 | 40 | %td |
| 41 | 41 | %td |
| 42 | 42 | ... | ... |
app/views/projects/_tree_file.html.haml
| ... | ... | @@ -3,7 +3,6 @@ |
| 3 | 3 | .view_file_header |
| 4 | 4 | %strong |
| 5 | 5 | = name |
| 6 | - -#= file.mime_type | |
| 7 | 6 | = link_to "raw", blob_project_path(@project, :commit_id => @commit.id, :path => params[:path] ), :class => "right", :target => "_blank" |
| 8 | 7 | = link_to "history", project_commits_path(@project, :path => params[:path]), :class => "right", :style => "margin-right:10px;" |
| 9 | 8 | %br/ | ... | ... |
app/views/projects/_tree_item.html.haml
| 1 | 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 | 3 | - return unless content_commit |
| 4 | 4 | %tr{ :class => "tree-item", :url => tree_file_project_path(@project, @commit.id, file) } |
| 5 | 5 | %td.tree-item-file-name |
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | = image_tag "txt.png" |
| 8 | 8 | - else |
| 9 | 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 | 11 | %td |
| 12 | 12 | = time_ago_in_words(content_commit.committed_date) |
| 13 | 13 | ago | ... | ... |
configure.rb
| ... | ... | @@ -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 | -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 | - |
| ... | ... | @@ -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 | + | ... | ... |
| ... | ... | @@ -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 | ... | ... |
| ... | ... | @@ -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" | ... | ... |