Sha256: 4f621af39870913c64fcbd2dfdc9cbf3720273be2ae538d7c01109d73a2ee21b
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
#!/usr/bin/env ruby unless File.respond_to? :realpath class File #:nodoc: def self.realpath path return realpath(File.readlink(path)) if symlink?(path) path end end end $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib') require 'hatchet' require 'thor' require 'threaded' class HatchetCLI < Thor desc "install", "installs repos defined in 'hatchet.json'" def install warn_dot_ignore! puts "Installing repos for hatchet" dirs.map do |directory, git_repo| Threaded.later do directory = File.expand_path(directory) if Dir[directory].present? puts "== pulling '#{git_repo}' into '#{directory}'\n" pull(directory, git_repo) else puts "== cloning '#{git_repo}' into '#{directory}'\n" clone(directory, git_repo) end end end.map(&:join) end desc "list", "lists all repos and their destination listed in hatchet.json" def list repos.each do |repo, directory| puts "#{repo}: #{directory}" end end private def warn_dot_ignore! return false unless File.exist?('.gitignore') gitignore = File.open('.gitignore').read repo_path = config.repo_directory_path.gsub(/^\.\//, '') # remove ./ from front of dir return if gitignore.include?(repo_path) puts "WARNING: add #{File.join(repo_path, '*')} to your .gitignore file \n\n" end def config @config ||= Hatchet::Config.new end def repos config.repos end def dirs config.dirs end def pull(path, git_repo) puts `cd #{path} && git pull --rebase #{git_repo} master --quiet` end def clone(path, git_repo) path = File.join(path, '..') # up one dir to prevent repos/codetriage/codetriage/#... FileUtils.mkdir_p(path) puts `cd #{path} && git clone #{git_repo} --quiet` end end HatchetCLI.start(ARGV)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
heroku_hatchet-1.3.4 | bin/hatchet |
heroku_hatchet-1.3.3 | bin/hatchet |
heroku_hatchet-1.3.2 | bin/hatchet |