Sha256: 2d5535ad4ec2c0d73c830dcfe808c989bd3d484544ccb919f7714dd7a90522a0
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
# Polisher Git Repo Representation # # Licensed under the MIT license # Copyright (C) 2013-2014 Red Hat, Inc. require 'awesome_spawn' require 'polisher/core' require 'polisher/git_cache' module Polisher module Git # Git Repository class Repo extend ConfHelpers # TODO use ruby git api conf_attr :git_cmd, '/usr/bin/git' attr_accessor :url def initialize(args={}) @url = args[:url] end def path GitCache.path_for(@url) end # Clobber the git repo def clobber! FileUtils.rm_rf path end def clone AwesomeSpawn.run "#{git_cmd} clone #{url} #{path}" end def cloned? File.directory?(path) end def in_repo Dir.chdir path do yield end end def file_paths in_repo { Dir['**/*'] } end # Note be careful when invoking: def reset! in_repo { AwesomeSpawn.run "#{git_cmd} reset HEAD~ --hard" } self end def pull in_repo { AwesomeSpawn.run "#{git_cmd} pull" } self end def checkout(tgt) in_repo { AwesomeSpawn.run "#{git_cmd} checkout #{tgt}" } self end def commit(msg) in_repo { AwesomeSpawn.run "#{git_cmd} commit -m '#{msg}'" } self end end # class Repo end # module Git end # module Polisher
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
polisher-0.9.1 | lib/polisher/git/repo.rb |
polisher-0.8.1 | lib/polisher/git/repo.rb |