Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlabhq/satellite.rb')
-rw-r--r--lib/gitlabhq/satellite.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gitlabhq/satellite.rb b/lib/gitlabhq/satellite.rb
new file mode 100644
index 00000000000..cd713a647cc
--- /dev/null
+++ b/lib/gitlabhq/satellite.rb
@@ -0,0 +1,41 @@
+module Gitlabhq
+ class Satellite
+
+ PARKING_BRANCH = "__parking_branch"
+
+ attr_accessor :project
+
+ def initialize project
+ self.project = project
+ end
+
+ def create
+ `git clone #{project.url_to_repo} #{path}`
+ end
+
+ def path
+ File.join(Rails.root, "tmp", "repo_satellites", project.path)
+ end
+
+ def exists?
+ File.exists? path
+ 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
+
+ end
+end