engineyard-serverside 2.7.0.pre → 2.7.8pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/bin/engineyard-serverside +1 -1
  2. data/lib/engineyard-serverside/about.rb +8 -7
  3. data/lib/engineyard-serverside/cli.rb +225 -4
  4. data/lib/engineyard-serverside/cli_helpers.rb +53 -0
  5. data/lib/engineyard-serverside/configuration.rb +0 -1
  6. data/lib/engineyard-serverside/dependency_manager/bundler.rb +18 -46
  7. data/lib/engineyard-serverside/dependency_manager/npm.rb +1 -12
  8. data/lib/engineyard-serverside/deploy.rb +45 -7
  9. data/lib/engineyard-serverside/deploy_hook.rb +83 -20
  10. data/lib/engineyard-serverside/maintenance.rb +9 -1
  11. data/lib/engineyard-serverside/paths.rb +0 -11
  12. data/lib/engineyard-serverside/rails_assets.rb +1 -2
  13. data/lib/engineyard-serverside/version.rb +1 -1
  14. data/spec/archive_deploy_spec.rb +53 -0
  15. data/spec/basic_deploy_spec.rb +26 -0
  16. data/spec/bundler_deploy_spec.rb +139 -0
  17. data/spec/configuration_spec.rb +205 -0
  18. data/spec/custom_deploy_spec.rb +128 -0
  19. data/spec/deploy_hook_spec.rb +362 -0
  20. data/spec/deprecation_spec.rb +23 -0
  21. data/spec/ey_yml_customized_deploy_spec.rb +99 -0
  22. data/spec/fixtures/gitrepo.tar.gz +0 -0
  23. data/{lib/engineyard-serverside/callbacks/hooks.rb → spec/fixtures/gitrepo/bar} +0 -0
  24. data/spec/fixtures/gitrepo/foo +0 -0
  25. data/spec/fixtures/invalid_hook.rb +1 -0
  26. data/spec/fixtures/lockfiles/0.9-no-bundler +111 -0
  27. data/spec/fixtures/lockfiles/0.9-with-bundler +117 -0
  28. data/spec/fixtures/lockfiles/1.0-no-bundler +54 -0
  29. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +162 -0
  30. data/spec/fixtures/lockfiles/1.0.18-do_mysql +88 -0
  31. data/spec/fixtures/lockfiles/1.0.18-do_postgres +79 -0
  32. data/spec/fixtures/lockfiles/1.0.18-mysql +43 -0
  33. data/spec/fixtures/lockfiles/1.0.18-mysql2 +43 -0
  34. data/spec/fixtures/lockfiles/1.0.18-pg +43 -0
  35. data/spec/fixtures/lockfiles/1.0.6-no-bundler +51 -0
  36. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +52 -0
  37. data/spec/fixtures/lockfiles/1.0.6-with-bundler +52 -0
  38. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +112 -0
  39. data/spec/fixtures/lockfiles/not-a-lockfile +1 -0
  40. data/spec/fixtures/repos/assets_detected/Gemfile +5 -0
  41. data/spec/fixtures/repos/assets_detected/Gemfile.lock +88 -0
  42. data/spec/fixtures/repos/assets_detected/README +1 -0
  43. data/spec/fixtures/repos/assets_detected/Rakefile +5 -0
  44. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  45. data/spec/fixtures/repos/assets_detected/config/application.rb +5 -0
  46. data/spec/fixtures/repos/assets_detected/config/ey.yml +3 -0
  47. data/spec/fixtures/repos/assets_disabled/Gemfile +5 -0
  48. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +88 -0
  49. data/spec/fixtures/repos/assets_disabled/README +1 -0
  50. data/spec/fixtures/repos/assets_disabled/Rakefile +6 -0
  51. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  52. data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
  53. data/spec/fixtures/repos/assets_disabled/config/ey.yml +3 -0
  54. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +5 -0
  55. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +88 -0
  56. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
  57. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +6 -0
  58. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  59. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
  60. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +5 -0
  61. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +5 -0
  62. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +88 -0
  63. data/spec/fixtures/repos/assets_disabled_utf8/README +3 -0
  64. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +5 -0
  65. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  66. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +7 -0
  67. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +3 -0
  68. data/spec/fixtures/repos/assets_enabled_all/Gemfile +5 -0
  69. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +88 -0
  70. data/spec/fixtures/repos/assets_enabled_all/README +1 -0
  71. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  72. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +5 -0
  73. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +6 -0
  74. data/spec/fixtures/repos/assets_enabled_all/script/assets +5 -0
  75. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +1 -0
  76. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +3 -0
  77. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +10 -0
  78. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
  79. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +8 -0
  80. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
  81. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +5 -0
  82. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +88 -0
  83. data/spec/fixtures/repos/assets_enabled_util_only/README +1 -0
  84. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +6 -0
  85. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  86. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +5 -0
  87. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +6 -0
  88. data/spec/fixtures/repos/assets_in_hook/Gemfile +5 -0
  89. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +88 -0
  90. data/spec/fixtures/repos/assets_in_hook/README +2 -0
  91. data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
  92. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  93. data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
  94. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +3 -0
  95. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +2 -0
  96. data/spec/fixtures/repos/bundle_fails/Gemfile +1 -0
  97. data/spec/fixtures/repos/bundle_fails/README +1 -0
  98. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +1 -0
  99. data/spec/fixtures/repos/bundler_disabled/Gemfile +4 -0
  100. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +12 -0
  101. data/spec/fixtures/repos/bundler_disabled/README +1 -0
  102. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +2 -0
  103. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +1 -0
  104. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +1 -0
  105. data/spec/fixtures/repos/default/Gemfile +4 -0
  106. data/spec/fixtures/repos/default/Gemfile.lock +12 -0
  107. data/spec/fixtures/repos/default/README +5 -0
  108. data/spec/fixtures/repos/default/ey.yml +3 -0
  109. data/spec/fixtures/repos/executable_hooks/README +1 -0
  110. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +72 -0
  111. data/spec/fixtures/repos/executable_hooks_not_executable/README +3 -0
  112. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +3 -0
  113. data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
  114. data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
  115. data/spec/fixtures/repos/ey_yml/README +1 -0
  116. data/spec/fixtures/repos/ey_yml/config/ey.yml +18 -0
  117. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
  118. data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
  119. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
  120. data/spec/fixtures/repos/ey_yml_alt/README +1 -0
  121. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
  122. data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
  123. data/spec/fixtures/repos/hook_fails/README +1 -0
  124. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +1 -0
  125. data/spec/fixtures/repos/hooks/README +1 -0
  126. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
  127. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
  128. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +1 -0
  129. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
  130. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
  131. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
  132. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
  133. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
  134. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +1 -0
  135. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
  136. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
  137. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
  138. data/spec/fixtures/repos/multi_dep_manager/README +1 -0
  139. data/spec/fixtures/repos/multi_dep_manager/composer.json +5 -0
  140. data/spec/fixtures/repos/multi_dep_manager/composer.lock +462 -0
  141. data/spec/fixtures/repos/multi_dep_manager/package.json +7 -0
  142. data/spec/fixtures/repos/multi_dep_manager/public/index.php +4 -0
  143. data/spec/fixtures/repos/no_ey_config/Gemfile +3 -0
  144. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +10 -0
  145. data/spec/fixtures/repos/no_ey_config/README +1 -0
  146. data/spec/fixtures/repos/no_ey_config/ey.yml +3 -0
  147. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +4 -0
  148. data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
  149. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +3 -0
  150. data/spec/fixtures/repos/nodejs/README +1 -0
  151. data/spec/fixtures/repos/nodejs/package.json +7 -0
  152. data/spec/fixtures/repos/not_bundled/README +1 -0
  153. data/spec/fixtures/repos/npm_disabled/README +1 -0
  154. data/spec/fixtures/repos/npm_disabled/config/ey.yml +2 -0
  155. data/spec/fixtures/repos/npm_disabled/package.json +7 -0
  156. data/spec/fixtures/repos/php_composer_disabled/README +1 -0
  157. data/spec/fixtures/repos/php_composer_disabled/composer.json +5 -0
  158. data/spec/fixtures/repos/php_composer_disabled/composer.lock +462 -0
  159. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +2 -0
  160. data/spec/fixtures/repos/php_composer_disabled/public/index.php +4 -0
  161. data/spec/fixtures/repos/php_composer_lock/README +1 -0
  162. data/spec/fixtures/repos/php_composer_lock/composer.json +5 -0
  163. data/spec/fixtures/repos/php_composer_lock/composer.lock +462 -0
  164. data/spec/fixtures/repos/php_composer_lock/public/index.php +4 -0
  165. data/spec/fixtures/repos/php_no_composer_lock/README +1 -0
  166. data/spec/fixtures/repos/php_no_composer_lock/composer.json +21 -0
  167. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +4 -0
  168. data/spec/fixtures/repos/public_system/Gemfile +4 -0
  169. data/spec/fixtures/repos/public_system/Gemfile.lock +12 -0
  170. data/spec/fixtures/repos/public_system/README +5 -0
  171. data/spec/fixtures/repos/public_system/ey.yml +3 -0
  172. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +3 -0
  173. data/spec/fixtures/repos/sqlite3/Gemfile +4 -0
  174. data/spec/fixtures/repos/sqlite3/Gemfile.lock +89 -0
  175. data/spec/fixtures/repos/sqlite3/README +1 -0
  176. data/spec/fixtures/retwisj.war +0 -0
  177. data/spec/fixtures/valid_hook.rb +1 -0
  178. data/spec/git_strategy_spec.rb +34 -0
  179. data/spec/lockfile_parser_spec.rb +122 -0
  180. data/spec/maintenance_spec.rb +44 -0
  181. data/spec/multi_dependency_manager_spec.rb +25 -0
  182. data/spec/nodejs_deploy_spec.rb +30 -0
  183. data/spec/php_deploy_spec.rb +81 -0
  184. data/spec/platform_configure_spec.rb +61 -0
  185. data/spec/rails31_deploy_spec.rb +164 -0
  186. data/spec/restart_spec.rb +43 -0
  187. data/spec/rollback_spec.rb +87 -0
  188. data/spec/server_spec.rb +70 -0
  189. data/spec/services_deploy_spec.rb +153 -0
  190. data/spec/shell_spec.rb +57 -0
  191. data/spec/source/archive_spec.rb +33 -0
  192. data/spec/source/git_spec.rb +44 -0
  193. data/spec/spec_helper.rb +355 -0
  194. data/spec/sqlite3_deploy_spec.rb +38 -0
  195. data/spec/support/integration.rb +103 -0
  196. data/spec/support/source_doubles.rb +28 -0
  197. data/spec/support/timecop.rb +5 -0
  198. data/spec/symlink_spec.rb +15 -0
  199. metadata +522 -184
  200. data/lib/engineyard-serverside/callbacks.rb +0 -11
  201. data/lib/engineyard-serverside/callbacks/collection.rb +0 -17
  202. data/lib/engineyard-serverside/callbacks/collection/base.rb +0 -94
  203. data/lib/engineyard-serverside/callbacks/collection/combined.rb +0 -45
  204. data/lib/engineyard-serverside/callbacks/collection/deploy_hooks.rb +0 -21
  205. data/lib/engineyard-serverside/callbacks/collection/service_hooks.rb +0 -17
  206. data/lib/engineyard-serverside/callbacks/collection/service_hooks/collection.rb +0 -24
  207. data/lib/engineyard-serverside/callbacks/collection/service_hooks/combined.rb +0 -40
  208. data/lib/engineyard-serverside/callbacks/distributor.rb +0 -23
  209. data/lib/engineyard-serverside/callbacks/distributor/base.rb +0 -38
  210. data/lib/engineyard-serverside/callbacks/distributor/executable.rb +0 -19
  211. data/lib/engineyard-serverside/callbacks/distributor/executable/runnable.rb +0 -41
  212. data/lib/engineyard-serverside/callbacks/distributor/executable/unrunnable.rb +0 -19
  213. data/lib/engineyard-serverside/callbacks/distributor/ruby.rb +0 -59
  214. data/lib/engineyard-serverside/callbacks/distributor/ruby/distributor.rb +0 -57
  215. data/lib/engineyard-serverside/callbacks/hooks/app.rb +0 -17
  216. data/lib/engineyard-serverside/callbacks/hooks/base.rb +0 -39
  217. data/lib/engineyard-serverside/callbacks/hooks/service.rb +0 -24
  218. data/lib/engineyard-serverside/callbacks/service_hook.rb +0 -20
  219. data/lib/engineyard-serverside/cli/app.rb +0 -136
  220. data/lib/engineyard-serverside/cli/helpers.rb +0 -58
  221. data/lib/engineyard-serverside/cli/server_hash_extractor.rb +0 -49
  222. data/lib/engineyard-serverside/cli/workflows.rb +0 -45
  223. data/lib/engineyard-serverside/cli/workflows/base.rb +0 -78
  224. data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +0 -31
  225. data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +0 -28
  226. data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +0 -29
  227. data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +0 -29
  228. data/lib/engineyard-serverside/cli/workflows/errors.rb +0 -13
  229. data/lib/engineyard-serverside/cli/workflows/helpers.rb +0 -21
  230. data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +0 -71
  231. data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +0 -36
  232. data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +0 -28
  233. data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +0 -28
  234. data/lib/engineyard-serverside/deploy_hook/callback_context.rb +0 -77
  235. data/lib/engineyard-serverside/propagator.rb +0 -59
  236. data/lib/engineyard-serverside/slug.rb +0 -7
  237. data/lib/engineyard-serverside/slug/distributor.rb +0 -58
  238. data/lib/engineyard-serverside/slug/enabler.rb +0 -100
  239. data/lib/engineyard-serverside/slug/failure_handler.rb +0 -24
  240. data/lib/engineyard-serverside/slug/finalizer.rb +0 -86
  241. data/lib/engineyard-serverside/slug/generator.rb +0 -29
  242. data/lib/engineyard-serverside/slug/migrator.rb +0 -41
  243. data/lib/engineyard-serverside/slug/restarter.rb +0 -103
  244. data/lib/engineyard-serverside/slug/source.rb +0 -16
  245. data/lib/engineyard-serverside/slug/source/updater.rb +0 -194
  246. data/lib/railway.rb +0 -43
  247. data/lib/result.rb +0 -7
  248. data/lib/result/base.rb +0 -41
  249. data/lib/result/dsl.rb +0 -16
  250. data/lib/result/failure.rb +0 -29
  251. data/lib/result/success.rb +0 -24
  252. data/lib/runner.rb +0 -34
@@ -1,16 +0,0 @@
1
- require 'engineyard-serverside/slug/source/updater'
2
-
3
- module EY
4
- module Serverside
5
- module Slug
6
- module Source
7
-
8
- def self.update(data = {})
9
- Updater.new(data).update
10
- end
11
-
12
-
13
- end
14
- end
15
- end
16
- end
@@ -1,194 +0,0 @@
1
- require 'railway'
2
- require 'runner'
3
-
4
- module EY
5
- module Serverside
6
- module Slug
7
- module Source
8
-
9
- class Updater
10
- include Railway
11
- include Runner
12
-
13
- step :create_source_cache
14
- step :ensure_ssh_wrapper
15
- step :determine_if_clone_needed
16
- step :clone_if_necessary
17
- step :prune_source_cache
18
- step :fetch_updates
19
- step :clean_local_branch
20
- step :calculate_requested_revision
21
- step :checkout_requested_revision
22
- step :sync_submodules
23
- step :update_submodules
24
- step :clean_source_cache
25
-
26
- attr_reader :source_cache, :uri, :git, :quiet, :ref, :config
27
-
28
- def initialize(input = {})
29
- @input = input
30
- @config = input[:config]
31
- source = input[:config].source
32
- @source_cache = source.source_cache
33
- @uri = source.uri
34
- @quiet = source.opts[:verbose] ? '' : '--quiet'
35
- @ref = source.ref
36
- @git = "#{wrapped_git} --git-dir #{source_cache}/.git --work-tree #{source_cache}"
37
- end
38
-
39
- def update
40
- call(@input)
41
- end
42
-
43
- private
44
-
45
- def wrapped_git
46
- "GIT_SSH=#{paths.ssh_wrapper} git"
47
- end
48
-
49
- def create_source_cache(input = {})
50
- begin
51
- source_cache.mkpath
52
- rescue
53
- return Failure(:error => "Could not create #{source_cache}")
54
- end
55
-
56
- Success(input)
57
- end
58
-
59
- def ensure_ssh_wrapper(input = {})
60
- wrapper_location = paths.ssh_wrapper
61
-
62
- return Success(input) if File.executable?(wrapper_location)
63
-
64
- begin
65
- wrapper = File.open(wrapper_location, 'w', 0700)
66
- wrapper.write <<-WRAPPER
67
- #!/bin/sh
68
-
69
- unset SSH_AUTH_SOCK
70
-
71
- command=$(wcho "$*" | sed -e 's/^-batch //')
72
-
73
- ssh -o CheckHostIP=no -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o LogLevel=INFO -o IdentityFile=#{paths.deploy_key} -o IdentitiesOnly=yes ${command}
74
- WRAPPER
75
- wrapper.close
76
- rescue => e
77
- return Failure(input.merge(:error => e))
78
- end
79
-
80
- Success(input)
81
- end
82
-
83
- def determine_if_clone_needed(input = {})
84
-
85
- check =
86
- source_cache.directory? &&
87
- run_and_output("#{git} remote -v | grep original").include?(uri)
88
-
89
- Success(input.merge(:clone_needed => !check))
90
- end
91
-
92
- def clone_if_necessary(input = {})
93
- if input[:clone_needed]
94
- unless run_and_success?("rm -rf #{source_cache} && git clone #{quiet} #{uri} #{source_cache} 2>&1")
95
-
96
- return Failure(
97
- input.merge(:error => "Could not clone #{uri} to #{source_cache}")
98
- )
99
- end
100
- end
101
-
102
- Success(input)
103
- end
104
-
105
- def prune_source_cache(input = {})
106
- return Failure(
107
- input.merge(:error => "Could not prune #{source_cache}")
108
- ) unless run_and_success?("#{git} remote prune origin 2>&1")
109
-
110
- Success(input)
111
- end
112
-
113
- def fetch_updates(input = {})
114
- return Failure(
115
- input.merge(:error => "Could not fetch #{source_cache}")
116
- ) unless run_and_success?("#{git} fetch --force --prune --update-head-ok #{quiet} origin '+refs/heads/*:refs/remotes/origin/*' '+refs/tags/*:refs/tags/*' 2>&1")
117
-
118
- Success(input)
119
- end
120
-
121
- def clean_local_branch(input = {})
122
- run_and_success?("#{git} show-branch #{ref} > /dev/null 2>&1 && #{git} branch -D #{ref} > /dev/null 2>&1")
123
-
124
- Success(input)
125
- end
126
-
127
- def calculate_requested_revision(input = {})
128
- remote_branch = Dir.chdir(source_cache) do
129
- run_and_success?("#{git} show-branch origin/#{ref} > /dev/null 2>&1")
130
- end
131
-
132
- Success(
133
- input.merge(
134
- :requested_branch => remote_branch ? "origin/#{ref}" : ref
135
- )
136
- )
137
- end
138
-
139
- def checkout_requested_revision(input = {})
140
- requested_branch = input[:requested_branch]
141
-
142
- Dir.chdir(source_cache) {
143
- run_and_success?(
144
- "git checkout --force #{quiet} '#{requested_branch}'"
145
- ) || run_and_success?(
146
- "git reset --hard #{quiet} '#{requested_branch}'"
147
- )
148
- } ?
149
- Success(input) :
150
- Failure(
151
- input.merge(:error => "Could not check out #{requested_branch}")
152
- )
153
- end
154
-
155
- def sync_submodules(input = {})
156
- return Failure(
157
- input.merge(:error => "Could not sync submodules")
158
- ) unless Dir.chdir(source_cache) {
159
- run_and_success?("#{wrapped_git} submodule sync")
160
- }
161
-
162
- Success(input)
163
- end
164
-
165
- def update_submodules(input = {})
166
- return Failure(
167
- input.merge(:error => "Could not update submodules")
168
- ) unless Dir.chdir(source_cache) {
169
- run_and_success?("#{wrapped_git} submodule update --init --recursive")
170
- }
171
-
172
- Success(input)
173
- end
174
-
175
- def clean_source_cache(input = {})
176
- return Failure(
177
- input.merge(:error => "Could not clean source")
178
- ) unless Dir.chdir(source_cache) {
179
- run_and_success?('git clean -dfq')
180
- }
181
-
182
- Success(input)
183
- end
184
-
185
- def paths
186
- config.paths
187
- end
188
-
189
- end
190
-
191
- end
192
- end
193
- end
194
- end
@@ -1,43 +0,0 @@
1
- require 'result'
2
-
3
- module Railway
4
- include Result::DSL
5
-
6
- module DSL
7
- def step(name, options = {})
8
- with = options.delete(:with)
9
- steps.push(:name => name, :with => with)
10
- end
11
-
12
- def steps
13
- @steps ||= []
14
- end
15
- end
16
-
17
- def self.included(base)
18
- base.send :extend, DSL
19
- end
20
-
21
- def call(input = {})
22
- steps = self.class.steps
23
-
24
- return Failure('No steps') if steps.empty?
25
-
26
- steps.
27
- inject(Success(input)) {|result, step|
28
- result.and_then {|data|
29
- dispatch_step(step, data)
30
- }
31
- }
32
- end
33
-
34
- private
35
- def dispatch_step(step, data)
36
- begin
37
- result = (step[:with] || self).send(step[:name], data)
38
- result.is_a?(Result::Base) ? result : Success(result)
39
- rescue => error
40
- Failure(error)
41
- end
42
- end
43
- end
@@ -1,7 +0,0 @@
1
- require 'result/dsl'
2
- require 'result/success'
3
- require 'result/failure'
4
-
5
- module Result
6
- extend DSL
7
- end
@@ -1,41 +0,0 @@
1
- module Result
2
-
3
- class Base
4
- def initialize(to_wrap)
5
- @wrapped = to_wrap
6
- end
7
-
8
- def success?
9
- false
10
- end
11
-
12
- def failure?
13
- false
14
- end
15
-
16
- def value
17
- raise "not present"
18
- end
19
-
20
- def error
21
- raise "not present"
22
- end
23
-
24
- def and_then
25
- self
26
- end
27
-
28
- def or_else
29
- self
30
- end
31
-
32
- def on_success
33
- self
34
- end
35
-
36
- def on_failure
37
- self
38
- end
39
- end
40
-
41
- end
@@ -1,16 +0,0 @@
1
- require 'result/success'
2
- require 'result/failure'
3
-
4
- module Result
5
-
6
- module DSL
7
- def Success(value)
8
- Success.new(value)
9
- end
10
-
11
- def Failure(error)
12
- Failure.new(error)
13
- end
14
- end
15
-
16
- end
@@ -1,29 +0,0 @@
1
- require 'result/base'
2
-
3
- module Result
4
-
5
- class Failure < Base
6
- def initialize(to_wrap)
7
- super
8
- freeze
9
- end
10
-
11
- def error
12
- @wrapped
13
- end
14
-
15
- def failure?
16
- true
17
- end
18
-
19
- def or_else
20
- yield error
21
- end
22
-
23
- def on_failure
24
- yield error
25
- super
26
- end
27
- end
28
-
29
- end
@@ -1,24 +0,0 @@
1
- require 'result/base'
2
-
3
- module Result
4
-
5
- class Success < Base
6
- def value
7
- @wrapped
8
- end
9
-
10
- def success?
11
- true
12
- end
13
-
14
- def and_then
15
- yield value
16
- end
17
-
18
- def on_success
19
- yield value
20
- super
21
- end
22
- end
23
-
24
- end
@@ -1,34 +0,0 @@
1
- require 'engineyard-serverside/spawner'
2
-
3
- module Runner
4
- def runner
5
- EY::Serverside::Spawner
6
- end
7
-
8
- # Internal: Run a command.
9
- #
10
- # cmd - A string command.
11
- #
12
- # Returns an instance of Spawner.
13
- def run(cmd)
14
- runner.run(cmd, shell, nil)
15
- end
16
-
17
- # Internal: Run a command and return the output.
18
- #
19
- # cmd - A string command.
20
- #
21
- # Returns the output of the command.
22
- def run_and_output(cmd)
23
- run(cmd).output
24
- end
25
-
26
- # Internal: Run a command and check if it was successful.
27
- #
28
- # cmd - A string command.
29
- #
30
- # Returns success.
31
- def run_and_success?(cmd)
32
- run(cmd).success?
33
- end
34
- end