Sha256: 8f390b3645d65ec9a0fcd4b55de88020ee86e9ee1b625b703cc69311208828a6
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
#!/usr/bin/env ruby require 'fileutils' require 'open-uri' @template_dir = ARGV[0] || File.join(ENV['HOME'], '.retrospec','repos','retrospec-puppet-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
4 entries across 4 versions & 1 rubygems