Commit 0541b3f3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

1.0.1

parent d3784687
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"
......
......@@ -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/
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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]
......
......@@ -6,8 +6,10 @@
&nbsp;
.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"
%ul#notes-list
- @notes.each do |note|
- next unless note.author
= render :partial => "notes/show", :locals => {:note => note}
%br
......
-#- if current_user.can_create_project?
= link_to 'New Project', new_project_path, :class => "lbutton vm"
%table.round-borders#projects-list
%tr
%th Name
......
%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;")
......
......@@ -5,7 +5,7 @@
&nbsp;
.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
......
......@@ -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/
......
- 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
......
root_path = File.expand_path(File.dirname(__FILE__))
require File.join(root_path, "install", "prepare")
env = ARGV[0] || "development"
Install.prepare(env)
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"
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
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
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
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"
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