Commit fba8ad560797500063df84089a99c24fdc5cacd7

Authored by Riyad Preukschas
1 parent 5f166878

Move Gitlab::Satellite into the Satellite module

app/roles/repository.rb
@@ -41,7 +41,7 @@ module Repository @@ -41,7 +41,7 @@ module Repository
41 end 41 end
42 42
43 def satellite 43 def satellite
44 - @satellite ||= Gitlab::Satellite.new(self) 44 + @satellite ||= Gitlab::Satellite::Satellite.new(self)
45 end 45 end
46 46
47 def has_post_receive_file? 47 def has_post_receive_file?
lib/gitlab/satellite.rb
@@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
1 -module Gitlab  
2 - class Satellite  
3 -  
4 - PARKING_BRANCH = "__parking_branch"  
5 -  
6 - attr_accessor :project  
7 -  
8 - def initialize(project)  
9 - @project = project  
10 - end  
11 -  
12 - #will be deleted all branches except PARKING_BRANCH  
13 - def clear  
14 - Dir.chdir(path) do  
15 - heads = Grit::Repo.new(".").heads.map{|head| head.name}  
16 - if heads.include? PARKING_BRANCH  
17 - `git checkout #{PARKING_BRANCH}`  
18 - else  
19 - `git checkout -b #{PARKING_BRANCH}`  
20 - end  
21 - heads.delete(PARKING_BRANCH)  
22 - heads.each do |head|  
23 - `git branch -D #{head}`  
24 - end  
25 - end  
26 - end  
27 -  
28 - def create  
29 - `git clone #{project.url_to_repo} #{path}`  
30 - end  
31 -  
32 - def exists?  
33 - File.exists? path  
34 - end  
35 -  
36 - def path  
37 - Rails.root.join("tmp", "repo_satellites", project.path)  
38 - end  
39 - end  
40 -end  
lib/gitlab/satellite/satellite.rb 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +module Gitlab
  2 + module Satellite
  3 + class Satellite
  4 + PARKING_BRANCH = "__parking_branch"
  5 +
  6 + attr_accessor :project
  7 +
  8 + def initialize(project)
  9 + @project = project
  10 + end
  11 +
  12 + #will be deleted all branches except PARKING_BRANCH
  13 + def clear
  14 + Dir.chdir(path) do
  15 + heads = Grit::Repo.new(".").heads.map{|head| head.name}
  16 + if heads.include? PARKING_BRANCH
  17 + `git checkout #{PARKING_BRANCH}`
  18 + else
  19 + `git checkout -b #{PARKING_BRANCH}`
  20 + end
  21 + heads.delete(PARKING_BRANCH)
  22 + heads.each do |head|
  23 + `git branch -D #{head}`
  24 + end
  25 + end
  26 + end
  27 +
  28 + def create
  29 + `git clone #{project.url_to_repo} #{path}`
  30 + end
  31 +
  32 + def exists?
  33 + File.exists? path
  34 + end
  35 +
  36 + def path
  37 + Rails.root.join("tmp", "repo_satellites", project.path)
  38 + end
  39 + end
  40 + end
  41 +end