Class: Magica::Command::Git

Inherits:
Magica::Command show all
Defined in:
lib/magica/commands/git.rb

Instance Attribute Summary collapse

Attributes inherited from Magica::Command

#build, #command

Instance Method Summary collapse

Constructor Details

#initialize(build) ⇒ Git

Returns a new instance of Git.



6
7
8
9
10
11
12
13
14
# File 'lib/magica/commands/git.rb', line 6

def initialize(build)
  super

  @command = "git"
  @flags = %w[]
  @clone_options = "clone %{flags} %{url} %{dir}"
  @pull_options = "pull %{flags} %{remote} %{branch}"
  @checkout_options = "checkout %{flags} %{checksum_hash}"
end

Instance Attribute Details

#checkout_optionsObject

Returns the value of attribute checkout_options.



4
5
6
# File 'lib/magica/commands/git.rb', line 4

def checkout_options
  @checkout_options
end

#clone_optionsObject

Returns the value of attribute clone_options.



4
5
6
# File 'lib/magica/commands/git.rb', line 4

def clone_options
  @clone_options
end

#flagsObject

Returns the value of attribute flags.



3
4
5
# File 'lib/magica/commands/git.rb', line 3

def flags
  @flags
end

#pull_optionsObject

Returns the value of attribute pull_options.



4
5
6
# File 'lib/magica/commands/git.rb', line 4

def pull_options
  @pull_options
end

Instance Method Details

#checkout(dir, checksum_hash) ⇒ Object



30
31
32
33
34
# File 'lib/magica/commands/git.rb', line 30

def checkout(dir, checksum_hash)
  workin dir do
    _run @checkout_options % {checksum_hash: checksum_hash, flags: @flags.join(" ")}
  end
end

#clone(dir, url, _flags = []) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/magica/commands/git.rb', line 16

def clone(dir, url, _flags = [])
  _run @clone_options % {
    flags: [@flags, _flags].flatten.join(" "),
    dir: filename(dir),
    url: url
  }
end

#pull(dir, remote = 'origin', branch = 'master') ⇒ Object



24
25
26
27
28
# File 'lib/magica/commands/git.rb', line 24

def pull(dir, remote = 'origin', branch = 'master')
  workin dir do
    _run @pull_options % {remote: remote, branch: branch, flags: @flags.join(" ")}
  end
end