Class: Cerberus::SCM::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/cerberus/scm/git.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #url

Constructor Details

This class inherits a constructor from Cerberus::SCM::Base

Instance Method Details

#current_revision(_full = false) ⇒ Object



36
37
38
# File 'lib/cerberus/scm/git.rb', line 36

def current_revision( _full=false )
  _full ? @revision : @revision.slice(0,8)
end

#has_changes?Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/cerberus/scm/git.rb', line 27

def has_changes?
  extract_current_head_revision
  new? or ( last_tested_revision != @revision )
end

#installed?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/cerberus/scm/git.rb', line 6

def installed?
  exec_successful? "#{@config[:bin_path]}git --version"
end

#last_authorObject



44
45
46
# File 'lib/cerberus/scm/git.rb', line 44

def last_author
  @author
end

#last_commit_messageObject



40
41
42
# File 'lib/cerberus/scm/git.rb', line 40

def last_commit_message
  @message
end

#new?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/cerberus/scm/git.rb', line 32

def new?
  @new == true
end

#outputObject



48
49
50
# File 'lib/cerberus/scm/git.rb', line 48

def output
  @status
end

#update!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cerberus/scm/git.rb', line 10

def update!
  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
end