From 2fa0a7b272bcf44a2512c64a0903284ce0cba661 Mon Sep 17 00:00:00 2001 From: Evan Davey Date: Thu, 17 Jan 2013 18:22:49 +0000 Subject: [PATCH] mods to allow gitolite on separate host --- app/models/project.rb | 8 +++++++- app/models/repository.rb | 14 +++++++++++--- lib/gitlab/satellite/satellite.rb | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 62f89e2cd1b..1d2783be404 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -181,7 +181,9 @@ class Project < ActiveRecord::Base nil end rescue Grit::NoSuchPathError - nil + self.satellite.create unless self.satellite.exists? + @repository ||= self.satellite.repo + end def git_error? @@ -341,6 +343,10 @@ class Project < ActiveRecord::Base # # All callbacks for post receive should be placed here. def trigger_post_receive(oldrev, newrev, ref, user) + + if self.satellite.exists? + self.satellite.update_from_source! + data = post_receive_data(oldrev, newrev, ref, user) # Create push event diff --git a/app/models/repository.rb b/app/models/repository.rb index 6bfdf2255f2..6ac2326d6a8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -11,10 +11,14 @@ class Repository # Default branch in the repository attr_accessor :root_ref + + # Create repo with full path instead + attr_accessor :full_path - def initialize(path_with_namespace, root_ref = 'master') + def initialize(path_with_namespace, root_ref = 'master', full_path = nil) @root_ref = root_ref || "master" @path_with_namespace = path_with_namespace + @full_path = full_path # Init grit repo object repo @@ -25,11 +29,15 @@ class Repository end def path_to_repo - @path_to_repo ||= File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git") + if @full_path + @path_to_repo = @full_path + else + @path_to_repo ||= File.join(Gitlab.config.gitolite.repos_path, "#{path_with_namespace}.git") + end end def repo - @repo ||= Grit::Repo.new(path_to_repo) + @repo ||= Grit::Repo.new(path_to_repo) end def commit(commit_id = nil) diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 164af55d895..8734550c17f 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -65,6 +65,10 @@ module Gitlab @repo ||= Grit::Repo.new(path) end + + def repository + raise_no_satellite unless exists? + @repository ||= Repository.new(project.path_with_namespace,'master',path) private -- GitLab