Method: Pipeline::GitMounter#mount

Defined in:
lib/pipeline/mounters/git_mounter.rb

#mount(target) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pipeline/mounters/git_mounter.rb', line 15

def mount target
  base = @options[:working_dir]

  Pipeline.debug "Making base."
  FileUtils.mkdir_p base

  # Grap the path part of the git url.
  protocol, path, suffix = target.match(/\A(.*\/\/)(.*)(.git)\z/i).captures
  working_target = File.expand_path(base + "" + path + "/")
  
  Pipeline.notify "Cleaning directory: #{working_target}"
  if ! Dir.exists? working_target      
    Pipeline.notify "#{working_target} is not a directory."              
    FileUtils.mkdir_p working_target
  else
    Pipeline.debug "Removing : #{working_target}"  
    FileUtils.rm_rf working_target 
    FileUtils.mkdir_p working_target
  end
    # result = `rm -rf #{working_target}`
    # puts result
  Pipeline.debug "Cloning into: #{working_target}"
  result = `git clone -q #{target} #{working_target}`
  # puts result
  #end
  return working_target
end