Sha256: ec1d61b4c2790ba25311dc39a735e93146a087d973f73659b08c0bd6c818b385

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
require 'fileutils'
require 'open-uri'

@template_dir    = ARGV[0] || File.join(ENV['HOME'], '.retrospec_templates')
@template_repo   = ARGV[1] || 'https://github.com/nwops/retrospec-templates'
@template_branch = ARGV[2] || 'master'

def create_repo(template_dir, git_url, branch)
  # check if repo already exists
  unless git_exists?(template_dir)
    puts `git clone -b #{branch} #{git_url} #{template_dir}`
  end
end

def git_exists?(template_dir)
  File.exists? File.join(template_dir,'.git','config')
end

def origin_exists?(template_dir)
  `git -C #{template_dir} remote show origin`
  $?.success?
end

def update_templates(git_url, dest, branch='master')
  create_repo(dest, git_url, branch)
  puts `git -C #{dest} pull`
  dest
end

def connected?
  open("http://www.google.com/") rescue false
end

# sometimes I work on an airplane and don't care to clone everything all the time
# so lets check for connectivity first
if connected?
  update_templates(@template_repo, @template_dir, @template_branch)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-retrospec-0.8.1 lib/retrospec/templates/clone-hook
puppet-retrospec-0.8.0 lib/retrospec/templates/clone-hook