Class: Magica::Command::Git

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

Overview

:nodoc:

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.



9
10
11
12
13
14
15
16
17
# File 'lib/magica/commands/git.rb', line 9

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.



7
8
9
# File 'lib/magica/commands/git.rb', line 7

def checkout_options
  @checkout_options
end

#clone_optionsObject

Returns the value of attribute clone_options.



7
8
9
# File 'lib/magica/commands/git.rb', line 7

def clone_options
  @clone_options
end

#flagsObject

Returns the value of attribute flags.



6
7
8
# File 'lib/magica/commands/git.rb', line 6

def flags
  @flags
end

#pull_optionsObject

Returns the value of attribute pull_options.



7
8
9
# File 'lib/magica/commands/git.rb', line 7

def pull_options
  @pull_options
end

Instance Method Details

#checkout(dir, checksum_hash) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/magica/commands/git.rb', line 35

def checkout(dir, checksum_hash)
  workin dir do
    _run format(@checkout_options,
                checksum_hash: checksum_hash,
                flags: @flags.join(' '))
  end
end

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



19
20
21
22
23
24
# File 'lib/magica/commands/git.rb', line 19

def clone(dir, url, flags = [])
  _run format(@clone_options,
              flags: [@flags, flags].flatten.join(' '),
              dir: filename(dir),
              url: url)
end

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



26
27
28
29
30
31
32
33
# File 'lib/magica/commands/git.rb', line 26

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