Commit 8134fe0efe287f6512b7684d4c654b2d43f3df9d

Authored by Dmitriy Zaporozhets
1 parent 8f4a0bd1

git host fixed

app/controllers/application_controller.rb
... ... @@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base
70 70 end
71 71  
72 72 def require_non_empty_project
73   - redirect_to @project unless @project.repo_exists?
  73 + redirect_to @project unless @project.repo_exists? && @project.has_commits?
74 74 end
75 75  
76 76 def respond_with_notes
... ...
app/controllers/projects_controller.rb
... ... @@ -65,7 +65,7 @@ class ProjectsController < ApplicationController
65 65 end
66 66  
67 67 def show
68   - return render "projects/empty" unless @project.repo_exists?
  68 + return render "projects/empty" unless @project.repo_exists? && @project.has_commits?
69 69 limit = (params[:limit] || 20).to_i
70 70 @activities = @project.cached_updates(limit)
71 71 end
... ...
app/controllers/refs_controller.rb
... ... @@ -52,6 +52,8 @@ class RefsController < ApplicationController
52 52 @commit = project.commit(@ref)
53 53 @tree = Tree.new(@commit.tree, project, @ref, params[:path])
54 54 @tree = TreeDecorator.new(@tree)
  55 + rescue
  56 + return render_404
55 57 end
56 58  
57 59 def ref
... ...
app/models/key.rb
... ... @@ -19,7 +19,7 @@ class Key < ActiveRecord::Base
19 19 end
20 20  
21 21 def update_gitosis
22   - GitoProxy.system.new.configure do |c|
  22 + Gitlabhq::GitHost.system.new.configure do |c|
23 23 c.update_keys(identifier, key)
24 24  
25 25 projects.each do |project|
... ... @@ -29,7 +29,7 @@ class Key < ActiveRecord::Base
29 29 end
30 30  
31 31 def gitosis_delete_key
32   - GitoProxy.system.new.configure do |c|
  32 + Gitlabhq::GitHost.system.new.configure do |c|
33 33 c.delete_key(identifier)
34 34  
35 35 projects.each do |project|
... ...
app/models/project.rb
... ... @@ -95,6 +95,10 @@ class Project < ActiveRecord::Base
95 95 notes.where(:noteable_id => commit.id, :noteable_type => "Commit")
96 96 end
97 97  
  98 + def has_commits?
  99 + !!commit
  100 + end
  101 +
98 102 def add_access(user, *access)
99 103 opts = { :user => user }
100 104 access.each { |name| opts.merge!(name => true) }
... ...
config/gitlab.yml
... ... @@ -11,7 +11,7 @@ email:
11 11 # But gitosis wiil be deprecated &
12 12 # some new features wont work with it
13 13 git_host:
14   - system: gitolite# or gitosis
  14 + system: gitolite
15 15 admin_uri: git@localhost:gitolite-admin
16 16 base_path: /home/git/repositories/
17 17 host: localhost
... ...
lib/gitlabhq/git_host.rb
... ... @@ -4,10 +4,10 @@ require File.join(Rails.root, "lib", "gitlabhq", "gitosis")
4 4 module Gitlabhq
5 5 class GitHost
6 6 def self.system
7   - if GIT_HOST["system"] == "gitolite"
8   - Gitlabhq::Gitolite
9   - else
  7 + if GIT_HOST["system"] == "gitosis"
10 8 Gitlabhq::Gitosis
  9 + else
  10 + Gitlabhq::Gitolite
11 11 end
12 12 end
13 13  
... ...