lib/cerberus/scm/git.rb in cerberus-0.6 vs lib/cerberus/scm/git.rb in cerberus-0.7

- old
+ new

@@ -1,28 +1,24 @@ require 'cerberus/utils' +require 'cerberus/scm/base' -class Cerberus::SCM::Git - def initialize(path, config = {}) - raise "Path can't be nil" unless path - - @path, @config = path.strip, config - @encoded_path = (@path.include?(' ') ? "\"#{@path}\"" : @path) - end - +class Cerberus::SCM::Git < Cerberus::SCM::Base + def installed? exec_successful? "#{@config[:bin_path]}git --version" end def update! - if test(?d, @path + '/.git') + if test( ?d, File.join( @path,'.git' ) ) get_updates execute("reset", "--hard #{remote_head}") else FileUtils.rm_rf(@path) if test(?d, @path) encoded_url = (@config[:scm, :url].include?(' ') ? "\"#{@config[:scm, :url]}\"" : @config[:scm, :url]) @new = true @status = execute("clone", "#{encoded_url} #{@path}", false) + execute('config', 'pager.diff false') # turn off git-diff $PAGER by default if branch = @config[:scm, :branch] execute('branch', "--track #{branch} #{remote_head}") execute('checkout', branch) end end @@ -39,14 +35,10 @@ def current_revision( _full=false ) _full ? @revision : @revision.slice(0,8) end - def url - @path - end - def last_commit_message @message end def last_author @@ -78,10 +70,10 @@ `#{cmd}` end def extract_commit_info( commit=remote_head ) message = execute("show", "#{ commit } --pretty='format:%an(%ae)|%ai|%H|%s'").split("|") - { :author => message[0], :date => message[1], :revision => message[2], :message => message[3] } + return { :author => message[0], :date => message[1], :revision => message[2], :message => message[3] } end def last_tested_revision # TODO Is there a better way to extract the last tested commit? app_name = @config['application_name']