Skip to content

Commit

Permalink
"deploy:setup": cleanup run_method and group_writeable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 15, 2009
1 parent 0356936 commit 738532b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/git_deploy.rb
Expand Up @@ -33,10 +33,10 @@ def try_sudo(*args)
raise ArgumentError, "too many arguments" if args.any?

as = options.fetch(:as, fetch(:admin_runner, nil))
via = fetch(:run_method, :sudo)

if command
invoke_command(command, :via => via, :as => as)
elsif via == :sudo
invoke_command(command, :via => run_method, :as => as)
elsif :sudo == run_method
sudo(:as => as)
else
""
Expand Down Expand Up @@ -64,16 +64,18 @@ def try_sudo(*args)

desc "Prepares servers for deployment."
task :setup do
shared = fetch(:group_writeable)

command = ["#{try_sudo} mkdir -p #{deploy_to}"]
command << "#{try_sudo} chown $USER #{deploy_to}" if fetch(:run_method, :sudo) == :sudo
command << "#{try_sudo} chown $USER #{deploy_to}" if :sudo == run_method
command << "cd #{deploy_to}"
command << "chmod g+w ."
command << "git init #{fetch(:group_writeable) ? '--shared' : ''}"
command << "chmod g+w ." if shared
command << "git init #{shared ? '--shared' : ''}"
command << "sed -i'' -e 's/master/#{branch}/' .git/HEAD" unless branch == 'master'
command << "git config --bool receive.denyNonFastForwards false" if fetch(:group_writeable)
command << "git config --bool receive.denyNonFastForwards false" if shared
command << "git config receive.denyCurrentBranch ignore"
run command.join(' && ')

install_hooks
push
end
Expand Down

0 comments on commit 738532b

Please sign in to comment.