Class: EY::Serverside::Source::Git
- Inherits:
-
EY::Serverside::Source
- Object
- EY::Serverside::Source
- EY::Serverside::Source::Git
- 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
- #create_revision_file_command(revision_file_path) ⇒ Object
- #gc_repository_cache ⇒ Object
-
#same?(previous_revision, active_revision, paths = nil) ⇒ Boolean
Check if there have been changes.
-
#short_log_message(revision) ⇒ Object
Get most recent commit message for revision.
- #update_repository_cache ⇒ Object
Methods inherited from EY::Serverside::Source
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_cache ⇒ Object
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.
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 (revision) run_and_output("#{git} log --pretty=oneline --abbrev-commit -n 1 '#{revision}'").strip end |
#update_repository_cache ⇒ Object
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 |