Move Gitlab::Satellite into the Satellite module
This commit is contained in:
parent
5f16687805
commit
fba8ad5607
3 changed files with 42 additions and 41 deletions
|
@ -41,7 +41,7 @@ module Repository
|
|||
end
|
||||
|
||||
def satellite
|
||||
@satellite ||= Gitlab::Satellite.new(self)
|
||||
@satellite ||= Gitlab::Satellite::Satellite.new(self)
|
||||
end
|
||||
|
||||
def has_post_receive_file?
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
module Gitlab
|
||||
class Satellite
|
||||
|
||||
PARKING_BRANCH = "__parking_branch"
|
||||
|
||||
attr_accessor :project
|
||||
|
||||
def initialize(project)
|
||||
@project = project
|
||||
end
|
||||
|
||||
#will be deleted all branches except PARKING_BRANCH
|
||||
def clear
|
||||
Dir.chdir(path) do
|
||||
heads = Grit::Repo.new(".").heads.map{|head| head.name}
|
||||
if heads.include? PARKING_BRANCH
|
||||
`git checkout #{PARKING_BRANCH}`
|
||||
else
|
||||
`git checkout -b #{PARKING_BRANCH}`
|
||||
end
|
||||
heads.delete(PARKING_BRANCH)
|
||||
heads.each do |head|
|
||||
`git branch -D #{head}`
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
`git clone #{project.url_to_repo} #{path}`
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.exists? path
|
||||
end
|
||||
|
||||
def path
|
||||
Rails.root.join("tmp", "repo_satellites", project.path)
|
||||
end
|
||||
end
|
||||
end
|
41
lib/gitlab/satellite/satellite.rb
Normal file
41
lib/gitlab/satellite/satellite.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Gitlab
|
||||
module Satellite
|
||||
class Satellite
|
||||
PARKING_BRANCH = "__parking_branch"
|
||||
|
||||
attr_accessor :project
|
||||
|
||||
def initialize(project)
|
||||
@project = project
|
||||
end
|
||||
|
||||
#will be deleted all branches except PARKING_BRANCH
|
||||
def clear
|
||||
Dir.chdir(path) do
|
||||
heads = Grit::Repo.new(".").heads.map{|head| head.name}
|
||||
if heads.include? PARKING_BRANCH
|
||||
`git checkout #{PARKING_BRANCH}`
|
||||
else
|
||||
`git checkout -b #{PARKING_BRANCH}`
|
||||
end
|
||||
heads.delete(PARKING_BRANCH)
|
||||
heads.each do |head|
|
||||
`git branch -D #{head}`
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
`git clone #{project.url_to_repo} #{path}`
|
||||
end
|
||||
|
||||
def exists?
|
||||
File.exists? path
|
||||
end
|
||||
|
||||
def path
|
||||
Rails.root.join("tmp", "repo_satellites", project.path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue