Skip to content

Commit

Permalink
simplify CLI workflow (fixes #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
effkay committed Oct 25, 2011
1 parent a594f0c commit cc4d6b3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 43 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Not everyone can or wants to deploy on heroku. But now you can have the same awe

## Quickstart

`blazing init`, edit the configuration, run `blazing setup:local` and `blazing setup:remote <target>` and you're set. Deploy with `git push <target> <branch>` or setup git to always push your current branch.
`blazing init`, edit the configuration, run `blazing setup [target]` and you're set. Deploy with `git push <target> <branch>` or setup git to always push your current branch.

## Overview & Background

Expand Down Expand Up @@ -49,17 +49,13 @@ See the generated configuration file or [the template file](https://github.com/e

### Setup

`blazing setup:local` will setup your local repository for deployment with blazing/git push. Basically, it will add a remote for each target you defined in the configuration file.

`blazing setup:remote <target>` will setup the project on the server side. It will:
`blazing setup` will:

* setup your local repository for deployment with blazing/git push. Basically, it will add a remote for each target you defined in the configuration file.
* clone the repository to the specified location
* setup the repository to allow a currently checked out branch to be pushed to it
* run ``blazing update``

`blazing update <target>`

Whenever you change something in your blazing config file you can run the update command so your git post-receive hook gets updated.
Whenever you change something in your blazing config file you can run the `update` command so your git post-receive hook and your git remotess get updated.

### Deploying

Expand Down
8 changes: 5 additions & 3 deletions lib/blazing/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ def init_command
end
end

def setup_local_command
def setup_git_remotes
repository = Grit::Repo.new(Dir.pwd)
@config.targets.each do |target|
info("Adding new remote #{target.name} pointing to #{target.location}")
repository.config["remote.#{target.name}.url"] = target.location
end
end

def setup_remote_command
def setup_command
@target.setup
update_command
end

def update_command
@target.update
setup_git_remotes
@target.apply_hook
end

def recipes_run_command
Expand Down
3 changes: 1 addition & 2 deletions lib/blazing/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def initialize(name, location, config, options = {})

def setup
@shell.run "ssh #{user}@#{host} '#{clone_repository} && #{setup_repository}'"
self.update
end

def update
def apply_hook
hook = ERB.new(File.read("#{Blazing::TEMPLATE_ROOT}/hook.erb")).result(binding)

File.open(Blazing::TMP_HOOK, "wb") do |f|
Expand Down
27 changes: 0 additions & 27 deletions spec/blazing/integration/setup_local_spec.rb

This file was deleted.

6 changes: 3 additions & 3 deletions spec/blazing/integration/setup_remote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'blazing/runner'
require 'grit'

describe 'blazing setup:remote' do
describe 'blazing setup' do

before :each do
setup_sandbox
Expand All @@ -25,8 +25,8 @@
@target = @config.default_target
@target.instance_variable_set('@shell', @shell)
@shell.should_receive(:run).with("ssh user@host 'git clone /some/where/else && cd /some/where/else && git config receive.denyCurrentBranch ignore'")
@target.should_receive(:update)
capture(:stdout) { @runner.exec('setup:remote') }
@target.should_receive(:apply_hook)
capture(:stdout) { @runner.exec('setup') }
end

end
5 changes: 5 additions & 0 deletions spec/blazing/integration/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@
capture(:stdout) { @runner.exec('update') }
end

it 'adds a git remote for each target' do
capture(:stdout) { @runner.exec('update') }
Grit::Repo.new(Dir.pwd).config['remote.production.url'].should == @production_url
end

end

0 comments on commit cc4d6b3

Please sign in to comment.