Class: Silo::Remote::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/silo/remote/git.rb

Overview

This class represents a standard Git remote attached to the Git repository backing the Silo repository

See Also:

Instance Attribute Summary

Attributes inherited from Base

#name, #url

Instance Method Summary collapse

Constructor Details

#initialize(repo, name, url) ⇒ Git

Creates a new Git remote

Parameters:

  • repo (Repository)

    The Silo repository this remote belongs to

  • name (String)

    The name of the remote

  • url (String)

    The URL of the remote Git repository. This may use any protocol supported by Git (+git:+, +file:+, +http(s):+)



24
25
26
27
28
# File 'lib/silo/remote/git.rb', line 24

def initialize(repo, name, url)
  super repo, name

  @url = url
end

Instance Method Details

#addObject

Adds this remote as a mirror to the backing Git repository



31
32
33
# File 'lib/silo/remote/git.rb', line 31

def add
  @repo.git.git.remote({}, 'add', '--mirror', @name, @url)
end

#pushObject

Pushes the current history of the repository to the remote repository using git push



37
38
39
# File 'lib/silo/remote/git.rb', line 37

def push
  @repo.git.git.push({}, @name)
end

#removeObject

Removes this remote from the backing Git repository



42
43
44
# File 'lib/silo/remote/git.rb', line 42

def remove
  @repo.git.git.remote({}, 'rm', @name)
end