class Polisher::Git::Repo
Git
Repository
Attributes
path[RW]
url[RW]
Public Class Methods
new(args = {})
click to toggle source
# File lib/polisher/git/repo.rb, line 22 def initialize(args = {}) @url = args[:url] @path = args[:path] end
Public Instance Methods
checkout(tgt)
click to toggle source
# File lib/polisher/git/repo.rb, line 75 def checkout(tgt) require_dep! 'awesome_spawn' require_cmd! git_cmd in_repo { AwesomeSpawn.run! "#{git_cmd} checkout #{tgt}" } self end
clobber!()
click to toggle source
Clobber the git repo
# File lib/polisher/git/repo.rb, line 32 def clobber! FileUtils.rm_rf path end
clone()
click to toggle source
# File lib/polisher/git/repo.rb, line 36 def clone require_dep! 'awesome_spawn' require_cmd! git_cmd AwesomeSpawn.run! "#{git_cmd} clone #{url} #{path}" end
cloned?()
click to toggle source
# File lib/polisher/git/repo.rb, line 42 def cloned? File.directory?(path) end
commit(msg)
click to toggle source
# File lib/polisher/git/repo.rb, line 82 def commit(msg) require_dep! 'awesome_spawn' require_cmd! git_cmd in_repo { AwesomeSpawn.run! "#{git_cmd} commit -m '#{msg}'" } self end
file_paths()
click to toggle source
# File lib/polisher/git/repo.rb, line 52 def file_paths in_repo { Dir['**/*'] } end
in_repo() { || ... }
click to toggle source
# File lib/polisher/git/repo.rb, line 46 def in_repo Dir.chdir path do yield end end
include?(file)
click to toggle source
# File lib/polisher/git/repo.rb, line 56 def include?(file) file_paths.include?(file) end
pull()
click to toggle source
# File lib/polisher/git/repo.rb, line 68 def pull require_dep! 'awesome_spawn' require_cmd! git_cmd in_repo { AwesomeSpawn.run! "#{git_cmd} pull" } self end
reset!()
click to toggle source
Note be careful when invoking:
# File lib/polisher/git/repo.rb, line 61 def reset! require_dep! 'awesome_spawn' require_cmd! git_cmd in_repo { AwesomeSpawn.run! "#{git_cmd} reset HEAD~ --hard" } self end