# Class Gitlab::Satellite::Satellite < Object

- lib/gitlab/satellite/satellite.rb

Methods

C
  - clear_and_update!,
  - create
E
  - exists?
L
  - lock,
  - lock_file
N
  - new
P
  - path
R
  - repo

Constants

PARKING_BRANCH | = | "__parking_branch"

Attributes

[RW] | project |

Class Public methods
new(project) Link

Source: show

    # File lib/gitlab/satellite/satellite.rb, line 8
    def initialize(project)
      @project = project
    end

Instance Public methods
clear_and_update!() Link

Source: show

    # 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() Link

Source: show

    # 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?() Link

Source: show

    # File lib/gitlab/satellite/satellite.rb, line 30
    def exists?
      File.exists? path
    end

lock() Link

- Locks the satellite

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

- Yields

Source: show

    # 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() Link

Source: show

    # File lib/gitlab/satellite/satellite.rb, line 49
    def lock_file
      Rails.root.join("tmp", "satellite_#{project.id}.lock")
    end

path() Link

Source: show

    # File lib/gitlab/satellite/satellite.rb, line 53
    def path
      Rails.root.join("tmp", "repo_satellites", project.path_with_namespace)
    end

repo() Link

Source: show

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

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