Compare commits
2 Commits
0.7.0
...
deploy_old
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8013426a7 | ||
|
|
e84f6a359d |
@@ -1,8 +1,9 @@
|
||||
module Capistrano
|
||||
module DeployTags
|
||||
def pending_git_changes?
|
||||
# Do we have any changes vs HEAD on deployment branch?
|
||||
!(`git fetch && git diff #{branch} --shortstat`.strip.empty?)
|
||||
|
||||
def uncommitted_git_changes?
|
||||
# Is the working directory clean?
|
||||
!( `git status --porcelain`.strip.empty? )
|
||||
end
|
||||
|
||||
def git_tag_for(stage)
|
||||
@@ -40,15 +41,26 @@ module Capistrano
|
||||
task :prepare_tree, :except => { :no_release => true } do
|
||||
cdt.validate_git_vars
|
||||
|
||||
logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'"
|
||||
|
||||
if cdt.pending_git_changes?
|
||||
logger.log Capistrano::Logger::IMPORTANT, "Whoa there, partner. Dirty trees can't deploy. Git yerself clean first."
|
||||
raise 'Dirty git tree'
|
||||
if cdt.uncommitted_git_changes?
|
||||
logger.log Capistrano::Logger::IMPORTANT, "Sorry, you have uncommitted changes. Please commit or stash them."
|
||||
end
|
||||
|
||||
cdt.safe_run "git", "checkout", branch
|
||||
cdt.safe_run "git", "pull", "origin", branch if cdt.has_remote?
|
||||
cdt.safe_run "git", "fetch"
|
||||
|
||||
ref = fetch(:revision, branch)
|
||||
|
||||
if exists?(:revision)
|
||||
logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy '#{ref}' to '#{stage}'"
|
||||
else
|
||||
logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from '#{ref}' to '#{stage}'"
|
||||
end
|
||||
|
||||
cdt.safe_run "git", "checkout", ref
|
||||
|
||||
# It doesn't make sense to pull a SHA, only a branch.
|
||||
if cdt.has_remote? && ! exists?(:revision)
|
||||
cdt.safe_run "git", "pull", "origin", ref
|
||||
end
|
||||
end
|
||||
|
||||
desc 'add git tags for each successful deployment'
|
||||
|
||||
Reference in New Issue
Block a user