 path = require 'path'
 async = require 'async'
 minimatch = require 'minimatch'
+spinner = require 'char-spinner'
 
 config = require './config'
 cache = require './cache'

# Fetch and return a list of all references in the repo
getUpToDateRefs = (repo, callback) ->
  logger.debug "Fetching updates"
  repo.fetchAll getOpts().fetchOpts
    .then ->
      logger.debug "Fetched successfully"
      return repo.getReferences(nodegit.Reference.TYPE.LISTALL)
    .then (reflist) ->


cloneRepo = (repoUrl, targetDir, callback) ->
  logger.info "Cloning from #{repoUrl}"
  interval = spinner()
  opts = getOpts()
  nodegit.Clone.clone repoUrl, targetDir, opts
    .then (repo) ->
      logger.debug 'Cloned successfully'
      clearInterval interval
      callback null, repo
    .catch (err) ->
      logger.error "Operation failed (#{err})"
