Class: StashCloneTool::StashCloner

Inherits:
Object
  • Object
show all
Includes:
StashCloneTool
Defined in:
lib/stash_clone_tool/stash_cloner.rb

Constant Summary

Constants included from StashCloneTool

VERSION

Instance Method Summary collapse

Constructor Details

#initialize(stash_url, username, password, directory) ⇒ StashCloner

Returns a new instance of StashCloner.



13
14
15
16
# File 'lib/stash_clone_tool/stash_cloner.rb', line 13

def initialize(stash_url, username, password, directory)
  @stash = StashApiClient.new(stash_url, username, password)
  @directory = directory
end

Instance Method Details

#clone_stash(clone_options) {|wrapper| ... } ⇒ Object

Yields:

  • (wrapper)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/stash_clone_tool/stash_cloner.rb', line 18

def clone_stash(clone_options)
  wrapper = Multiblock.wrapper
  yield(wrapper)
  @stash.projects.each do |project|
    project.repositories.each do |repository|
      folder = File.join(@directory, project.key, repository.slug)
      wrapper.call(:initialize_repository, repository, folder)
      clone_link = repository.clone_link(:ssh)
      if Dir.exists?(folder)
        wrapper.call(:failure, repository, 'Target already exists')
      else
        Git.clone(clone_link, folder, clone_options)
        wrapper.call(:success, repository)
      end
    end
  end
end