git-runner-deploy 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/git-runner-deploy.rb +29 -19
  3. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 391c6b17b3feaa48e361581e5545da6046f0db54
4
- data.tar.gz: 5ca2f915d73f198fc00c9ff63bee910ed4816f73
3
+ metadata.gz: 1f2da21103512291854c878d6438d517941367a5
4
+ data.tar.gz: 7e4f5136ae27f59394737147c3e4c493dbf06c0c
5
5
  SHA512:
6
- metadata.gz: 4ff52f97346cd4db10ffaf8468c1332cb634a83bddd62b4c6df5e5bc6198eba3486acb1b89c00477362c93a14f2b4348e53f4f3ef8f8b08d3d0ac4a2e7887c60
7
- data.tar.gz: 8d88de1869aedc7640e59a0b85cbfe9b8aa29d214d595abf2fdfda66e1d9843d5138340a4289a0c2a0126d4bddf04a07b7b648c357a4c445befe1fec6ec3995c
6
+ metadata.gz: 6b8bb8ff2ad4f52a17da7b87ad0281a8c5725abc4fd9306e23cdd3f2e17508889cd989f8efabd308807343b6e8586cec2d52fab5e7fa4e3bb609a51f1ffb0260
7
+ data.tar.gz: 4a9521c6ddf9acddf2d0530f923f2486fc54555ab3ae6a98f74423add0e78fd74cc021d8cc4dba098cc4d00374adb9558d91b180281b3f63661afe4d17ae3e17
@@ -7,7 +7,7 @@ module GitRunner
7
7
 
8
8
  # Performs deployments using capistrano (cap deploy)
9
9
  class Deploy < Base
10
- VERSION = '0.1.5'
10
+ VERSION = '0.2.0'
11
11
 
12
12
  attr_accessor :clone_directory
13
13
 
@@ -24,7 +24,6 @@ module GitRunner
24
24
  Text.out(Text.green("Performing Deploy (#{environment_from_branch(branch)})"), :heading)
25
25
 
26
26
  checkout_branch
27
- ensure_presence_of_capfile
28
27
  prepare_deploy_environment
29
28
  perform_deploy
30
29
 
@@ -40,17 +39,32 @@ module GitRunner
40
39
 
41
40
 
42
41
  private
43
- def branches
44
- args.split(/\s+/)
42
+ def default_deploy_command(branch_name)
43
+ if multistage?
44
+ "cap #{branch_name == 'master' ? 'production' : branch} deploy"
45
+ else
46
+ "cap deploy"
47
+ end
45
48
  end
46
49
 
47
- def ensure_presence_of_capfile
48
- unless File.exists?("#{clone_directory}/Capfile")
49
- Text.out(Text.red("Missing Capfile, unable to complete deploy."))
50
- fail!
50
+ def branches_with_commands
51
+ b_args = args.dup
52
+
53
+ if !b_args.empty? && b_args.scan(/\((.*?)(?:="(.*?)"?)?\)/).empty?
54
+ # Support old format for branch declarations
55
+ b_args = b_args.split(/\s+/).map { |a| "(#{a})" }.join
56
+ end
57
+
58
+ b_args.scan(/\((.*?)(?:="(.*?)"?)?\)/).inject({}) do |hash, (branch, command)|
59
+ hash[branch] = command || default_deploy_command(branch)
60
+ hash
51
61
  end
52
62
  end
53
63
 
64
+ def branches
65
+ branches_with_commands.keys
66
+ end
67
+
54
68
  def uses_bundler?
55
69
  File.exists?("#{clone_directory}/Gemfile")
56
70
  end
@@ -98,29 +112,25 @@ module GitRunner
98
112
  end
99
113
 
100
114
  def perform_deploy
101
- cap_deploy_command = if multistage?
102
- Text.out("Deploying application (multistage detected)")
103
- "cap #{environment_from_branch(branch)} deploy"
104
- else
105
- Text.out("Deploying application")
106
- "cap deploy"
107
- end
115
+ deploy_command = branches_with_commands[branch.name] || default_deploy_command(branch.name)
108
116
 
109
117
  # 'bundle exec' if bundler is being used
110
- cap_deploy_command = "bundle exec #{cap_deploy_command}" if uses_bundler?
118
+ deploy_command = "bundle exec #{deploy_command}" if uses_bundler?
119
+
120
+ Text.out("Deploying application (#{deploy_command})")
111
121
 
112
122
  Text.indent do
113
123
  execute(
114
124
  "cd #{clone_directory}",
115
- cap_deploy_command,
116
- :errproc => method(:cap_deploy_outproc)
125
+ deploy_command,
126
+ :errproc => method(:deploy_outproc)
117
127
  )
118
128
  end
119
129
 
120
130
  GitRunner::Hooks.fire(:deploy_success, self)
121
131
  end
122
132
 
123
- def cap_deploy_outproc(out)
133
+ def deploy_outproc(out)
124
134
  if out =~ /executing `(.*)'/
125
135
  case $1
126
136
  when 'deploy:update_code'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-runner-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git-runner
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.2
27
27
  description: Capistrano deploy module for git-runner
@@ -31,7 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
35
  - Gemfile
36
36
  - LICENSE.txt
37
37
  - README.md
@@ -47,17 +47,17 @@ require_paths:
47
47
  - lib
48
48
  required_ruby_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.0.6
60
+ rubygems_version: 2.2.2
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Capistrano deploy module for git-runner