Class: DependencyWiring::Git

Inherits:
SCM
  • Object
show all
Defined in:
lib/dependency_wiring/git.rb

Instance Attribute Summary

Attributes inherited from SCM

#opts

Attributes included from Wiring

#dest, #src

Instance Method Summary collapse

Methods inherited from SCM

#initialize, #prepare_dest

Methods included from Wiring

#initialize, #prepare_dest

Constructor Details

This class inherits a constructor from DependencyWiring::SCM

Instance Method Details

#cloneObject



6
7
8
9
10
11
# File 'lib/dependency_wiring/git.rb', line 6

def clone
  ret = sh_with_code("git clone #{git_opts} #{@src} .")
  raise("GIT: Cannot clone #{@src} into #{@dest}! Output: #{ret[0]}") if ret[1] != 0
  rev = git_revision
  update if (rev != @opts[:branc] && rev != default_opts[:rev])
end

#default_optsObject



35
36
37
# File 'lib/dependency_wiring/git.rb', line 35

def default_opts
  { rev: 'HEAD' }
end

#pullObject



13
14
15
16
# File 'lib/dependency_wiring/git.rb', line 13

def pull
  ret = sh_with_code("git fetch #{@src}")
  raise("GIT: Cannot fetch #{@dest}! Output: #{ret[0]}") if ret[1] != 0
end

#to_sObject



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

def to_s
  "git(#{@src}, #{@opts}) -> #{@dest}"
end

#updateObject



18
19
20
21
22
23
# File 'lib/dependency_wiring/git.rb', line 18

def update
  ret = sh_with_code("git checkout #{git_revision}")
  if ret[1] != 0
    raise("GIT: Cannot update #{@dest} to #{git_revision}! Output: #{ret[0]}") 
  end
end

#valid_destination?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
# File 'lib/dependency_wiring/git.rb', line 39

def valid_destination?
  if File.directory? @dest
    Dir.chdir(@dest) {
      File.exists? '.git'
    }
  else
    false
  end
end

#wireObject



25
26
27
28
29
# File 'lib/dependency_wiring/git.rb', line 25

def wire
  super
  pull
  update
end