Class: EY::Serverside::Source::Git

Inherits:
EY::Serverside::Source show all
Defined in:
lib/engineyard-serverside/source/git.rb

Overview

Deploy source for git repository sourced deploy.

Instance Attribute Summary

Attributes inherited from EY::Serverside::Source

#opts, #ref, #shell, #source_cache, #uri

Instance Method Summary collapse

Methods inherited from EY::Serverside::Source

#initialize, require_opts

Constructor Details

This class inherits a constructor from EY::Serverside::Source

Instance Method Details

#create_revision_file_command(revision_file_path) ⇒ Object


7
8
9
# File 'lib/engineyard-serverside/source/git.rb', line 7

def create_revision_file_command(revision_file_path)
  %Q{#{git} show --pretty=format:"%H" | head -1 > "#{revision_file_path}"}
end

#gc_repository_cacheObject


11
12
13
14
# File 'lib/engineyard-serverside/source/git.rb', line 11

def gc_repository_cache
  shell.status "Garbage collecting cached git repository to reduce disk usage."
  run("#{git} gc")
end

#same?(previous_revision, active_revision, paths = nil) ⇒ Boolean

Check if there have been changes. git diff –exit-code returns

  • 0 when nothing has changed

  • 1 when there are changes

previous_revision - The previous ref string. active_revision - The current ref string.

Returns a boolean whether there has been a change.

Returns:

  • (Boolean)

26
27
28
# File 'lib/engineyard-serverside/source/git.rb', line 26

def same?(previous_revision, active_revision, paths=nil)
  run_and_success?("#{git} diff '#{previous_revision}'..'#{active_revision}' --exit-code --name-only -- #{Array(paths).join(' ')} >/dev/null 2>&1")
end

#short_log_message(revision) ⇒ Object

Get most recent commit message for revision.


31
32
33
# File 'lib/engineyard-serverside/source/git.rb', line 31

def short_log_message(revision)
  run_and_output("#{git} log --pretty=oneline --abbrev-commit -n 1 '#{revision}'").strip
end

#update_repository_cacheObject


35
36
37
38
39
40
# File 'lib/engineyard-serverside/source/git.rb', line 35

def update_repository_cache
  unless fetch && checkout
    shell.fatal "git checkout #{to_checkout} failed."
    raise "git checkout #{to_checkout} failed."
  end
end