capistrano-confirm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +10 -1
- data/capistrano-confirm.gemspec +7 -2
- data/lib/capistrano-confirm/version.rb +1 -1
- data/lib/capistrano-confirm.rb +15 -13
- metadata +4 -4
data/README
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
Confirm before deploy.
|
4
4
|
|
5
|
-
Make sure you are not deploying the wrong branch,
|
5
|
+
Make sure you are not deploying the wrong branch, and remind you should deploy it after code review!
|
6
|
+
|
7
|
+
Please use it, because I write it after deployed a wrong branch to our production server! ;(
|
6
8
|
|
7
9
|
== Usage:
|
8
10
|
|
@@ -15,6 +17,13 @@
|
|
15
17
|
require "bundler/setup"
|
16
18
|
require 'capistrano-confirm'
|
17
19
|
|
20
|
+
3, Only want to confirm for some stages? customize `confirm_stages` as your like.
|
21
|
+
|
22
|
+
For example, only want to confirm when deploying production, Add below to your deploy.rb
|
23
|
+
set :confirm_stages, "production"
|
24
|
+
|
25
|
+
Or confirm when deploying staging and production? Ok, Add something like this
|
26
|
+
set :confirm_stages, [:production, :staging]
|
18
27
|
|
19
28
|
== Author
|
20
29
|
Jinzhu Zhang
|
data/capistrano-confirm.gemspec
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "capistrano-confirm/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = "capistrano-confirm"
|
5
|
-
s.version =
|
7
|
+
s.version = Capistrano::Confirm::VERSION
|
6
8
|
s.authors = ["Jinzhu"]
|
7
9
|
s.email = ["wosmvp@gmail.com"]
|
8
10
|
s.homepage = "https://github.com/jinzhu/capistrano-confirm"
|
9
11
|
s.summary = %q{Confirm before deploy}
|
10
|
-
s.description = %q{Confirm before deploy
|
12
|
+
s.description = %q{Confirm before deploy,
|
13
|
+
Make sure you are not deploying the wrong branch, and remind you should deploy it after code review!
|
14
|
+
Please use it, because I write it after deployed a wrong branch to our production server! ;(
|
15
|
+
}
|
11
16
|
|
12
17
|
s.rubyforge_project = "capistrano-confirm"
|
13
18
|
|
data/lib/capistrano-confirm.rb
CHANGED
@@ -5,30 +5,32 @@ end
|
|
5
5
|
Capistrano::Configuration.instance.load do
|
6
6
|
namespace :deploy do
|
7
7
|
task :confirm do
|
8
|
-
|
8
|
+
if (Array[confirm_stages].flatten.map(&:to_s).include?(stage.to_s) rescue true)
|
9
|
+
first_num, sencond_num = rand(10), rand(10)
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
result = first_num + sencond_num
|
12
|
+
stage_info = " #{colorful(stage)}" rescue ''
|
13
|
+
branch_info = " with branch #{colorful(branch)}" rescue ''
|
13
14
|
|
14
|
-
|
15
|
+
Capistrano::CLI.ui.say %Q(
|
15
16
|
#{colorful("="*80, 33)}
|
16
17
|
|
17
18
|
You are deploying#{stage_info}#{branch_info}, Are you sure?
|
18
19
|
Please make sure you did #{colorful("code review")}, and are not deploying the #{colorful("wrong branch")},
|
19
|
-
Answer the
|
20
|
+
Answer the below question to make sure you are not drunk!
|
20
21
|
#{first_num} + #{sencond_num} = ?
|
21
22
|
|
22
23
|
#{colorful("="*80, 33)}
|
23
24
|
)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
answer = Capistrano::CLI.ui.ask("Your answer here (answer `NO` to stop the deploy):").strip
|
27
|
+
if (answer =~ /^\s*\d+\s*$/) && (answer.to_i == result)
|
28
|
+
Capistrano::CLI.ui.say colorful("Deploying#{"."*71}", 33)
|
29
|
+
else
|
30
|
+
Capistrano::CLI.ui.say colorful("Stoping#{"."*73}", 33)
|
31
|
+
Capistrano::CLI.ui.say colorful("Difficult question for you? Your math must be taught by National Bureau of Statistics!") if (answer =~ /^\s*\d+\s*$/)
|
32
|
+
abort
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-confirm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jinzhu
|
@@ -19,7 +19,7 @@ date: 2011-12-15 00:00:00 +08:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Confirm before deploy
|
22
|
+
description: "Confirm before deploy,\n Make sure you are not deploying the wrong branch, and remind you should deploy it after code review!\n Please use it, because I write it after deployed a wrong branch to our production server! ;(\n "
|
23
23
|
email:
|
24
24
|
- wosmvp@gmail.com
|
25
25
|
executables: []
|