diff --git a/app/models/project.rb b/app/models/project.rb index 62f89e2cd1becbcc7f2aac6aead662e348fc3937..1d2783be404978441a75a27b74a55c6c4e86ff02 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 6bfdf2255f2b812b7132ec7331660f7ef06d1047..6ac2326d6a8e951e21a20e3c57f58a95bfb94a71 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 164af55d895842a3337aa3d96dcef3aa25b329aa..8734550c17f9fe1ad880b60578c2226f00f5948c 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