capistrano_confirm_branch 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 483621ae853ee0cfe7c9aef6296437ed65407cf0
4
- data.tar.gz: 3db9b3bf22a1f8148d25ebacc665384e8ce2be41
3
+ metadata.gz: b9e330c8b3781e1e8a677922001c12649837a725
4
+ data.tar.gz: 68db5b09834f02d611a5680f5323418566004bd8
5
5
  SHA512:
6
- metadata.gz: c3534b1587c6e3c965f15d5a287dea4f474d3d952b2210b6419b6afe509ac1bdc4825b57f3e413405e45f605b15b89cd1c1086a77a23d8afaa4abdfb8fd61778
7
- data.tar.gz: f2e39f079d64a87c754ee927ccd73d8beecf163eed4d572426ce7e2dd016f535246f020a195e665709b599a5dc55ed187f1b965c24374697a981c2c49c3ca661
6
+ metadata.gz: 3623841547fb4deefb308af4b7f982e3329fccff44f2a86638d5d47ae88d5825d56a6a6a71b82789310d0d93eebdffc41655c91e42b71074a77d4718f743eb9d
7
+ data.tar.gz: f524cda189d04173e931fa4bfe7855a0b313059fee8a31007a6723d6e3d6d7b544424b5462a8fa5b684703eb481026f28dc040514188a55ba0816d8810204474
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/capistrano_confirm_branch.png)](http://badge.fury.io/rb/capistrano_confirm_branch)
3
3
 
4
4
 
5
- Requires confirmation before switching deployed branches using capistrano.
5
+ Requires confirmation before switching deployed branches using capistrano and
6
+ warns when deploying with unpushed changes.
6
7
 
7
8
  ![Confirm Deploy](http://i.imgur.com/7IdUY.png)
8
9
 
@@ -23,6 +24,23 @@ gem 'capistrano_confirm_branch'
23
24
  Then in your `Capfile` add `require 'capistrano/confirm_branch'` and you will be
24
25
  asked to confirm changing branches before each deploy.
25
26
 
27
+
28
+ ### Configuration options
29
+
30
+ By default `capistrano_confirm_branch` will warn when changing branches AND when
31
+ there are unpushed git commits. You can opt out of either warning by setting the
32
+ following options:
33
+
34
+ ```ruby
35
+ # config/deploy.rb
36
+
37
+ # Turn off unpushed git commit check
38
+ set :check_unpushed_commits_before_deploy, false
39
+
40
+ # Turn off branch change warning
41
+ set :confirm_branch_before_deploy, false
42
+ ```
43
+
26
44
  ## Bonus
27
45
 
28
46
  To deploy from the current working branch, use this in your capistrano recipe:
@@ -39,4 +57,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
39
57
 
40
58
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
41
59
 
42
- 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.
60
+ 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.
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module ConfirmBranch
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -1,6 +1,8 @@
1
1
  namespace :confirm_branch do
2
2
  desc 'Confirms deployment when switching deployed branches'
3
3
  task :check_deployed_branch do
4
+ return unless fetch(:confirm_branch_before_deploy, true)
5
+
4
6
  ui = HighLine.new
5
7
  deployed_branch = nil
6
8
  pending_deploy_branch = fetch(:branch)
@@ -27,12 +29,42 @@ namespace :confirm_branch do
27
29
 
28
30
  abort unless ui.agree(
29
31
  "Do you wish to continue deploying #{pending_deploy_branch}?"
30
- )
32
+ ) {|a| a.default = 'yes' }
33
+ end
34
+ end
35
+
36
+ desc 'Confirms there are no pending commits to be pushed'
37
+ task :check_unpushed_commits do
38
+ if fetch(:scm).to_s == 'git' &&
39
+ fetch(:check_unpushed_commits_before_deploy, true)
40
+ pending_commits = `git status`
41
+
42
+ unless pending_commits[/Your branch is up-to-date/]
43
+ pending_commits = /(Your branch is ahead of '\S*' by \d commits?)/.
44
+ match(pending_commits).captures.first
45
+
46
+ ui = HighLine.new
47
+
48
+ ui.say %{
49
+ ============ WARNING: Unpushed Commits Present ============
50
+
51
+ #{pending_commits}
52
+
53
+ ===========================================================
54
+
55
+ }
56
+
57
+ abort unless ui.agree(
58
+ "Do you wish to continue deploying?"
59
+ ) {|a| a.default = 'yes' }
60
+ end
31
61
  end
32
62
  end
33
63
 
34
64
  desc 'Updates the file which tracks the currently deployed branch'
35
65
  task :update_current_branch do
66
+ return unless fetch(:confirm_branch_before_deploy, true)
67
+
36
68
  on release_roles(:all) do
37
69
  within shared_path do
38
70
  execute :echo, %{"#{fetch(:branch)}" > current_branch}
@@ -41,5 +73,7 @@ namespace :confirm_branch do
41
73
  end
42
74
  end
43
75
 
76
+ before 'deploy', 'confirm_branch:check_unpushed_commits'
77
+
44
78
  before 'deploy', 'confirm_branch:check_deployed_branch'
45
79
  after 'deploy', 'confirm_branch:update_current_branch'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_confirm_branch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Byron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -51,7 +51,7 @@ files:
51
51
  - lib/capistrano/confirm_branch.rb
52
52
  - lib/capistrano/confirm_branch/version.rb
53
53
  - lib/capistrano/tasks/confirm_branch.rake
54
- homepage: https://github.com/elm-city-craftworks/capistrano_confirm_branch
54
+ homepage: https://github.com/madriska/capistrano_confirm_branch
55
55
  licenses: []
56
56
  metadata: {}
57
57
  post_install_message: