Skip to content

Commit

Permalink
don't deploy when you don't need to
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Wolfe committed Nov 21, 2008
1 parent f6b0dde commit ba5f6f6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pushr.rb
Expand Up @@ -45,6 +45,14 @@ def in_repo(action)
`cd #{repo} && #{action}`
end

def git_version
in_repo "git rev-list HEAD --max-count=1"
end

def live_version
in_path "git rev-list HEAD --max-count=1"
end

def deploy!
# TODO : Refactor logging/notifying into Observers, obviously!
CONFIG['cap']['action'] or raise "cap.action is a required setting"
Expand All @@ -62,13 +70,13 @@ def deploy!

log.info(application) { "Checking versions..." }

git_version = in_repo "git rev-list HEAD --max-count=1"
live_version = in_path "git rev-list HEAD --max-count=1"

if(git_version == live_version)
#TODO: allow force option to re-deploy same version
log.fatal(application){ 'No updates found' }
raise "No upgrade required."
end
log.info("let's update from #{live_version} to #{git_version}")

historical = in_repo('git rev-list HEAD').split.grep live_version
if not historical
Expand Down Expand Up @@ -101,7 +109,7 @@ def deploy!
private

def repository_info
sep = ' ;;;; '
sep = ' ;;;;; '
info = in_path " git log --pretty='format:%h#{sep}%s#{sep}%an#{sep}%ar#{sep}%ci' -n 1 "
Struct::Repository.new( *info.split(/#{sep}/) )
end
Expand All @@ -122,12 +130,15 @@ def repository_info
end

error do
'Sorry there was a nasty error - ' + request.env['sinatra.error'].inspect
request.env['sinatra.error'].to_s
end

# == Get info
get '/' do
@pushr = Pushr.new(CONFIG['path'])
@git_version = @pushr.git_version
@live_version = @pushr.live_version

haml :info
end

Expand Down Expand Up @@ -175,6 +186,8 @@ def repository_info
= @pushr.repository.when
by
= @pushr.repository.author
%p
= @git_version + " => " + @live_version
%p
%form{ :action => "/", :method => 'post', :onsubmit => "this.submit.disabled='true'" }
%input{ 'type' => 'hidden', 'name' => 'token', 'value' => CONFIG['token'] }
Expand Down

0 comments on commit ba5f6f6

Please sign in to comment.