capistrano-hivequeen 3.0.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,10 @@ class HiveQueen
42
42
  @roles[env_id] ||= get("/#{env_id}.json")
43
43
  end
44
44
 
45
+ def commit_status(commit_sha)
46
+ get("/projects/#{project}/commit_statuses/#{commit_sha}.json")
47
+ end
48
+
45
49
  def start_deployment(environment_id, params)
46
50
  required_params = [:task, :commit]
47
51
  required_params.each do |key|
@@ -10,6 +10,7 @@ Capistrano::Configuration.instance.load do
10
10
  end
11
11
 
12
12
  before "deploy:update_code", "hivequeen:start"
13
+ before 'hivequeen:start', 'hivequeen:check_commit'
13
14
  on :start, "hivequeen:require_environment", :except => HiveQueen.environment_names
14
15
  namespace :hivequeen do
15
16
 
@@ -45,6 +46,51 @@ Capistrano::Configuration.instance.load do
45
46
  abort "Cannot start deployment. Errors: #{$!.message}"
46
47
  end
47
48
  end
49
+
50
+ desc "[internal] Prompt if deploying the currently running commit, or if tests haven't passed"
51
+ task :check_commit do
52
+ if environment.to_s == 'production'
53
+ if current_commit == real_revision
54
+ banner = %q{
55
+ ______ _ _ _ ___
56
+ | ____| | | | | | | |__ \
57
+ | |__ ___ _ __ __ _ ___| |_ | |_ ___ _ __ _ _ ___| |__ ) |
58
+ | __/ _ \| '__/ _` |/ _ \ __| | __/ _ \ | '_ \| | | / __| '_ \ / /
59
+ | | | (_) | | | (_| | __/ |_ | || (_) | | |_) | |_| \__ \ | | |_|
60
+ |_| \___/|_| \__, |\___|\__| \__\___/ | .__/ \__,_|___/_| |_(_)
61
+ __/ | | |
62
+ |___/ |_|
63
+ }
64
+ puts banner
65
+ puts "\n\nCommit #{current_commit} is currently deployed\n"
66
+ Capistrano::CLI.ui.ask("Did you forget to push a new commit? Press enter to continue deploying, or ctrl+c to abort")
67
+ end
68
+
69
+ banner = %q{
70
+ _______ _ _ _ _ _ _ _
71
+ |__ __| | | | (_) | | ( ) | | |
72
+ | | ___ ___| |_ ___ __| |_ __| |_ __ |/| |_ _ __ __ _ ___ ___| |
73
+ | |/ _ \/ __| __/ __| / _` | |/ _` | '_ \ | __| | '_ \ / _` / __/ __| |
74
+ | | __/\__ \ |_\__ \ | (_| | | (_| | | | | | |_ | |_) | (_| \__ \__ \_|
75
+ |_|\___||___/\__|___/ \__,_|_|\__,_|_| |_| \__| | .__/ \__,_|___/___(_)
76
+ | |
77
+ |_|
78
+ }
79
+ puts "Checking commit status for #{real_revision}"
80
+ status = HiveQueen.commit_status(real_revision)
81
+ unless status && status['state'] == "success"
82
+ puts banner
83
+
84
+ message = "Commit status is %s." % (status['state'] || 'unknown')
85
+ if status['target_url']
86
+ message << " See #{status['target_url']}"
87
+ end
88
+ puts "\n\n#{message}\n"
89
+
90
+ Capistrano::CLI.ui.ask("Are you sure you want to deploy when tests haven't passed? Press enter to continue deploying, or ctrl+c to abort")
91
+ end
92
+ end
93
+ end
48
94
  end
49
95
 
50
96
  # Keep all but the 5 most recent releases
@@ -1,6 +1,6 @@
1
1
  class HiveQueen
2
2
  class Version
3
- @@version = '3.0.2'
3
+ @@version = '4.0.0'
4
4
 
5
5
  def self.to_s
6
6
  @@version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-hivequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-03 00:00:00.000000000 Z
12
+ date: 2013-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano