Sha256: 1255262b6f3272ae9c3461f2a7be82e7851a49432effd8c3becc72731675fbd1
Contents?: true
Size: 1.57 KB
Versions: 10
Compression:
Stored size: 1.57 KB
Contents
#!/usr/bin/env ruby require 'fileutils' require 'open-uri' # this hook is only called once until the template directory is cloned # once the template directory is cloned the clone hook from the template directory # will be run instead of this file. This is on purpose in order to allow the user # to easily customize the hook. @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.exist? File.join(template_dir, '.git', 'config') end def origin_exists?(template_dir) `git --git-dir #{template_dir}/.git --work-tree #{template_dir} remote show origin` $CHILD_STATUS.success? end def update_templates(git_url, dest, branch = 'master') create_repo(dest, git_url, branch) puts "Attempting to connect to #{@template_repo}" puts `git --git-dir #{dest}/.git --work-tree #{dest} pull` dest end def connected?(url) unless ENV['CLONE_RETROSPEC_TEMPLATES'].nil? # if the user wants internet but doesn't want cloning, allow them to set this variable return false end true end # sometimes I work on an airplane and don't care to clone everything all the time # so lets check for connectivity first update_templates(@template_repo, @template_dir, @template_branch) if connected?(@template_repo)
Version data entries
10 entries across 10 versions & 1 rubygems