Methods
C
E
L
N
P
R
Constants
PARKING_BRANCH = "__parking_branch"
 
Attributes
[RW] project
Class Public methods
new(project)
# File lib/gitlab/satellite/satellite.rb, line 8
def initialize(project)
  @project = project
end
Instance Public methods
clear_and_update!()
# File lib/gitlab/satellite/satellite.rb, line 12
def clear_and_update!
  raise "Satellite doesn't exist" unless exists?

  delete_heads!
  clear_working_dir!
  update_from_source!
end
create()
# File lib/gitlab/satellite/satellite.rb, line 20
def create
  create_cmd = "git clone #{project.url_to_repo} #{path}"
  if system(create_cmd)
    true
  else
    Gitlab::GitLogger.error("Failed to create satellite for #{project.name_with_namespace}")
    false
  end
end
exists?()
# File lib/gitlab/satellite/satellite.rb, line 30
def exists?
  File.exists? path
end
lock()
  • Locks the satellite

  • Changes the current directory to the satellite’s working dir

  • Yields

# File lib/gitlab/satellite/satellite.rb, line 37
def lock
  raise "Satellite doesn't exist" unless exists?

  File.open(lock_file, "w+") do |f|
    f.flock(File::LOCK_EX)

    Dir.chdir(path) do
      return yield
    end
  end
end
lock_file()
# File lib/gitlab/satellite/satellite.rb, line 49
def lock_file
  Rails.root.join("tmp", "satellite_#{project.id}.lock")
end
path()
# File lib/gitlab/satellite/satellite.rb, line 53
def path
  Rails.root.join("tmp", "repo_satellites", project.path_with_namespace)
end
repo()
# File lib/gitlab/satellite/satellite.rb, line 57
def repo
  raise "Satellite doesn't exist" unless exists?

  @repo ||= Grit::Repo.new(path)
end