capistrano_confirm_branch 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Jordan Byron
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Capistrano Confirm Branch
2
+
3
+ Requires confirmation before switching deployed branches using capistrano.
4
+
5
+ ![Confirm Deploy](http://i.imgur.com/7IdUY.png)
6
+
7
+ ## Usage
8
+
9
+ Install the gem using rubygems:
10
+
11
+ ```bash
12
+ $ gem install capistrano_confirm_branch
13
+ ```
14
+
15
+ or add it to your Gemfile and run `bundle install`
16
+
17
+ ```ruby
18
+ gem 'capistrano_confirm_branch'
19
+ ```
20
+
21
+ Then in your `Capfile` add `require 'capistrano/confirm_branch'` and you will be
22
+ asked to confirm changing branches before each deploy.
23
+
24
+ ## Bonus
25
+
26
+ To deploy from the current working branch, use this in your capistrano recipe:
27
+
28
+ ```ruby
29
+ set :branch, $1 if `git branch` =~ /\* (\S+)\s/m
30
+ ```
31
+
32
+ ## License
33
+
34
+ Copyright (c) 2012 Jordan Byron
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Capistrano Confirm Branch'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.md')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,37 @@
1
+ require 'capistrano'
2
+
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ before "deploy:update_code", "deploy:confirm_branch"
5
+ after "deploy", "deploy:update_current_branch"
6
+
7
+ namespace :deploy do
8
+ desc 'Confirms deployment when switching deployed branches'
9
+ task :confirm_branch do
10
+ deployed_branch = nil
11
+ pending_deploy_branch = fetch(:branch)
12
+
13
+ run %{cat #{shared_path}/current_branch} do |ch, stream, out|
14
+ deployed_branch = out.strip
15
+ end
16
+
17
+ if deployed_branch != pending_deploy_branch
18
+ Capistrano::CLI.ui.say %{
19
+ ============ Changing deployed branches ============
20
+ Deployed Branch: #{deployed_branch}
21
+ Pending Deploy Branch: #{pending_deploy_branch}
22
+ ====================================================
23
+
24
+ }
25
+
26
+ abort unless Capistrano::CLI.ui.agree(
27
+ "Do you wish to continue deploying #{pending_deploy_branch}?"
28
+ )
29
+ end
30
+ end
31
+
32
+ desc 'Updates the file which tracks the currently deployed branch'
33
+ task :update_current_branch do
34
+ run %{echo "#{fetch(:branch)}" > #{shared_path}/current_branch}
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module ConfirmBranch
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano_confirm_branch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jordan Byron
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Requires confirmation before switching deployed branches
31
+ email:
32
+ - jordan.byron@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/capistrano/confirm_branch/version.rb
38
+ - lib/capistrano/confirm_branch.rb
39
+ - Rakefile
40
+ - README.md
41
+ - LICENSE
42
+ homepage: https://github.com/elm-city-craftworks/capistrano_confirm_branch
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ segments:
55
+ - 0
56
+ hash: -2784818728531638516
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ segments:
64
+ - 0
65
+ hash: -2784818728531638516
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Requires confirmation before switching deployed branches
72
+ test_files: []